Maxscale为什么不通过故障转移将主服务器中的从服务器传递出去?

问题描述

我刚刚设置了MariaDB Eslace和主服务器。我想使用故障转移功能,但是当我停止mariadb主服务时,MaxScale识别出它的停止并告诉我它将把从服务器切换为主服务器...但是从服务器仍处于从服务器状态。

maxscale.cnf:

cat maxscale.cnf


[maxscale]
threads=auto
log_augmentation = 1
ms_timestamp = 1
log_info= 1
log_debug= 1
log_augmentation=1

[db1_master]
type=server
address=10.126.26.205
port=3306
protocol=MariaDBBackend

[db2_slave]
type=server
address=10.126.26.242
port=3306
protocol=MariaDBBackend

[MariaDB-Monitor]
type=monitor
module=mariadbmon
servers=db1_master,db2_slave
user=maxscaleuser
passwd=XXXXXXX
monitor_interval=1000
auto_rejoin=true
auto_failover=1
failover_timeout=5
failcount=2


[Read-Only-Service]
type=service
router=readconnroute
servers=db1_master,db2_slave
user=maxscaleuser
passwd=XXXXXXX
router_options=master

[Read-Write-Service]
type=service
router=readconnroute
servers=db1_master,db2_slave
user=maxscaleuser
passwd=XXXXXX
router_options=master

[MaxAdmin-Service]
type=service
router=cli

[Read-Only-Listener]
type=listener
service=Read-Only-Service
protocol=MariaDBClient
port=4008

[Read-Write-Listener]
type=listener
service=Read-Write-Service
protocol=MariaDBClient
port=4006

[MaxAdmin-Listener]
type=listener
service=MaxAdmin-Service
protocol=maxscaled
socket=default

maxadmin列表服务

--------------------------+-------------------+--------+----------------+-------------------
Service Name              | Router Module     | #Users | Total Sessions | Backend databases
--------------------------+-------------------+--------+----------------+-------------------
Read-Only-Service         | readconnroute     |      1 |              1 | db1_master,db2_slave
Read-Write-Service        | readconnroute     |      1 |              4 | db1_master,db2_slave
MaxAdmin-Service          | cli               |      2 |              4 |
--------------------------+-------------------+--------+----------------+-------------------

Master MariaDB:

MariaDB [(无)]>显示主状态;

+------------------+----------+--------------+------------------+
| File             | Position | binlog_Do_DB | binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| MysqL-bin.000012 |      342 | masterdb     |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.000 sec)

解决方法

剩下的是因为我的邮件太长而被视为垃圾邮件:


从状态:

MariaDB [(none)]> SHOW ALL SLAVES STATUS \G;
*************************** 1. row ***************************
               Connection_name: 1009
               Slave_SQL_State: Slave has read all relay log; waiting for the slave I/O thread to update it
                Slave_IO_State: Waiting for master to send event
                   Master_Host: 10.126.26.205
                   Master_User: myslave
                   Master_Port: 3306
                 Connect_Retry: 60
               Master_Log_File: mysql-bin.000012
           Read_Master_Log_Pos: 342
                Relay_Log_File: mysqld-relay-bin-1009.000005
                 Relay_Log_Pos: 641
         Relay_Master_Log_File: mysql-bin.000012
              Slave_IO_Running: Yes
             Slave_SQL_Running: Yes
               Replicate_Do_DB: masterdb
           Replicate_Ignore_DB: mysql
            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: 342
               Relay_Log_Space: 1341
               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: 1009
                Master_SSL_Crl:
            Master_SSL_Crlpath:
                    Using_Gtid: Slave_Pos
                   Gtid_IO_Pos: 1-1009-21247
       Replicate_Do_Domain_Ids:
   Replicate_Ignore_Domain_Ids:
                 Parallel_Mode: conservative
                     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
              Slave_DDL_Groups: 2
Slave_Non_Transactional_Groups: 0
    Slave_Transactional_Groups: 0
          Retried_transactions: 0
            Max_relay_log_size: 20971520
          Executed_log_entries: 29
     Slave_received_heartbeats: 241
        Slave_heartbeat_period: 30.000
                Gtid_Slave_Pos: 1-1009-21247
1 row in set (0.000 sec)

ERROR: No query specified

maxctrl列表服务器

┌────────────┬───────────────┬──────┬─────────────┬─────────────────┬──────────────┐
│ Server     │ Address       │ Port │ Connections │ State           │ GTID         │
├────────────┼───────────────┼──────┼─────────────┼─────────────────┼──────────────┤
│ db1_master │ 10.126.26.205 │ 3306 │ 1           │ Master,Running │ 1-1009-21247 │
├────────────┼───────────────┼──────┼─────────────┼─────────────────┼──────────────┤
│ db2_slave  │ 10.126.26.242 │ 3306 │ 0           │ Slave,Running  │ 1-1009-21247 │
└────────────┴───────────────┴──────┴─────────────┴─────────────────┴──────────────┘

I decide to stop the mariadb service on the master server :

service mariadb stop


maxctrl list servers

