報此錯誤是由於日誌所在目錄只有root有權限新建文件,從mysql客戶端執行flush logs實際上是以mysql這個帳號去執行的,因此會權限不足node
查看錯誤日誌所在位置 mysql> show variables like '%log_error%'; +---------------------+-----------------------+ | Variable_name | Value | +---------------------+-----------------------+ | binlog_error_action | IGNORE_ERROR | | log_error | /data/mysql/mysql.log | +---------------------+-----------------------+ 2 rows in set (0.00 sec) 查看權限 [root@db02 mysql]# ll total 44 -rw-r--r-- 1 root root 0 Apr 24 19:53 mysql.log 修改權限 [root@db02 mysql]# chown -R mysql. ./* [root@db02 mysql]# ll total 44 -rw-rw---- 1 mysql mysql 290 Apr 25 11:49 mysql-bin.index -rw-r--r-- 1 mysql mysql 0 Apr 24 19:53 mysql.log 再從新flush logs就沒有報此問題了 mysql> flush logs; 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: 10.0.0.51 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000006 Read_Master_Log_Pos: 1444 Relay_Log_File: db03-relay-bin.000002 Relay_Log_Pos: 408 Relay_Master_Log_File: mysql-bin.000006 Slave_IO_Running: Yes Slave_SQL_Running: No Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 1007 Last_Error: Error 'Can't create database 'oldboy'; database exists' on query. Default dat abase: 'oldboy'. Query: 'create database oldboy' Skip_Counter: 0 Exec_Master_Log_Pos: 404 Relay_Log_Space: 1651 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: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 1007 Last_SQL_Error: Error 'Can't create database 'oldboy'; database exists' on query. Default dat abase: 'oldboy'. Query: 'create database oldboy' Replicate_Ignore_Server_Ids: Master_Server_Id: 51 Master_UUID: 45984377-6897-11e9-8ce0-000c2938e32d Master_Info_File: /application/mysql-5.6.42/data/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: 190427 20:02:11 Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 45984377-6897-11e9-8ce0-000c2938e32d:2-6 Executed_Gtid_Set: 45984377-6897-11e9-8ce0-000c2938e32d:1 Auto_Position: 1 解決方法: mysql> reset master; Query OK, 0 rows affected (0.00 sec) mysql> stop slave; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> reset slave; Query OK, 0 rows affected (0.01 sec) mysql> set global gtid_purged='45984377-6897-11e9-8ce0-000c2938e32d:2'; #事務日誌後加1便可 Query OK, 0 rows affected (0.01 sec) mysql> change master to master_host='10.0.0.51',master_user='repl',master_password='123' ,MASTER_AUTO_POSITI ON=1;Query OK, 0 rows affected, 2 warnings (0.01 sec) 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: 10.0.0.51 Master_User: repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000006 Read_Master_Log_Pos: 1444 Relay_Log_File: db03-relay-bin.000002 Relay_Log_Pos: 1553 Relay_Master_Log_File: mysql-bin.000006 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: 1444 Relay_Log_Space: 1756 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: 51 Master_UUID: 45984377-6897-11e9-8ce0-000c2938e32d Master_Info_File: /application/mysql-5.6.42/data/master.info SQL_Delay: 0 SQL_Remaining_Delay: NULL Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it Master_Retry_Count: 86400 Master_Bind: Last_IO_Error_Timestamp: Last_SQL_Error_Timestamp: Master_SSL_Crl: Master_SSL_Crlpath: Retrieved_Gtid_Set: 45984377-6897-11e9-8ce0-000c2938e32d:1:3-6 Executed_Gtid_Set: 45984377-6897-11e9-8ce0-000c2938e32d:1-6 Auto_Position: 1 1 row in set (0.00 sec) ERROR: No query specified
錯誤以下:mysql
[root@db03 ~]# masterha_check_repl --conf=/etc/mha/app1.cnf Sat Apr 27 23:33:29 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping .Sat Apr 27 23:33:29 2019 - [info] Reading application default configuration from /etc/mha/app1.cnf.. Sat Apr 27 23:33:29 2019 - [info] Reading server configuration from /etc/mha/app1.cnf.. Sat Apr 27 23:33:29 2019 - [info] MHA::MasterMonitor version 0.58. Sat Apr 27 23:33:29 2019 - [error][/usr/share/perl5/vendor_perl/MHA/Server.pm, ln180] Got MySQL error when c onnecting 10.0.0.53(10.0.0.53:3306) :1045:Access denied for user 'mha'@'db03' (using password: YES), but this is not a MySQL crash. Check MySQL server settings.Sat Apr 27 23:33:29 2019 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln301] at /usr/share/ perl5/vendor_perl/MHA/ServerManager.pm line 297.Sat Apr 27 23:33:30 2019 - [error][/usr/share/perl5/vendor_perl/MHA/ServerManager.pm, ln309] Got fatal error , stopping operationsSat Apr 27 23:33:30 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm line 329.Sat Apr 27 23:33:30 2019 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.Sat Apr 27 23:33:30 2019 - [info] Got exit code 1 (Not master dead). MySQL Replication Health is NOT OK!
解決方法:redis
須要將每一個數據庫裏的空用戶進行刪除,如root@db01,''@'db01'等用戶,因主機名不一樣此處的用戶也不一樣 mysql> select user,host,password from mysql.user; +------+-----------+----------+ | user | host | password | +------+-----------+----------+ | root | localhost | | | root | db01 | | | root | 127.0.0.1 | | | root | ::1 | | | | localhost | | | | db01 | | +------+-----------+----------+ mysql> drop user root@'db01'; Query OK, 0 rows affected (0.00 sec) mysql> drop user ''@'db01'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
從新添加已刪除的節點時,報此錯誤sql
[ERR] Node 10.0.0.51:7007 is not empty. Either the node already knows other nodes (check with CLUSTER NODES) or contains some key in database 0.
解決方法:數據庫
[root@db01 7007]# redis-cli -h 10.0.0.51 -p 7007 # 鏈接到redis 10.0.0.51:7007> flushdb # 清空數據 OK 10.0.0.51:7007> 10.0.0.51:7007> 10.0.0.51:7007> cluster reset # 重置cluster 再從新添加節點便可