mysql5.5远程主从设置

主机:10.0.0.1
从机:10.0.0.2

1 主机设置
1.1 配置文件/etc/mysql/my.cnf

server-id               = 1
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 2
max_binlog_size         = 100M

binlog_ignore_db = mysql
binlog_ignore_db = information_schema
binlog_ignore_db = performance_schema

binlog_do_db = testcase
binlog_do_db = db100
binlog_do_db = db200

1.2 mysql控制台命令启动master模式

     mysql>GRANT replication slave on *.* to 'slave2'@'10.0.0.2' IDENTIFIED BY 'password';
     mysql>SHOW master status;

2 从机设置
2.1 从机配置

server-id               = 2
log_bin                 = /var/log/mysql/mysql-bin.log
expire_logs_days        = 2
max_binlog_size         = 100M

2.2 从机控制台命令

     mysql>slave stop;
     mysql>change master to master_host='10.0.0.1', master_port=3306, master_user='slave2', master_password='password', master_log_file='mysql-bin.000011', master_log_pos=189;
     mysql>slave start;
     mysql>show slave status \G;

3mysql远程账号设置

mysql>grant all privileges on *.* to njava@10.0.0.1 identified by "password" with grant option;
星期一, 四月 28th, 2014 服务器

Leave a Reply

1LMooBmUE153Wnd3zDryWvDyXxQudbFxDr