MySQL主從配置This operation cannot be performed with a running slave io thread; run STOP SLAVE IO_THREAD FOR CHANNEL '' first.
阿新 • • 發佈:2020-12-21
MySQL主從配置This operation cannot be performed with a running slave io thread; run STOP SLAVE IO_THREAD FOR CHANNEL '' first.
報錯介面:
擺錯內容:
ERROR 3021 (HY000): This operation cannot be performed with a running slave io thread; run STOP SLAVE IO_THREAD FOR CHANNEL '' first.
解決辦法:
1.先關閉當前的slave;
mysql> stop slave;
2.檢查主伺服器的配置資訊:
vi /etc/my.cnf
# 檔案末尾檢視追加
log-bin=master-bin
binlog-format=ROW
server-id=1
binlog-do-db=msb
3.檢視主的狀態資訊,在主MySQL下:
mysql> show master status; +-------------------+----------+--------------+------------------+-------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set | +-------------------+----------+--------------+------------------+-------------------+ | master-bin.000009 | 154 | msb | | | +-------------------+----------+--------------+------------------+-------------------+ 1 row in set (0.00 sec)
記住Position,完成後重新關聯:
change master to master_host='192.168.182.111',master_user='root',master_password='123456',master_port=3306,master_log_file='master-bin.000001',master_log_pos=154;
檢視slave狀態:
發現Slave_SQL_Running: No,這地方必須是兩個yes才可以同步。
執行:
STOP SLAVE; SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1; START SLAVE;
再檢視slave狀態:
slave_sql_running和Slave_IO_Running,分別負責slave mysql程序和與主機的io通訊全部是yes,成功!