配置主服务器
启用binlog日志
[root@mysql11 ~]# vim /etc/my.cnf
log_bin=master11
server_id=11
[root@mysql11 ~]# systemctl restart mysqld
用户授权
[root@mysql11 ~]# mysql -uroot -p123qqq...A
mysql> grant replication slave on *.* to repluser@"%" identified by "123qqq...A";
查看日志信息
mysql> show master status;

配置从服务器
指定server_id
[root@mysql22 mysql]# vim /etc/my.cnf server_id=22
[root@mysql22 mysql]# systemctl restart mysqld
指定主服务器信息
mysql> change master to master_host="192.168.4.11",master_user="repluser",
->
master_password="123qqq...A",master_log_file="master11.000001",master_log_pos=441;
启动slave进程
mysql> start slave;
Query OK, 0 rows affected (0.04 sec)
查看状态信息
mysql> show slave status \G;

网友评论