我要评分
获取效率
正确性
完整性
易理解

Verifying HA

  1. Simulate a scenario where a primary node is stopped and test the routing of read and write requests.
    1. Log in to secondary database 1.
      /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysqls.sock
    2. Stop the database.
      shutdown;
    3. Log in to the primary database and view the group member information.
      /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysqlm.sock
      select * from performance_schema.replication_group_members;

    4. Execute the read request script.
      sh /home/read_6447.sh

      The 127.0.0.1:3307 database service is disabled. Read requests are sent to the other two primary nodes in polling mode as expected.

    5. Execute the write request script.
      1. Open the file.
        vim /home/write_6447.sh
      2. Replace the file content with the following:
        1
        2
        3
        4
        5
        #!/bin/bash
        for i in {2001..3000}
        do
        /usr/local/mysql/bin/mysql -uroot -p123456 -P6447 -h127.0.0.1 -Dsysbench -e "insert into test1(id,report_serverid) values($i,@@server_id)"
        done
        
      3. Press Esc, type :wq!, and press Enter to save the file and exit.
      4. Execute the write request script.
        1
        sh /home/write_6447.sh
        
      5. Confirm the test data.
        1
        /usr/local/mysql/bin/mysql -uroot -p123456 -P6447 -h127.0.0.1 -Dsysbench -e "select * from test1"
        

        The 127.0.0.1:3307 database service is disabled. Write requests are sent to the other two primary nodes in polling mode as expected.

  2. Simulate a scenario where two primary nodes are stopped and test the routing of read and write requests.
    1. Log in to secondary database 2.
      /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysqls2.sock
    2. Stop the database.
      shutdown;
    3. Log in to the primary database and view the group member information.
      /usr/local/mysql/bin/mysql -uroot -p123456 -S /data/mysql/run/mysqlm.sock
      select * from performance_schema.replication_group_members;

    4. Execute the read request script.
      sh /home/read_6447.sh

      The 127.0.0.1:3307 and 127.0.0.1:3308 database services are disabled. Read requests are sent to the remaining primary node as expected.

    5. Execute the write request script.
      1. Open the file.
        vim /home/write_6447.sh
      2. Replace the file content with the following:
        1
        2
        3
        4
        5
        #!/bin/bash
        for i in {3001..4000}
        do
        /usr/local/mysql/bin/mysql -uroot -p123456 -P6447 -h127.0.0.1 -Dsysbench -e "insert into test1(id,report_serverid) values($i,@@server_id)"
        done
        
      3. Press Esc, type :wq!, and press Enter to save the file and exit.
      4. Execute the write request script.
        1
        sh /home/write_6447.sh
        
      5. Confirm the test data.
        1
        /usr/local/mysql/bin/mysql -uroot -p123456 -P6447 -h127.0.0.1 -Dsysbench -e "select * from test1"
        

        The 127.0.0.1:3307 and 127.0.0.1:3308 database services are disabled. Write requests are sent to the remaining primary node as expected.