mysql5 主从设置

来源:互联网 发布:matlab2016拟合数据 编辑:程序博客网 时间:2024/04/29 22:29
mysql5 的主从简化了好多,网上大把例子用以前的参数反而不能用,这里mark一下。版本:5.1.56版本一致性:同一版本(要求:从库版本不低于主库版本)主库设置:创建账号:grant replication slave,file on *.* to 'slave_user'@'slave_host' identified by 'slave_pwd';配置主my.cnf:bind-address=0.0.0.0server_id=1log-bin=mysql-binbinlog-do-db=db1binlog-do-db=db2...binlog-ignore-db=idb1binlog-ignore-db=idb2...重启mysqlshow master status \G先记录master当前日志文件名mysql-bin.index和行位置position,再向从库恢复对应数据库配置从my.cnf:server_id=2(大于主库)replicate-do-db=db1replicate-do-db=db2...replicate-ignore-db=idb1replicate-ignore-db=idb2...重启mysqlslave stop;change master to master_host='master_host',master_user='slave_user',master_password='slave_pwd',master_log_file='mysql-bin.index',master_log_pos=pos;slave start;show slave status \G查看从库状态,slave_io_running以及slave_sql_running 正常即可作后续测试。

原创粉丝点击