标签:MySQL
128机器:[root@localhost ~]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL.. SUCCESS!
129机器:
[root@localhost ~]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL.. SUCCESS!
先配主从:
128机器上:
拷贝数据并传输到129机器上
[root@localhost ~]# mysqldump -uroot -p123456 --all-databases > /tmp/mysqlall.sql [root@localhost ~]# scp -r /tmp/mysqlall.sql 192.168.65.129:/tmp/
mysql> grant replication slave on *.* to 'repl'@192.168.65.129 identified by '123456'; mysql> flush privileges;
测试机器数据变化基本没有,所以就不锁表了
129机器上:
[root@localhost ~]# mysql -uroot -p123456 < /tmp/mysqlall.sql
mysql> stop slave; Query OK, 0 rows affected (0.00 sec) mysql> change master to master_host='192.168.65.128', master_user='repl', master_password='123456', master_log_file='thermos.000001, master_log_pos=420; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> start slave; Query OK, 0 rows affected (0.01 sec) mysql> show slave status\G
主从同步完成
主主同步:
129机器上:
更改/etc/my.cnf,增加log_bin
[root@localhost ~]# /etc/init.d/mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL.. SUCCESS!
mysql> grant replication slave on *.* to 'repl'@192.168.65.128 identified by '123456'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
128机器上:
mysql> stop slave; Query OK, 0 rows affected (0.00 sec) mysql> change master to master_host='192.168.65.129', master_user='repl', master_password='123456', master_log_file='alex.000001', master_log_pos=420; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> start slave; Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G
测试主主
128上
129上
(已经多了micheal库)
129上
128上
(多了jackson库)
自己研究的,不知道正确与否,如果有错误,望指正!
标签:MySQL
原文地址:http://blog.51cto.com/11530642/2095380