┌────────────┬───────────────┬──────┬─────────────┬────────────────┬──────────────┐
│ Server     │ Address       │ Port │ Connections │ State          │ GTID         │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db1_master │ 10.126.26.205 │ 3306 │ 0           │ Down           │ 1-1009-21247 │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db2_slave  │ 10.126.26.242 │ 3306 │ 0           │ Slave,Running │ 1-1009-21247 │
└────────────┴───────────────┴──────┴─────────────┴────────────────┴──────────────┘

Maxscale可以识别主服务器的关闭

/var/log/maxscale/maxscale.log:

2020-08-14 11:48:12.725   info   : (auth): Accept authentication from 'admin',using password. Request: /v1/servers
2020-08-14 11:48:12.739   info   : (auth): Accept authentication from 'admin',using password. Request: /v1/monitors/MariaDB-Monitor
2020-08-14 11:53:47.104   info   : (session_free): Stopped Read-Write-Service client session [9]
2020-08-14 11:53:47.480   error  : (mon_log_connect_error): Monitor was unable to connect to server [10.126.26.205]:3306 : "Can't connect to MySQL server on '10.126.26.205' (115)"
**2020-08-14 11:53:47.481   notice : [mariadbmon] (monitorMain): Server [10.126.26.205]:3306 lost the master status.**
**2020-08-14 11:53:47.505   notice : (mon_log_state_change): Server changed state: db1_master[10.126.26.205:3306]: master_down. [Master,Running] -> [Down]**
**2020-08-14 11:53:47.505   warning: [mariadbmon] (mon_process_failover): Master has failed. If master status does not change in 1 monitor passes,failover begins.**
2020-08-14 11:53:48.512   notice : [mariadbmon] (mon_process_failover): Performing automatic failover to replace failed master 'db1_master'.
2020-08-14 11:53:48.512   error  : (mon_report_query_error): Failed to execute query on server 'db1_master' ([10.126.26.205]:3306): MySQL server has gone away
2020-08-14 11:53:48.514   warning: [mariadbmon] (check_replication_settings): Slave 'db2_slave' has gtid_strict_mode disabled. Enabling this setting is recommended. For more information,see https://mariadb.com/kb/en/library/gtid/#gtid_strict_mode
**2020-08-14 11:53:48.514   notice : [mariadbmon] (promote_new_master): Promoting server 'db2_slave' to master.
2020-08-14 11:53:48.515   notice : [mariadbmon] (redirect_slaves): Redirecting slaves to new master.**
2020-08-14 11:54:10.526   info   : (auth): Accept authentication from 'admin',using password. Request: /v1/servers
2020-08-14 11:54:10.540   info   : (auth): Accept authentication from 'admin',using password. Request: /v1/monitors/MariaDB-Monitor
maxctrl list servers

┌────────────┬───────────────┬──────┬─────────────┬────────────────┬──────────────┐
│ Server     │ Address       │ Port │ Connections │ State          │ GTID         │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db1_master │ 10.126.26.205 │ 3306 │ 0           │ Down           │ 1-1009-21247 │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db2_slave  │ 10.126.26.242 │ 3306 │ 0           │ Slave,Running │ 1-1009-21247 │
└────────────┴───────────────┴──────┴─────────────┴────────────────┴──────────────┘

root@crm-eu-fr-maxscale-01a:/etc# maxctrl call command mariadbmon failover MariaDB-Monitor
OK

root@crm-eu-fr-maxscale-01a:/etc# maxctrl list servers
┌────────────┬───────────────┬──────┬─────────────┬────────────────┬──────────────┐
│ Server     │ Address       │ Port │ Connections │ State          │ GTID         │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db1_master │ 10.126.26.205 │ 3306 │ 0           │ Down           │              │
├────────────┼───────────────┼──────┼─────────────┼────────────────┼──────────────┤
│ db2_slave  │ 10.126.26.242 │ 3306 │ 0           │ Slave,Running │ 1-1009-21247 │
└────────────┴───────────────┴──────┴─────────────┴────────────────┴──────────────┘


MaxScale> show servers
Server 0x55f4a0e7d170 (db1_master)
        Server:                              10.126.26.205
        Status:                              Down
        Protocol:                            MariaDBBackend
        Port:                                3306
        Server Version:                      10.4.11-MariaDB-1:10.4.11+maria~bionic-log
        Node Id:                             1009
        Master Id:                           -1
        Last event:                          master_down
        Triggered at:                        Fri,14 Aug 2020 11:53:36 GMT
        Slave Ids:                           2009
        Repl Depth:                          0
        Number of connections:               2
        Current no. of conns:                0
        Current no. of operations:           0
        Number of routed packets:            4
Server 0x55f4a0e7bee0 (db2_slave)
        Server:                              10.126.26.242
        Status:                              Slave,Running
        Protocol:                            MariaDBBackend
        Port:                                3306
        Server Version:                      10.4.11-MariaDB-1:10.4.11+maria~bionic-log
        Node Id:                             2009
        Master Id:                           1009
        Last event:                          new_slave
        Triggered at:                        Fri,14 Aug 2020 10:04:58 GMT
        Slave Ids:
        Repl Depth:                          1
        Number of connections:               0
        Current no. of conns:                0
        Current no. of operations:           0
        Number of routed packets:            0

但是,当我检查时,从属服务器不会成为主服务器...我没有在日志中找到更多信息...:/

您是否知道问题可能出在哪里?

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...