Mysql-主从

                                                                             Alvin.zeng<孤独0-1>

master:192.168.9.11
slave:192.168.9.13
slave:192.168.9.14

master操作: 
#:vim /etc/my.cnf
server-id=1
binlog-do-db=zytest  需要同步的库

#mysql 
mysql>grant replication slave on *.* to 'admin'@'192.168.9.13'identified by '123456';
mysql>grant replication slave on *.* to 'admin'@'192.168.9.14'identified by '123456';
mysql>select user,host from mysql.user;  
mysql>flush tables with read lock;
mysql>show master status;
mysql>unlock tables;

slave13操作:
#:vim /etc/my.cnf
server-id=2

#:mysql
mysql>slave stop;
mysql>change master to master_host='192.168.9.11',master_user='admin',master_password='123456', master_log_file='binlog.000004',master_log_pos=0;
mysql>slave start;
mysql>show slave status\G;


slave14操作:
#:vim /etc/my.cnf
server-id=3

#:mysql
mysql>slave stop;
mysql>change master to master_host='192.168.9.11',master_user='admin',master_password='123456', master_log_file='binlog.000004',master_log_pos=0;
mysql>slave start;
mysql>show slave status\G;