Mysql Slave群切換Master (=)

aaqwsh發表於2010-11-28
續上。
 
 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部落格 ” ,連結:http://blog.itpub.net/758322/viewspace-680473/,如需轉載,請註明出處,否則將追究法律責任。

相關文章