1.1、环境准备
两台机器ip分别为
100.100.100.105 (主)
100.100.100.106(从)
安装 MysqL
[root@centos ~]# yum install MysqL-server MysqL-client -y
[root@centos ~]# service MysqLd start
[root@centos ~]# /usr/bin/MysqLadmin -u root password '123456'
1.2、修改配置文件
100.100.100.105
[root@centos ~]# vim /etc/my.cnf
log-bin=MysqL-bin
server-id=105
100.100.100.106
[root@centos ~]# vim /etc/my.cnf
log-bin=MysqL-bin
server-id=106
1.3、添加MysqL用户
MysqL> grant replication slave on *.* to slave@'100.100.100.106' identified by '123456';
1.4、查看主服务器信息
MysqL> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| MysqL-bin.000004 | 261 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
1.5、登录从MysqL
change master to
master_user='slave',master_password='123456',master_host='100.100.100.105',master_log_file='MysqL-bin.000004',master_log_pos=261;
1.6、开启从MysqL
MysqL> start slave;
1.7、判断成功,可查看如下参数
MysqL> show slave status\G;
Slave_IO_Running: Yes
Slave_sql_Running: Yes