MySQL双主热备问题处理

摘要:
再次授予权限==例如==˃grantrepplicationslavon*.*to'root'@'192.16.10.21'由'root'标识;˃grantrepplicationslavon*.*to'root'@'192.16.10.23'由'root'标识;2.从机_ IO_状态:等待在主事件失败后重新连接readmysql˃showslavestatiusG***************************1.行***************************从机_ IO状态:等待主事件失败之后重新连接readMaster_主机:192.16.10.231主机_用户:cahmsMaster_端口:3306Connect_重试:60Master_日志_文件:mysql-bin.00003读取_主机_日志_位置:106Relay_日志文件:mysqld-relay-bin.00001中继_日志位置:4Relay_Master_Log_文件:mysql-bin.00003Slave _ IO_运行:NoSlave_SQL_运行:YesReplicate_Do_DB:Replicate_Do_Table:Replicate_Ignore_Table:Replicate_Wild_Do_表:Replicate-Wild_Ignore_Table:Last_Erno:0Last_Error:Skip _计数器:0Exec_Master_Log_位置:106Relay_Log_空间:106Until_条件:无Until_Log_文件:Until_Log位置:0Master_SSL_允许:NoMaster_SSL_CA_File:Master_SSL_CA_Path:Master_SSL_Cert:Master_ SSL_密码:Master_SSL_密钥:Seconds_ Behind_主机:NULLMaster_SSL_Verify_服务器_证书:NoLast_IO_Errno:0Last_IO_Error:Last_SQL_Errno:0Last_SQL_错误:1rownset˃grantreplicationslavon*.*to'root'@'192.16.10.228'由'root'标识;˃grantrepplicationslavon*.*to'root'@'192.16.10.231'由'root'标识;˃冲洗特权;3.另一个MySQL守护程序已准备好使用samunixsocket运行。原因是多个MySQL进程使用同一个套接字。第二种方法是直接重命名mysql.sock文件。然后可以启动mysql。

1. Slave_IO_Running: No

mysql> show slave statusG
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 192.16.10.21
                  Master_User: cahms
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 20398
               Relay_Log_File: mysqld-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: No
            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: 20398
              Relay_Log_Space: 106
              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: 1593
                Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have 
                               equal MySQL server ids; these ids must be different for replication to 
                               work (or the --replicate-same-server-id option must be used on slave but 
                               this does not always make sense; please check the manual before using
                               it).
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

(1) master and slave have equal MySQL server ids
【解决的方法】
改动/etc/my.cnf 下的server-id的值。确保master和slave的server-id不一样就可以;

(2) Error reading packet from server:

Access denied; you need the REPLICATION SLAVE privilege for this operation ( server_errno=1227)

【解决的方法】主服务器给的复制权限不够。又一次赋予权限。

> grant replication slave on *.* to 'uname'@'对端ip' identified by 'password'。
> flush privileges。
== e.g ==
> grant replication slave on *.* to 'root'@'192.16.10.21'   
  identified by 'root';
> grant replication slave on *.* to 'root'@'192.16.10.23' 
  identified by 'root';

2. Slave_IO_State:

Waiting to reconnect after a failed master event read
mysql> show slave statusG
*************************** 1. row ***************************
               Slave_IO_State: Waiting to reconnect after a failed master event read
                  Master_Host: 192.16.10.231
                  Master_User: cahms
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000003
          Read_Master_Log_Pos: 106
               Relay_Log_File: mysqld-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000003
             Slave_IO_Running: No
            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: 106
              Relay_Log_Space: 106
              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: 0
               Last_SQL_Error:
1 row in set (0.00 sec)

【解决的方法】


> grant replication slave on *.* to 'root'@'192.16.10.228'
  identified by 'root';

> grant replication slave on *.* to 'root'@'192.16.10.231'   
  identified by 'root';

> flush privileges;

3.Another MySQL daemon already running with the same unix socket.

原因多个Mysql进程使用了同一个socket。 两个方法解决:

第一个是马上关机 使用命令 shutdown -h now 关机,关机后在启动。进程就停止了。

第二个直接把mysql.sock文件改名就可以。也能够删除,推荐改名。


然后就能够启动mysql了。

以下是国外原文

To prevent the problem from occurring, you must perform a graceful
shutdown of the server from the command line rather than powering off
the server.

# shutdown -h now

This will stop the running services before powering down the machine.
Based on Centos, an additional method for getting it back up again when you run into this problem is to move mysql.sock:

# mv /var/lib/mysql/mysql.sock /var/lib/mysql/mysql.sock.bak

# service mysqld start

Restarting the service creates a new entry called mqsql.sock


热门推荐


免责声明:文章转载自《MySQL双主热备问题处理》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇ODBC连接EXCEL的一些问题微服务架构 SpringBoot(二)下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

更改Ubuntu gcc、g++默认编译器版本

转一篇文章: 升级Ubuntu到11.10,但在编译Android的时候出错了。这个Android在升级系统之前编译是没有错误的,对比发现升级到Ubuntu 11.10后gcc、g++的版本都是4.6.1。而升级之前的版本是4.4.6。我想多半原因就在这里了。要想解决问题需要更改Ubuntu gcc、g++默认编译器版本。google一把发现有两种方法可以...

MySQL设置主键字段自增从0001开始

DROP TABLE IF EXISTS `fi_kj_log_test`; CREATE TABLE `fi_kj_log_test` ( `id` bigint(4) unsigned zerofill NOT NULL AUTO_INCREMENT, `ts` bigint(20) DEFAULT NULL, `success` tiny...

php error_log记录日志的使用方法和配置 (日志目录一定要手动创建)

对于PHP开发者来 说,一旦某个产品投入使用,应该立即将 display_errors选项关闭,以免因为这些错误所透露的路径、数据库连接、数据表等信息而遭到黑客攻击。但是,任何一个产品在投入使用后,都难 免会有错误出现,那么如何记录一些对开发者有用的错误报告呢?我们可以在单独的文本文件中将错误报告作为日志记录。错误日志的记录,可以帮助开发人员或者 管理人...

如何使用Xmanager及VNC登录远程桌面

如何调用远程桌面,比较常见的有两种方式:Xmanager及VNC 正好今天鼓捣了一下,特整理如下: Xmanager Xmanager的调用也有两种方式: 一、直接在Xshell中调用       这时需设置会话属性,如下图所示,需在“隧道”选项上勾选“转发X11连接到(X):”        二、用Xstart登录远程桌面       如图,主机,用户名...

MySQL -- Innodb是如何处理自增列的

对于那些向带有自增列的表中插入行的语句,Innodb提供一种可配置的锁定机制,这种锁定机制可以显著提高SQL语句的可伸缩性和性能。 Innodb中为了使用自增机制,自增列必须是索引的部份,从而可以使用等价查询。典型的做法是将自增列放在表的索引的第一个位置。   Innodb自增锁模式 自增锁模式是在启动的时候由参数innodb_autoinc_lock_m...

MySQL SQL优化

前言 有人反馈之前几篇文章过于理论缺少实际操作细节,这篇文章就多一些可操作性的内容吧。 注:这篇文章是以 MySQL 为背景,很多内容同时适用于其他关系型数据库,需要有一些索引知识为基础。 优化目标 1.减少 IO 次数 IO永远是数据库最容易瓶颈的地方,这是由数据库的职责所决定的,大部分数据库操作中超过90%的时间都是 IO 操作所占用的,减少 IO...