MYSQL MGR 单写 A new primary切换
在MGR下,当主节点关掉后,在其他节点可以看到哪个节点为是新的主节点
[root@win2 logs]# tail -n 10 alert_3306.log 2020-11-19T12:19:42.561360Z 4 [Note] Plugin group_replication reported: 'Primary had applied all relay logs, disabled conflict detection' 2020-11-19T12:24:57.775327Z 0 [Note] Plugin group_replication reported: 'Members joined the group: win3.inno.com:3306' 2020-11-19T12:24:57.775530Z 0 [Note] Plugin group_replication reported: 'Group membership changed to win2.inno.com:3306, win1.inno.com:3306, win3.inno.com:3306 on view 16057873198811400:7.' 2020-11-19T12:24:57.849202Z 0 [Note] Plugin group_replication reported: 'The member with address win3.inno.com:3306 was declared online within the replication group' 2020-11-19T16:30:21.373404Z 0 [Warning] Plugin group_replication reported: 'Members removed from the group: win1.inno.com:3306' 2020-11-19T16:30:21.373468Z 0 [Note] Plugin group_replication reported: 'Primary server with address win1.inno.com:3306 left the group. Electing new Primary.' 2020-11-19T16:30:21.374001Z 0 [Note] Plugin group_replication reported: 'A new primary with address win2.inno.com:3306 was elected, enabling conflict detection until the new primary applies all relay logs.' 2020-11-19T16:30:21.374676Z 20 [Note] Plugin group_replication reported: 'This server is working as primary member.' 2020-11-19T16:30:21.374789Z 0 [Note] Plugin group_replication reported: 'Group membership changed to win2.inno.com:3306, win3.inno.com:3306 on view 16057873198811400:8.' 2020-11-19T16:37:32.807516Z 4 [Note] Plugin group_replication reported: 'Primary had applied all relay logs, disabled conflict detection'
在节点2 上查看
Server version: 5.7.25-log MySQL Community Server (GPL) Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show variables like 'group%'; +----------------------------------------------------+--------------------------------------+ | Variable_name | Value | +----------------------------------------------------+--------------------------------------+ | group_concat_max_len | 1024 | | group_replication_allow_local_disjoint_gtids_join | OFF | | group_replication_allow_local_lower_version_join | OFF | | group_replication_auto_increment_increment | 7 | | group_replication_bootstrap_group | OFF | | group_replication_components_stop_timeout | 31536000 | | group_replication_compression_threshold | 1000000 | | group_replication_enforce_update_everywhere_checks | OFF | | group_replication_exit_state_action | READ_ONLY | | group_replication_flow_control_applier_threshold | 25000 | | group_replication_flow_control_certifier_threshold | 25000 | | group_replication_flow_control_mode | QUOTA | | group_replication_force_members | | | group_replication_group_name | b665d136-2a50-11eb-ac56-0050563156dd | | group_replication_group_seeds | win1:33061,win2:33061,win3:33061 | | group_replication_gtid_assignment_block_size | 1000000 | | group_replication_ip_whitelist | AUTOMATIC | | group_replication_local_address | win2:33061 | | group_replication_member_weight | 50 | | group_replication_poll_spin_loops | 0 | | group_replication_recovery_complete_at | TRANSACTIONS_APPLIED | | group_replication_recovery_reconnect_interval | 60 | | group_replication_recovery_retry_count | 10 | | group_replication_recovery_ssl_ca | | | group_replication_recovery_ssl_capath | | | group_replication_recovery_ssl_cert | | | group_replication_recovery_ssl_cipher | | | group_replication_recovery_ssl_crl | | | group_replication_recovery_ssl_crlpath | | | group_replication_recovery_ssl_key | | | group_replication_recovery_ssl_verify_server_cert | OFF | | group_replication_recovery_use_ssl | OFF | | group_replication_single_primary_mode | ON | | group_replication_ssl_mode | DISABLED | | group_replication_start_on_boot | OFF | | group_replication_transaction_size_limit | 0 | | group_replication_unreachable_majority_timeout | 0 | +----------------------------------------------------+--------------------------------------+ 37 rows in set (0.00 sec) mysql> insert into kevin.haha values(3,"yangyang"),(4,"shikui"); Query OK, 2 rows affected (0.00 sec) Records: 2 Duplicates: 0 Warnings: 0 mysql> select * from kevin.haha; +----+-----------+ | id | name | +----+-----------+ | 1 | wangshibo | | 2 | guohuihui | | 3 | yangyang | | 4 | shikui | +----+-----------+ 4 rows in set (0.00 sec)
在节点3上可以看到更新
mysql> show variables like 'group%'; +----------------------------------------------------+--------------------------------------+ | Variable_name | Value | +----------------------------------------------------+--------------------------------------+ | group_concat_max_len | 1024 | | group_replication_allow_local_disjoint_gtids_join | OFF | | group_replication_allow_local_lower_version_join | OFF | | group_replication_auto_increment_increment | 7 | | group_replication_bootstrap_group | OFF | | group_replication_components_stop_timeout | 31536000 | | group_replication_compression_threshold | 1000000 | | group_replication_enforce_update_everywhere_checks | OFF | | group_replication_exit_state_action | READ_ONLY | | group_replication_flow_control_applier_threshold | 25000 | | group_replication_flow_control_certifier_threshold | 25000 | | group_replication_flow_control_mode | QUOTA | | group_replication_force_members | | | group_replication_group_name | b665d136-2a50-11eb-ac56-0050563156dd | | group_replication_group_seeds | win1:33061,win2:33061,win3:33061 | | group_replication_gtid_assignment_block_size | 1000000 | | group_replication_ip_whitelist | AUTOMATIC | | group_replication_local_address | win3:33061 | | group_replication_member_weight | 50 | | group_replication_poll_spin_loops | 0 | | group_replication_recovery_complete_at | TRANSACTIONS_APPLIED | | group_replication_recovery_reconnect_interval | 60 | | group_replication_recovery_retry_count | 10 | | group_replication_recovery_ssl_ca | | | group_replication_recovery_ssl_capath | | | group_replication_recovery_ssl_cert | | | group_replication_recovery_ssl_cipher | | | group_replication_recovery_ssl_crl | | | group_replication_recovery_ssl_crlpath | | | group_replication_recovery_ssl_key | | | group_replication_recovery_ssl_verify_server_cert | OFF | | group_replication_recovery_use_ssl | OFF | | group_replication_single_primary_mode | ON | | group_replication_ssl_mode | DISABLED | | group_replication_start_on_boot | OFF | | group_replication_transaction_size_limit | 0 | | group_replication_unreachable_majority_timeout | 0 | +----------------------------------------------------+--------------------------------------+ 37 rows in set (0.00 sec) mysql> select * from kevin.haha; +----+-----------+ | id | name | +----+-----------+ | 1 | wangshibo | | 2 | guohuihui | | 3 | yangyang | | 4 | shikui | +----+-----------+ 4 rows in set (0.00 sec)
查看主节点
mysql> SHOW STATUS LIKE 'group_replication_primary_member'; +----------------------------------+--------------------------------------+ | Variable_name | Value | +----------------------------------+--------------------------------------+ | group_replication_primary_member | 094939ff-2a61-11eb-b0fb-00505625c159 | +----------------------------------+--------------------------------------+ 1 row in set (0.01 sec) mysql> SELECT * FROM performance_schema.replication_group_members; +---------------------------+--------------------------------------+---------------+-------------+--------------+ | CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | +---------------------------+--------------------------------------+---------------+-------------+--------------+ | group_replication_applier | 094939ff-2a61-11eb-b0fb-00505625c159 | win2.inno.com | 3306 | ONLINE | | group_replication_applier | 18075979-2a5e-11eb-953b-0050563156dd | win1.inno.com | 3306 | ONLINE | | group_replication_applier | ed0a0135-2a61-11eb-af60-005056353553 | win3.inno.com | 3306 | ONLINE | +---------------------------+--------------------------------------+---------------+-------------+--------------+ 3 rows in set (0.00 sec)
每天进步一点点,多思考,多总结
版权声明:本文为CNblog博主「zaituzhong」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。