当前位置:Gxlcms > 数据库问题 > 部署mariadb高可用

部署mariadb高可用

时间:2021-07-01 10:21:17 帮助过:19人阅读

=ON wsrep_provider=/usr/lib64/galera/libgalera_smm.so wsrep_cluster_address=gcomm:// binlog_format=row default_storage_engine=InnoDB innodb_autoinc_lock_mode=2 bind-address=0.0.0.0 wsrep_cluster_name="MariaDB_Cluster" wsrep_node_address="192.168.1.74" wsrep_sst_method=rsyn

 

(3)配置备份节点node-2

#vi /etc/my.cnf.d/server.cnf

[galera]
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so 

wsrep_cluster_address="gcomm://192.168.1.74,192.168.1.75" 

binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
bind-address=0.0.0.0

wsrep_cluster_name="MariaDB_Cluster"
wsrep_node_address="192.168.1.75"
wsrep_sst_method=rsync

 启动服务

node-1节点:

#/bin/galera_new_cluster

node-2节点:

#systemctl start mariadb

测试集群状态

(1)查询集群状态

#mysql -u root -p

MariaDB [(none)]> show status like ‘wsrep_%‘;

技术分享图片

+------------------------------+---------------------------------------+
| Variable_name                | Value                                 |
+------------------------------+---------------------------------------+
| wsrep_apply_oooe             | 0.000000                              |
| wsrep_apply_oool             | 0.000000                              |
| wsrep_apply_window           | 0.000000                              |
| wsrep_causal_reads           | 0                                     |
| wsrep_cert_deps_distance     | 0.000000                              |
| wsrep_cert_index_size        | 0                                     |
| wsrep_cert_interval          | 0.000000                              |
| wsrep_cluster_conf_id        | 2                                     |
| wsrep_cluster_size           | 2                                     |
| wsrep_cluster_state_uuid     | 841486a3-b56a-11e8-a451-d7d8f2309253  |
| wsrep_cluster_status         | Primary                               |
| wsrep_commit_oooe            | 0.000000                              |
| wsrep_commit_oool            | 0.000000                              |
| wsrep_commit_window          | 0.000000                              |
| wsrep_connected              | ON                                    |
| 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_flow_control_paused    | 0.000000                              |
| wsrep_flow_control_paused_ns | 0                                     |
| wsrep_flow_control_recv      | 0                                     |
| wsrep_flow_control_sent      | 0                                     |
| wsrep_gcomm_uuid             | 8412f980-b56a-11e8-bb08-4fd6339a7674  |
| wsrep_incoming_addresses     | 192.168.100.11:3306,192.168.1.74:3306 |
| wsrep_last_committed         | 0                                     |
| wsrep_local_bf_aborts        | 0                                     |
| wsrep_local_cached_downto    | 18446744073709551615                  |
| wsrep_local_cert_failures    | 0                                     |
| wsrep_local_commits          | 0                                     |
| wsrep_local_index            | 1                                     |
| wsrep_local_recv_queue       | 0                                     |
| wsrep_local_recv_queue_avg   | 0.166667                              |
| wsrep_local_recv_queue_max   | 2                                     |
| wsrep_local_recv_queue_min   | 0                                     |
| wsrep_local_replays          | 0                                     |
| wsrep_local_send_queue       | 0                                     |
| wsrep_local_send_queue_avg   | 0.000000                              |
| wsrep_local_send_queue_max   | 1                                     |
| wsrep_local_send_queue_min   | 0                                     |
| wsrep_local_state            | 4                                     |
| wsrep_local_state_comment    | Synced                                |
| wsrep_local_state_uuid       | 841486a3-b56a-11e8-a451-d7d8f2309253  |
| wsrep_protocol_version       | 7                                     |
| wsrep_provider_name          | Galera                                |
| wsrep_provider_vendor        | Codership Oy <info@codership.com>     |
| wsrep_provider_version       | 25.3.22(r3764)                        |
| wsrep_ready                  | ON                                    |
| wsrep_received               | 6                                     |
| wsrep_received_bytes         | 414                                   |
| wsrep_repl_data_bytes        | 0                                     |
| wsrep_repl_keys              | 0                                     |
| wsrep_repl_keys_bytes        | 0                                     |
| wsrep_repl_other_bytes       | 0                                     |
| wsrep_replicated             | 0                                     |
| wsrep_replicated_bytes       | 0                                     |
| wsrep_thread_count           | 2                                     |
+------------------------------+---------------------------------------+
58 rows in set (0.00 sec)

 

如果 "wsrep_local_state_comment" is "Synced" 则表明集群创建成功

(3)数据同步

在node-1上新建数据库galera_test

MariaDB [(none)]> create database galera_test;

MariaDB [(none)]> show databases;

技术分享图片

在node-2上查询

MariaDB [(none)]> show databases;

技术分享图片

 

部署mariadb高可用

标签:strong   create   auto   inter   local   host   smm   ddr   自动   

人气教程排行