mysql/mariadb数据的galera集群搭建
1 修改添加本地源
cd /etc/yum.repos.d/
vim CentOS-Base.repo
2 添加hosts
vim /etc/hosts
3 修改hostnames
hostnamectl set-hostname 。。。
4 安装 (确保galera与mariadb与别的几个节点一致)
yum install epel-release -y
yum install um-plugin-priorities -y
yum install MariaDB-client.x86_64 mariadb-server.x86_64 galera percona-xtrabackup -y
5 修改galera的配置文件
cd /etc/my.cnf.d/
vim server.cnf
#
# These two groups are read by the client library
# Use it for options that affect all clients, but not the server
#
[client]
# This group is not read by mysql client library,
# If you use the same .cnf file for MySQL and MariaDB,
# use it for MariaDB-only client options
[client-mariadb]
[root@falcon_db my.cnf.d]# cat server.cnf
[server]
# this is only for the mysqld standalone daemon
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 8
max_connections = 800
#
log-bin=mysql-bin
binlog_format=mixed
#server-id = 1
#
# * Galera-related settings
#
[galera]
# Mandatory settings
wsrep_on=ON
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://" #主节点ip
wsrep_cluster_name="wsrep_cluster"
wsrep_node_name=falcon_db #本机hostname
wsrep_node_address= #本机ip
binlog_format=row
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
#
# Allow server to accept connections on all interfaces.
#
#bind-address=0.0.0.0
#
# Optional setting
#wsrep_slave_threads=1
#innodb_flush_log_at_trx_commit=0
# this is only for embedded server
[embedded]
# This group is only read by MariaDB servers, not by MySQL.
# If you use the same .cnf file for MySQL and MariaDB,
# you can put MariaDB-only options here
[mariadb]
log-error=/var/log/mariadb/mariadb.log
pid-file=/var/run/mariadb/mariadb.pid
# This group is only read by MariaDB-10.1 servers.
# If you use the same .cnf file for MariaDB of different versions,
# use this group for options that older servers don't understand
[mariadb-10.1]
mkdir -p /var/log/mariadb/
mkdir -p /var/run/mariadb/
chown -R mysql:mysql /var/run/mariadb
chown -R mysql:mysql /var/log/mariadb
service mysql start --wsrep_cluster_address=gcomm://ip地址 每次启动需要指定主节点
show status like “%wsrep%”; 数据库内查看集群信息
- show status like 'wsrep_local_state_comment';
- show status like 'wsrep_cluster_size';
- 来源
https://zhuanlan.zhihu.com/p/467036685
相关文章