本文共 1277 字,大约阅读时间需要 4 分钟。
连接到主服务器IP地址信息(192.168.2.84):
[root@youyun-284 mysql]# mysql -uroot -p
使用数据库权限管理命令创建‘repl’用户:
CREATE USER 'repl'@'%' IDENTIFIED BY '*********';flush privileges;
定zenith定期修改my.cnf文件,确保以下设置:
server-id = 1binlog_format = mixedlog-bin = master-a-binexpire_logs_days = 7max_binlog_size = 100mbinlog_cache_size = 4mmax_binlog_cache_size = 512mbinary_do_db = pay-order#binlog_do_db = pay-channel
在主服务器上授予从服务器复制权限:
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';flush privileges;
# 使用 systemctl 命令(CentOS/RedHat]systemctl restart mysql# 或者使用 systemctl# systemctl stop mysql && systemctl start mysql
在从服务器上设置主服务器详细信息:
change master to master_host='IP地址信息', master_port=3306, master_user='repl', master_password='*********', master_log_file='master-bin.000001', master_log_pos=10000;
mysql> start slave;
验证从服务状态:
show slave status \G;
重点关注以下状态 ```Slave_IO_State: Waiting for master to send eventSlave_IO_Running: YesSlave_SQL_Running: Yes
### 9. 解锁主表```bashmysql> unlock table;
如需进一步帮助,可参考具体数据库文档或技术支持。
转载地址:http://hlxhz.baihongyu.com/