CentOS 7 Galera Cluster installation guide

Recently, the original data of Hive needs to use mysql, so Galera Cluster is installed again. Although it has been installed many times, there are still some ambiguities. So roughly record it and share it.

Galera Cluster must be installed on at least 3 servers, as an all-master no-delay cluster, the odd number of servers is to prevent split brain.

The first documents to be prepared are as follows

Before installation, we have to install some prepared libraries:

yum install libaio gcc gcc-c++ boost-devel scons check-devel openssl-devel openssh-clients

perl-DBD-MySQL perl-Time-HiRes perl-Digest nc rsync lsof galera autoconf That's all, I don't rule out omissions, so installing galera cluster is very troublesome.

Remove the mysql library that comes with CentOS 7 before installation. This blog has been written before

yum remove mariadb-libs-5.5.56-2.el7.x86_64

Then start the installation

rpm -ivh add file name

Such as rpm -ivh mysql-wsrep-libs-compat-5.6-5.6.36-25.20.el6.x86_64.rpm

All in the picture should be installed, the installation order except mysql-wsrep-server-5.6-5.6.36-25.20.el6.x86_64.rpm and mysql-wsrep-5.6-5.6.36-25.20.el6.x86_64.rpm and the last installation Besides, the others can be in any order.

If there is an error during the installation process, it means that the library is not installed, you can use --force to force the installation.

After the installation is complete, perform the following operations

  1. mkdir -p /opt/dbdata/mysql_3306
  2. chown -R mysql:mysql /opt/dbdata/mysql_3306
  3. chmod -R 755 /opt/dbdata/mysql_3306
  4. mysql_install_db --user=mysql --datadir=/opt/dbdata/mysql_3306

It is recommended to put dbdata/mysql_3306 in your relatively large external disk, not the system disk. In other words, the /opt directory is optional. You can use df -h to view.

Write my.cnf as follows

[ client]
port = 3306
socket = /mnt/dbdata/mysql_3306/mysql.sock
[ mysqld_multi]
mysqld = /usr/bin/mysqld_safe
mysqladmin = /usr/bin/mysqladmin
log = /var/log/mysqld_multi.err
[ mysqldump]
quick
max_allowed_packet = 16M

[ mysql]
no-auto-rehash
[ myisamchk]
key_buffer_size = 20M
sort_buffer_size = 20M
read_buffer = 2M
write_buffer = 2M
[ mysqlhotcopy]
interactive-timeout
[ mysqld]
port = 3306
socket = /mnt/dbdata/mysql_3306/mysql.sock
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
log-bin-trust-function-creators = 1
expire_logs_days = 1
max_connections = 600
skip-external-locking
skip-name-resolve
datadir=/mnt/dbdata/mysql_3306
character_set_server = utf8
log-bin = mysql-bin
max_allowed_packet=64M

Mandatory Settings

server-id= 44
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2

Optional mysqld Settings

datadir=/path/to/datadir

innodb_buffer_pool_size=28G

innodb_log_file_size=100M

innodb_file_per_table=1

innodb_flush_log_at_trx_commit=0

Basic wsrep Provider Settings

wsrep_provider=/usr/lib64/galera/libgalera_smm.so

wsrep_provider_options="gcache.szie=32m;gcache.page_size=32m;"

##############################################

if this is the node started firstly,use this option

wsrep_cluster_address=gcomm://

nor,use this option

wsrep_cluster_address=gcomm://IP1,IP2,IP3
##############################################
wsrep_cluster_name='galera_cluster'
wsrep_node_address='IP1'
wsrep_node_name='node1'
wsrep_sst_method=xtrabackup
wsrep_sst_auth=root: password

Optional wsrep Provider Settings

wsrep_node_incoming_address='192.168.1.158'

wsrep_sst_donor='demo_node1'

wsrep_slave_threads=16

###############################################################################

Start node1 --wsrep-new-cluster

Where the three servers are different

server-id should be set to a different number, generally set to the last number of the IP address

Set wsrep_node_address to different IP

Set wsrep_node_name to a different node name

The wsrep_sst_method must be set to rsync when connecting to the cluster for the first time. If you use xtrabackup, the first time you connect to the cluster, you will not be able to connect. After the first three servers are successfully connected, close all mysql services and change them all. Go back to xtrabackup, then you can connect successfully.

