MySQL多主模型Galera Cluster(2)

登入node1的MySQL其实在抬头信息就可以看见
5.5.53-MariaDB-wsrep MariaDB Server, wsrep_25.14.r9949137
这样表示已经安装到了MariaDB-Galera-server了。
但是这并没有什么用,因为更重要的是集群能不能正行运行。

(8)查看集群中关的参数,验证集群是否正常运行:

MariaDB [(none)]>SHOW STATUS LIKE 'wsrep_%'; +------------------------------+-----------------------------------------------------------------------------+ | Variable_name | Value | +------------------------------+-----------------------------------------------------------------------------+ | wsrep_local_state_uuid | 8ae2ecfd-aa14-11e6-9b1e-7f1d6291d077 | | wsrep_protocol_version | 7 | | wsrep_last_committed | 11 | | wsrep_replicated | 0 | | wsrep_replicated_bytes | 0 | | wsrep_repl_keys | 0 | | wsrep_repl_keys_bytes | 0 | | wsrep_repl_data_bytes | 0 | | wsrep_repl_other_bytes | 0 | | wsrep_received | 5 | | wsrep_received_bytes | 996 | | wsrep_local_commits | 0 | | wsrep_local_cert_failures | 0 | | wsrep_local_replays | 0 | | wsrep_local_send_queue | 0 | | wsrep_local_send_queue_max | 1 | | wsrep_local_send_queue_min | 0 | | wsrep_local_send_queue_avg | 0.000000 | | wsrep_local_recv_queue | 0 | | wsrep_local_recv_queue_max | 2 | | wsrep_local_recv_queue_min | 0 | | wsrep_local_recv_queue_avg | 0.200000 | | wsrep_local_cached_downto | 18446744073709551615 | | wsrep_flow_control_paused_ns | 0 | | wsrep_flow_control_paused | 0.000000 | | wsrep_flow_control_sent | 0 | | wsrep_flow_control_recv | 0 | | wsrep_cert_deps_distance | 0.000000 | | wsrep_apply_oooe | 0.000000 | | wsrep_apply_oool | 0.000000 | | wsrep_apply_window | 0.000000 | | wsrep_commit_oooe | 0.000000 | | wsrep_commit_oool | 0.000000 | | wsrep_commit_window | 0.000000 | | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_cert_index_size | 0 | | wsrep_causal_reads | 0 | | wsrep_cert_interval | 0.000000 | | wsrep_incoming_addresses | 192.168.2.201:3306,192.168.2.202:3306,192.168.2.203:3306,192.168.2.204:3306 | | wsrep_desync_count | 0 | | wsrep_evs_delayed | | | wsrep_evs_evict_list | | | wsrep_evs_repl_latency | 0/0/0/0/0 | | wsrep_evs_state | OPERATIONAL | | wsrep_gcomm_uuid | 249832a4-bd6a-11e6-a81b-1bfdbeb7f343 | | wsrep_cluster_conf_id | 4 | | wsrep_cluster_size | 4 | | wsrep_cluster_state_uuid | 8ae2ecfd-aa14-11e6-9b1e-7f1d6291d077 | | wsrep_cluster_status | Primary | | wsrep_connected | ON | | wsrep_local_bf_aborts | 0 | | wsrep_local_index | 0 | | wsrep_provider_name | Galera | | wsrep_provider_vendor | Codership Oy <info@codership.com> | | wsrep_provider_version | 25.3.18(r3632) | | wsrep_ready | ON | | wsrep_thread_count | 2 | +------------------------------+-----------------------------------------------------------------------------+

我们可以看到,四个节点都加入到这个多主模型之中了。
假如节点故障,则不会显示在wsrep_incoming_addresses 之中。
通常初始化节点都是会启动成功的,但是假如其他节点启动失败,wsrep_incoming_addresses 就只会有本机地址。
也就是使用service mysql start --wsrep-new-cluster经常出现的状况。

(9)测试是否正常工作
a.创建数据库并在里面建立一个新表。

MariaDB [(none)]> create database wsrep_test; Query OK, 1 row affected (0.01 sec) MariaDB [(none)]> use wsrep_test; Database changed MariaDB [wsrep_test]> create table wsrep_test (id int auto_increment not null primary key,name varchar(30) not null); MariaDB [wsrep_test]> desc wsrep_test; +-------+-------------+------+-----+---------+----------------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+----------------+ | id | int(11) | NO | PRI | NULL | auto_increment | | name | varchar(30) | NO | | NULL | | +-------+-------------+------+-----+---------+----------------+ 2 rows in set (0.00 sec)

创建的表格的命令,意思是创建一个叫wsrep_test的表,里面有两个字段,一个是id,一个是name。
其中id字段设置为自动增长。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/6cf975cca1e0fe8d5d8cdec704b731b7.html