vim /etc/my.cnf#设置从服务器id,必须于主服务器不同server-id=2#启动MySQ二进制日志系统log-bin=mysql-bin#需要同步的数据库名 。如果不指明同步哪些库,就去掉这行,表示所有库的同步(除了ignore忽略的库)配置主从同步指令
#执行同步前,要先关闭slavemysql> stop slave;mysql> change master to master_host='192.168.150.185',master_user='repl',master_password='repl123',master_log_file='ON.000065',master_log_pos=186607472;mysql> start slave;mysql> show slave status \G;mysql> show slave status \G*************************** 1. row ***************************Slave_IO_State: Waiting for master to send eventMaster_Host: 192.168.150.185Master_User: slaveMaster_Port: 3306Connect_Retry: 60Master_Log_File: ON.000065Read_Master_Log_Pos: 187730832Relay_Log_File: xmkjoa02-relay-bin.000002Relay_Log_Pos: 46151494Relay_Master_Log_File: ON.000065Slave_IO_Running: YesSlave_SQL_Running: YesReplicate_Do_DB:Replicate_Ignore_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_Table:Replicate_Wild_Ignore_Table:Last_Errno: 0Last_Error:Skip_Counter: 0Exec_Master_Log_Pos: 187730832Relay_Log_Space: 46151706Until_Condition: NoneUntil_Log_File:Until_Log_Pos: 0Master_SSL_Allowed: YesMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_SSL_Cipher:Master_SSL_Key:Seconds_Behind_Master: 0Master_SSL_Verify_Server_Cert: NoLast_IO_Errno: 0Last_IO_Error:Last_SQL_Errno: 0Last_SQL_Error:Replicate_Ignore_Server_Ids:Master_Server_Id: 1Master_UUID: 6c3f5abb-1c32-11ec-96ba-fa163e7a46bfMaster_Info_File: mysql.slave_master_infoSQL_Delay: 0SQL_Remaining_Delay: NULLSlave_SQL_Running_State: Slave has read all relay log; waiting for more updatesMaster_Retry_Count: 86400Master_Bind:Last_IO_Error_Timestamp:Last_SQL_Error_Timestamp:Master_SSL_Crl:Master_SSL_Crlpath:Retrieved_Gtid_Set:Executed_Gtid_Set:Auto_Position: 0Replicate_Rewrite_DB:Channel_Name:Master_TLS_Version:Master_public_key_path:Get_master_public_key: 1Network_Namespace:1 row in set (0.00 sec)如上,当IO和SQL线程的状态均为Yes,则表示主从已实现同步了!
【01-MySQL8主从详解】
经验总结扩展阅读
- Dubbo2.7详解
- 属鸡2023年多大年龄了 属鸡人2023全年运势详解
- 华为手环6怎么样_华为手环6功能详解
- logback.xml详解
- iptables使用详解
- RAID5 IO处理之条带读代码详解
- RAID5 IO处理之写请求代码详解
- RAID5 IO处理之重构代码详解
- RAID5 IO处理之replace代码详解
- 二 kafka详解--kafka为什么快
