CentOS7部署(Mysql) MariaDB Galera Cluster 10.1记录

1、环境说明

vmwareworkstation 12
centos 7.2 64bit mini install
mariadb 10.1

已关闭selinux firewalld

2、yum安装mariadb 10.1

配置yum源

# MariaDB 10.1 CentOS repository list - created 2016-12-13 01:20 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

安装mariadb,大约100M,centos mini 依赖包perl rsysnc ..

yum install mariadb-server mariadb-client

3、初始化数据库

只需要在第一台服务器配置即可。

#systemctl start mariadb

#mysql_secure_installation 

设置mysql root密码,其他回答yes即可。

4、关闭数据库,修改/etc/my.cnf.d/server.cnf

systemctl stop mariadb
vi /etc/my.cnf.d/server.cnf

[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.65.128,192.168.65.129"
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2

注意wsrep_cluster_address配置需要引号.

5、启动第一节点mariadb

第一个节点启动与其他不同,需要使用_WSREP_START_POSITION。使用galera提供的脚本。

#galera_new_cluster

检查wsrep状态

mysql> MariaDB [(none)]> show status like “wsrep_%”;

Variable_nameValue
wsrep_apply_oooe0.000000
wsrep_apply_oool0.000000
wsrep_apply_window0.000000
wsrep_causal_reads0
wsrep_cert_deps_distance0.000000
wsrep_cert_index_size0
wsrep_cert_interval0.000000
wsrep_cluster_conf_id1
wsrep_cluster_size1
wsrep_cluster_state_uuidab5f4c8d-c10a-11e6-9b50-4e319db8c0ac
wsrep_cluster_statusPrimary
wsrep_commit_oooe0.000000
wsrep_commit_oool0.000000
wsrep_commit_window0.000000
wsrep_connectedON
wsrep_desync_count0
wsrep_evs_delayed
wsrep_evs_evict_list
wsrep_evs_repl_latency1.901e-06/4.4636e-06/1.1001e-05/3.47701e-06/5
wsrep_evs_stateOPERATIONAL
wsrep_flow_control_paused0.000000
wsrep_flow_control_paused_ns0
wsrep_flow_control_recv0
wsrep_flow_control_sent0
wsrep_gcomm_uuidab5dcc24-c10a-11e6-b67a-bbb4829e3b24
wsrep_incoming_addresses192.168.65.128:3306
wsrep_last_committed0
wsrep_local_bf_aborts0
wsrep_local_cached_downto18446744073709551615
wsrep_local_cert_failures0
wsrep_local_commits0
wsrep_local_index0
wsrep_local_recv_queue0
wsrep_local_recv_queue_avg0.500000
wsrep_local_recv_queue_max2
wsrep_local_recv_queue_min0
wsrep_local_replays0
wsrep_local_send_queue0
wsrep_local_send_queue_avg0.000000
wsrep_local_send_queue_max1
wsrep_local_send_queue_min0
wsrep_local_state4
wsrep_local_state_commentSynced
wsrep_local_state_uuidab5f4c8d-c10a-11e6-9b50-4e319db8c0ac
wsrep_protocol_version7
wsrep_provider_nameGalera
wsrep_provider_vendorCodership Oy <info@codership.com>
wsrep_provider_version25.3.18(r3632)
wsrep_readyON
wsrep_received2
wsrep_received_bytes144
wsrep_repl_data_bytes0
wsrep_repl_keys0
wsrep_repl_keys_bytes0
wsrep_repl_other_bytes0
wsrep_replicated0
wsrep_replicated_bytes0
wsrep_thread_count2

58 rows in set (0.00 sec)

6、其他节点配置

6.1复制gelare配置到节点2的server.cnf文件

6.2启动mariadb

systemctl start mariadb

6.3查看启动情况

# systemctl status mariadb

参考资料:
https://mariadb.com/kb/en/mar…
http://severalnines.com/blog/…

    原文作者:glinuz
    原文地址: https://segmentfault.com/a/1190000007831311
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