2

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_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 1
wsrep_cluster_size 1
wsrep_cluster_state_uuid ab5f4c8d-c10a-11e6-9b50-4e319db8c0ac
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 1.901e-06/4.4636e-06/1.1001e-05/3.47701e-06/5
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 ab5dcc24-c10a-11e6-b67a-bbb4829e3b24
wsrep_incoming_addresses 192.168.65.128: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 0
wsrep_local_recv_queue 0
wsrep_local_recv_queue_avg 0.500000
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 ab5f4c8d-c10a-11e6-9b50-4e319db8c0ac
wsrep_protocol_version 7
wsrep_provider_name Galera
wsrep_provider_vendor Codership Oy <info@codership.com>
wsrep_provider_version 25.3.18(r3632)
wsrep_ready ON
wsrep_received 2
wsrep_received_bytes 144
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)

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
18 声望3 粉丝