Remember to put it in the /etc directory after editing

Before starting the first server, comment out wsrep_cluster_address=gcomm://IP1,IP2,IP3, and uncomment wsrep_cluster_address=gcomm://.

Start the first server service mysql start

Use mysql to enter directly, no username or password is required.

GRANT ALL ON . TO'root'@'%' IDENTIFIED BY'password';'%' means that IP access is not restricted. If you want to restrict IP access, you can set the IP address segment, such as GRANT ALL ON * .* TO'root'@'192.168.%' IDENTIFIED BY'Password';

use mysql

update user set password=PASSWORD('password') where user='root';

flush privileges;

exit

Service mysql stop

Re-edit my.cnf vim /etc/my.cnf

Comment out wsrep_cluster_address=gcomm://, uncomment wsrep_cluster_address=gcomm://IP1,IP2,IP3

Start service mysql start --wsrep_cluster_address=gcomm:// again

Then start the second and third servers in succession service mysql start

At this time, all three servers can start normally and connect successfully.

Enter any mysql to view, mysql -uroot -hIP1 -p

After entering the password, enter

show status like 'wsrep%';

It means that the three servers are successfully connected. At this time, the SQL writing, modification, table creation, and database creation operations you do on any one will respond to the three servers at the same time, and the data will be fully synchronized.

Shut down all servers service mysql stop

vim /etc/my.cnf

wsrep_sst_method changes rsync to xtrabackup

Then start the servers in sequence according to the above method, and all installation of galera cluster is completed.

Recommended Posts

CentOS 7 Galera Cluster installation guide
Centos5 installation guide
Centos7 mqtt cluster installation
Glusterfs cluster installation on Centos7
Redis cluster installation under CentOS
Redis cluster installation under CentOS
2019-07-09 CentOS7 installation
centos7_1708 installation
Centos7 hadoop cluster installation and configuration
The latest Centos7 installation Mysql8 guide
Python - centos6 installation
Docker installation (CentOS7 installation)
(1) Centos7 installation to build a cluster environment
CentOS7 docker installation
CentOS online installation RabbitMQ3.7
CentOS 8 install ZABBIX4.4 guide
Zabbix 2.2.20 installation details (Centos6.9)
CentOS7.3.1611 deploys k8s1.5.2 cluster
Centos6.9 build rabbitmq 3.6.8 cluster
CentOS6 install couchdb2 cluster
Centos source installation Python3
lamp (centos7) installation lamp environment
CentOS 6.8 deploy zookeeper cluster
Centos7 build Kubernetes cluster
Graphical installation of CentOS8
Mysql8.0.15 installation configuration (centos7)
Linux notes (1): CentOS-7 installation
Redis3 installation under Centos7
CentOS cluster related issues
Centos7 deploys Kubernetes cluster
CentOS online installation RabbitMQ3.7
CentOS7 deploys k8s cluster
Docker CentOS installation method
Linux CentOS 7 installation tutorial
Centos7 docker installation details
Discourse CentOS 8 new installation manual
Centos 7 mini installation process record
CentOS7 install rabbitmq cluster (binary)
Centos7 installation and configuration prometheus
Centos7.2/7.3 cluster install Kubernetes 1.8.4 + Dashboard
CentOS 7 installation and configuration PPTP
CentOS 6.x installation mysql5.7 record
CentOS installation and configuration cmake
Graphical centos installation detailed process
Centos7.5 installation and configuration MongoDB4.0.4
CentOS 7 installation and configuration PPTP
Hyper-V + CentOS7 installation video tutorial
centos7 kvm installation and use
Centos7 silent installation of Oracle11g
CentOS 6.8 virtual machine installation details
CentOS7 postgresql installation and use
CentOS environment installation of Docker
CentOs7.3 build SolrCloud cluster service
Centos7 install k8s cluster 1.15.0 version
Centos7 installation tomcat process introduction
Centos7.4 environment installation lamp-php7.0 tutorial
Docker EE installation on centos7
Discourse CentOS 8 new installation manual
CentOS8 Linux 8.0.1905 installation process (illustration)
Centos7 elk7.1.1 installation and use
Centos7 installation and configuration of Jenkins