您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
master | slave | |
---|---|---|
IP | 192.168.7.71 | 192.168.7.72 |
主机名 | master01 | slave01 |
OS | CentOS7 | CentOS7 |
MySQL版本 | 5.7.28 | 5.7.28 |
略
# vim /etc/my.cnf
[mysqld]
log-bin = mysql-bin
server-id = 1
# 重启服务
systemctl start mysqld
grant replication slave on *.* to repluser@'192.168.7.%' identified by '123.com';
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 154 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
[mysqld]
server-id = 2
read_only = ON #设为只读,但是对超级用户无效。
mysql> CHANGE MASTER TO
-> MASTER_HOST='192.168.7.71',
-> MASTER_USER='repluser',
-> MASTER_PASSWORD='123.com',
-> MASTER_PORT=3306,
-> MASTER_LOG_FILE='mysql-bin.000001',
-> MASTER_LOG_POS=154;
mysql> start slave;
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.7.71
Master_User: repluser
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 154
Relay_Log_File: slave01-relay-bin.000002
Relay_Log_Pos: 320
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
...省略信息...
master.info:用于保存slave连接至master时的相关信息,例如账号、密码、服务器地址等
relay-log.info:保存在当前slave节点上已经复制的当前二进制日志和本地relay log日志的对应关系
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。