Master配置:
log-bin = mysql-bin
server-id = 1
binlog-do-db = powerdns #要同步的数据库
Master新增slave账号:
mysql> grant replication slave on *.* to 'slave'@'192.168.1.2' identified by 'passwd';
mysql> flush privileges;
重启Master MySQL,查看Master状态信息,记住File名称,POS位置。
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000002 | 309 | powerdns | mysql |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
Slave配置:
server-id =2
slave-skip-errors = 1062 #跳过重复字段错误
开始同步:
mysql> change master to master_host='192.168.1.1',master_user='slave',master_password='passwd',\
master_log_file='mysql-bin.000002',master_log_pos=309;
mysql> start slave;
查看Slave同步状态:
mysql> show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
标签:none