1, master server configuration.
[Email protected] ~]# vim/etc/my.cnf log-bin=master-binlog-bin-index=master-bin.indexinnodb_file_per_table = 1binlog_format=mixedserver-id = 1 #必须是唯一值sync_binlog =1 #设置主从同步二进制日志文件mysql > GRANT REPLICATION SLAVE on * * to ' Repluser ' @ ' 172.16.%.% ' identified by ' Replpass ';mysql> flush privileges;mysql> SHOW MASTER status\g;
2, slave server configuration.
[[email protected] ~]# vim /etc/my.cnf relay-log = relay-logserver-id = 2relay-log-index = relay-log.indexread-only = on #数据库只读锁定, Does not affect master-slave replication skip_slave_start=1 #禁止slave随数据库启动mysql > change master to master_host= ' 172.16.23.22 ', master_log_file= ' master-bin.000001 ', master_user= ' repluser ', master_password= ' Replpass ', MASTER_ log_pos=4;mysql> help change master to #查看命令用法mysql > show slave STATUS\G; #查看状态mysql > START SLAVE; #启动slave服务mysql > START SLAVE IO_THREAD; #依次启动slave服务mysql > start slave sql_ thread; mysql> show global variables like ' read% '; # View global Variables Verify read-only locking mysql> set global read_only=off; #临时修改系统变量 [[email protected] ~]# cat /datadir/master.info #文件记录了master的连接帐号信息 [[Email protected] ~]# cat /datadir/relay-log.info #文件记录了中继日志的信息