A:192.168.1.1 master
B:192.168.1.2 slave
A:
1修改配置參數:
vi /etc/my.cnf
增加:
[mysqld]
log-bin
server-id=1
sql-bin-update-same
binlog-do-db=backup //需要備份的DB
2增加存取權限:
mysql>grant all privileges on *.* to 'ctl.root'@'192.168.1.2' identified by '12345678';
mysql> update mysql.user set password=old_password('12345678') where user='ctl.root' and host='192.168.1.2';
mysql>flush privileges;
mysql>quit
3匯出資料:
./mysql-install-road/bin/mysqldump –uroot –p backup>/backup.sql
B:
1匯入資料
./mysql-install-road/bin/mysql –uroot –p backup </backup.sql
2 vi /etc/my.cnf
server-id=2
master-host=192.168.1.212
master-user=ctl.root
master-password=12345678
master-port=3306
master-connect-retry=10
replicate-do-db=backup
3把master&slave同時重起
4 啟動slave:
mysql>slave start;
mysql>show slave status/G;
mysql>load data from master; //手動同步
A:
mysql>show master status/G;
zz:http://blog.csdn.net/techmylife/archive/2006/04/27/694077.aspx