ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Mysql Slave群切换Master (=)

Mysql Slave群切换Master (=)

原创 Linux操作系统 作者:aaqwsh 时间:2010-11-28 10:56:15 0 删除 编辑
续上。
 
 Mysql Slave群切换Master 后,master转为slave:
注意:原来的slave变为master后,日志已经重置,
MASTER_LOG_FILE='mysql-bin.000019',MASTER_LOG_POS=106不在需要,从头开始应用:
 
 
 
mysql> RESET slave;
Query OK, 0 rows affected (0.00 sec)
mysql> CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.202',
    -> MASTER_USER='rep',
    -> MASTER_PASSWORD='rep',
    -> MASTER_LOG_FILE='mysql-bin.000019',
    -> MASTER_LOG_POS=106;
Query OK, 0 rows affected (0.17 sec)
mysql> start slave;
Query OK, 0 rows affected (0.00 sec)
mysql> show slave status\G
*************************** 1. row ***************************
               Slave_IO_State:
                  Master_Host: 192.168.1.202
                  Master_User: rep
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: mysql-bin.000019
          Read_Master_Log_Pos: 106
               Relay_Log_File: node1-relay-bin.000001
                Relay_Log_Pos: 4
        Relay_Master_Log_File: mysql-bin.000019
             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: 1236
                Last_IO_Error: Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
               Last_SQL_Errno: 0
               Last_SQL_Error:
1 row in set (0.00 sec)
mysql> CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.202',
    -> MASTER_USER='rep',
    -> MASTER_PASSWORD='rep';
ERROR 1198 (HY000): This operation cannot be performed with a running slave; run STOP SLAVE first
mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
mysql> CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.202',
    -> MASTER_USER='rep',
    -> MASTER_PASSWORD='rep';
Query OK, 0 rows affected (0.05 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: 192.168.1.202
                  Master_User: rep
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: node2-bin.000001
          Read_Master_Log_Pos: 400
               Relay_Log_File: node1-relay-bin.000002
                Relay_Log_Pos: 545
        Relay_Master_Log_File: node2-bin.000001
             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: 400
              Relay_Log_Space: 700
              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:
1 row in set (0.00 sec)
mysql> use test;
Database changed
mysql> show tables;
+----------------+
| Tables_in_test |
+----------------+
| aa             |
| t3             |
| testrep        |
+----------------+
3 rows in set (0.01 sec)
mysql> select * from t3;
+------+
| i    |
+------+
|    1 |
|    1 |
|    1 |
|    1 |
|    1 |
|    2 |
|    3 |
|  333 |
|  333 |
|  666 |
|  666 |
+------+
11 rows in set (0.00 sec)
mysql> select * from testrep;          
+------+
| i    |
+------+
|    1 |
|    1 |
|    1 |
|    1 |
|    1 |
|    2 |
|    3 |
|  333 |
|  333 |
|  666 |
|  666 |
|  888 |
+------+
12 rows in set (0.00 sec)
mysql>
 
 

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/758322/viewspace-680473/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2010-11-24

  • 博文量
    132
  • 访问量
    287979