mysql5.7 主从同步
【摘要】 数据库版本mysql --versionmysql Ver 14.14 Distrib 5.7.32, for Linux (x86_64) using EditLine wrapper1,主数据库设置my.cnf //更改之后重启数据库erver-id=1 log-bin=mysql-bin//新建同步用户set global validate_password_policy=0;se...
数据库版本
mysql --version
mysql Ver 14.14 Distrib 5.7.32, for Linux (x86_64) using EditLine wrapper
1,主数据库设置
my.cnf
//更改之后重启数据库
erver-id=1
log-bin=mysql-bin
//新建同步用户
set global validate_password_policy=0;
set global validate_password_length=1;
grant FILE on *.* to 'rep'@'192.168.0.201' identified by '123456';
grant replication slave on *.* to 'rep'@'192.168.0.201' identified by '123456';
flush privileges;
//记录主数据库日志文件位置
mysql> show master status; +------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +------------------+----------+--------------+------------------+-------------------+ | mysql-bin.000002 | 1350 | | | | +------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
2,备数据库设置
my.cnf
//重启数据库
log-bin=mysql-bin server-id=2 binlog-ignore-db=information_schema binlog-ignore-db=performance_schema binlog-ignore-db=mysql
//设置主备同步
//填入主数据库日志文件名称,pos位置
change master to master_host='192.168.0.205', master_user='rep', master_password='123456', master_log_file='mysql-bin.000002', master_log_pos=1350;
启动
mysql> start slave; Query OK, 0 rows affected (0.00 sec)
检查状态
mysql> show slave status\G; *************************** 1. row *************************** Slave_IO_State: Waiting for master to send event Master_Host: 192.168.0.205 Master_User: rep Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000002 Read_Master_Log_Pos: 1350 Relay_Log_File: node01-relay-bin.000002 Relay_Log_Pos: 320 Relay_Master_Log_File: mysql-bin.000002 Slave_IO_Running: Yes Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 1350 Relay_Log_Space: 528 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: 0 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 1 Master_UUID: 8a59fbeb-3a39-11eb-ac5f-000c29ccec7f Master_Info_File: /var/lib/mysql/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for more up dates Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: Executed_Gtid_Set: Auto_Position: 0 Replicate_Rewrite_DB: Channel_Name: Master_TLS_Version: 1 row in set (0.00 sec) ERROR: No query specified mysql>
//
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)