MySQL5.5
IP 192.168.60.134
hostnameora01.dh.cn
master port 3306
slave2 prot 3307
slave3 prot 3308
配置流程修改master配置文件
log-bin=ora01-bin
server-id=1在master授权复制用户
grant replication slaveon*.*to'repli'@'ora01.dh.cn'identified by'123456';
flush privileges;在master上备份数据
mysqldump -A --opt > dump.sql
导出后,保证不要再向master写数据,不然position值会有变化。修改slave配置文件
server-id=2启动slave MySQL(3308端口的MySQL类似)
关闭log_bin(可选)
set global sql_log_bin=OFF;
导入dump.sql文件
mysql -uroot -p -h192.168.60.134 -P3307 < dump.sql
查看master状态
mysql> show master status \G
*************************** 1. row ***************************
File:ora01-bin.000022
Position:187
Binlog_Do_DB:
Binlog_Ignore_DB:
1 row in set (0.00 sec)
指定master复制
change master to master_host='192.168.60.134',master_port=3306,master_user='repli',master_password='123456',master_log_file='ora01-bin.000022',master_log_pos=187;查看同步状态
show slave status \G
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Slave_IO_Running:Slave从Master上读取log_bin,并写入Slave中继日志Relay_Log_File
Slave_SQL_Running:负责读取并且执行中继日志中的log_bin