内容正式开始前,我已经在集群中添加了新的节点controller1(IP地址为10.0.0.14)。
安装软件:
# yum install -y mariadb-galera-server xinetd rsync
创建用于健康检查的用户:
# systemctl start mysqld.service
# mysql -e "CREATE USER [email protected] IDENTIFIED BY ‘123456‘;"
# systemctl stop mysqld.service
创建健康检查登录信息文件:
# vi /etc/sysconfig/clustercheck
MYSQL_USERNAME=clustercheck
MYSQL_PASSWORD=123456
MYSQL_HOST=controller1
MYSQL_PORT=3306
创建供HAProxy调用的健康检查服务:
#vi /etc/xinetd.d/galera-monitor
service galera-monitor
{
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
}
此处检查状态的端口为9200。
启动xinetd服务,clustercheck需要这个服务:
# systemctl daemon-reload
# systemctl enable xinetd
# systemctl start xinetd
配置MariaDB和Galera:
# vi /etc/my.cnf.d/galera.cnf
[mysqld]
binlog_format=ROW
default-storage-engine=innodb
innodb_autoinc_lock_mode=2
innodb_locks_unsafe_for_binlog=1
query_cache_size=0
query_cache_type=0
bind-address=controller1
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_name="my_wsrep_cluster"
wsrep_cluster_address="gcomm://controller1,controller2,controller3"
wsrep_slave_threads=1
wsrep_certify_nonPK=1
wsrep_max_ws_rows=131072
wsrep_max_ws_size=1073741824
wsrep_debug=0
wsrep_convert_LOCK_to_trx=0
wsrep_retry_autocommit=1
wsrep_auto_increment_control=1
wsrep_drupal_282555_worka