.搭建galera集群
yum install epel-release
yum install centos-release-openstack-stein
1.1 安装mariadb
yum install mariadb mariadb-server python2-PyMySQL -y
yum install mariadb-server-galera mariadb-galera-common galera xinetd rsync -y
1.2 初始化galera集群
3个节点选择其中任何一个节点
systemctl start mariadb.service
mysql_secure_installation
编辑配置文件:
vim /etc/my.cnf.d/openstack.cnf
[mysqld]
binlog_format = ROW
bind-address = 192.168.10.51
default-storage-engine = innodb
innodb_file_per_table = on
max_connections = 4096
collation-server = utf8_general_ci
character-set-server = utf8
[galera]
bind-address = 192.168.10.51
wsrep_provider = /usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address ="gcomm://controller1,controller2,controller3"
wsrep_cluster_name = openstack-cluster-01
wsrep_node_name = controller1
wsrep_node_address = 192.168.10.51
wsrep_on=ON
wsrep_slave_threads=4
wsrep_sst_method=rsync
default_storage_engine=InnoDB
[embedded]
[mariadb]
[mariadb-10.1]
controller1节点:
systemctl stop mariadb.service
/usr/libexec/mysqld --wsrep-new-cluster --user=root &
另外两个节点:
systemctl start mariadb.service
controller1节点:
pkill mysqld
rm -rf /var/lib/mysql/*
systemctl start mariadb.service
查看集群状态
MariaDB [(none)]> show status like "wsrep_cluster_size";
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in set (0.002 sec)
MariaDB [(none)]> SHOW status LIKE 'wsrep_ready';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| wsrep_ready | ON |
+---------------+-------+
1 row in set (0.002 sec)
1.3 设置心跳检测
wget https://raw.githubusercontent.com/olafz/percona-clustercheck/master/clustercheck
chmod +x clustercheck
mv clustercheck /usr/bin/
MariaDB [(none)]> GRANT PROCESS ON . TO 'clustercheckuser'@'localhost' IDENTIFIED BY 'clustercheckpassword!';
Query OK, 0 rows affected (0.006 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.004 sec)
[root@controller01 ~]# touch /etc/xinetd.d/mysqlchk
[root@controller01 ~]# vim /etc/xinetd.d/mysqlchk
default: on
description: mysqlchk
service mysqlchk
{
port = 9200
disable = no
socket_type = stream
protocol = tcp
wait = no
user = root
group = root
groups = yes
server = /usr/bin/clustercheck
type = UNLISTED
per_source = UNLIMITED
log_on_success =
log_on_failure = HOST
flags = REUSE
}
修改/etc/services,变更tcp9200端口用途,以controller01节点为例
[root@controller01 ~]# vim /etc/services
wap-wsp 9200/tcp # WAP connectionless session service
mysqlchk 9200/tcp # mysqlchk
启动xinetd服务,以controller01节点为例
[root@controller01 ~]# systemctl daemon-reload
[root@controller01 ~]# systemctl enable xinetd
[root@controller01 ~]# systemctl start xinetd
来源:https://www.cnblogs.com/shiyw/p/12386353.html