Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Compilation and installation of Percona-XtraDB-Cluster

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Environment:

The operating system centos7.4,mysql is installed under / data/mysql, mysql belongs to the mysql user, pxc-5.7.19

First, download the source package:

1.1 download pxc-5.7.19

Mkdir-p / home/sunx/tools

Wget-P / home/sunx/tools

Https://www.percona.com/downloads/Percona-XtraDB-Cluster-57/Percona-XtraDB-Cluster-5.7.19-29.22/source/tarball/Percona-XtraDB-Cluster-5.7.19-29.22.tar.gz

1. 2 download boost

Mkdir-p / usr/local/boost

Wget-P / usr/local/boost https://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download

1.3download percona-xtrabackup-2.4.5

Wget-P / home/sunx/tools https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2.4.5/source/tarball/percona-xtrabackup-2.4.5.tar.gz

Second, installation dependencies:

Yum-y install libtool ncurses-devel libgcrypt-devel libev-devel\

Git scons gcc gcc-c++ openssl check cmake bison boost-devel\

Asio-devel libaio-devel ncurses-devel readline-devel pam-devel socat\

Libaio automake autoconf vim redhat-lsb check-devel

Yum-y install libnl-devel openssl-devel libnfnetlink-devel ipvsadm\

Popt-devel libnfnetlink kernel-devel popt-static iptraf

Yum-y install numactl libev perl-DBD-mysql perl-Time-HiRes

Configure the epel library

Wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

3. Compile and install:

3.1 compile and install percona-xtrabackup

Cd / usr/local/src/percona-xtrabackup-2.4.5/

Cmake. /-DBUILD_CONFIG=xtrabackup_release\

-DWITH_MAN_PAGES=OFF\

-DDOWNLOAD_BOOST=1\

-DWITH_BOOST= "/ usr/local/boost"

Make-j 4 & & make install

3.2Compiler and install Percona-XtraDB-Cluster-5.7.19-29.22

It is best to uninstall the local mysql database before compiling and installing

Rpm-qa | grep mysql (pay attention to case and change MySQL if mysql fails)

Package name of yum-y remove mysql

The data and / etc/my.cnf in / var/lib/mysql will not be deleted after uninstallation. If determined to be useless, delete them manually.

Rm-f / etc/my.cnf

Rm-rf / var/lib/mysql

Create a mysql user name and folder

Mkdir / data/mysql

Ln-s / data/mysql / usr/local/mysql

Mkdir / usr/local/mysql/ {binlog,slow}-p

Useradd mysql

Chown-R mysql:mysql / usr/local/mysql

Compile garbd,libgalera_smm.so

Cd / usr/local/mysql

Cd "percona-xtradb-cluster-galera"

Get the revno value

Cat GALERA-REVISION

# revno= "GALERA-REVISION"

Scons-j4 psi=1-config=force revno= "8678538" boost_pool=0 libgalera_smm.so

Scons-J4-config=force revno= "8678538" garb/garbd

Create a pxc installation directory

Mkdir-p / usr/local/mysql/ {bin,lib}

Copy the compilation result file to the pxc installation directory

Cp garb/garbd / usr/local/mysql/bin

Cp libgalera_smm.so / usr/local/mysql/lib

Check whether the copied file is normal

Ls-1 / usr/local/mysql/bin/garbd

Ls-1 / usr/local/mysql/lib/libgalera_smm.so

-DMYSQL_SERVER_SUFFIX value acquisition

Cd / usr/local/Percona-XtraDB-Cluster-5.7.19-29.22WSREPVERSION = "$(grep WSREP_INTERFACE_VERSION wsrep/wsrep_api.h | cut-d'"'- f2). $(grep 'SET (WSREP_PATCH_VERSION' "cmake/wsrep.cmake" | cut-d' "'- f2)" echo $WSREP_VERSION

-DCOMPILATION_COMMENT value acquisition

Cd / usr/local/Percona-XtraDB-Cluster-5.7.19-29.22source VERSIONMYSQL_VERSION= "$MYSQL_VERSION_MAJOR.$MYSQL_VERSION_MINOR.$MYSQL_VERSION_PATCH" echo $MYSQL_VERSIONREVISION= "$(cd" $SOURCEDIR "; grep'^ short: 'Docs/INFO_SRC | sed-e' s/short: / /')" echo "Percona XtraDB Cluster binary (GPL) $MYSQL_VERSION-$WSREP_VERSION Revision $REVISION"

Compile Percona-XtraDB-Cluster-5.7.16-27.19

Cd / usr/local/mysqlcmake. /-DBUILD_CONFIG=mysql_release\-DCMAKE_BUILD_TYPE=RelWithDebInfo\-DWITH_EMBEDDED_SERVER=OFF\-DFEATURE_SET=community\-DWITH_SSL=system-DWITH_ZLIB=system\-DCMAKE_INSTALL_PREFIX= "/ usr/local/mysql"\-DMYSQL_DATADIR= "/ usr/local/mysql/data"\-DMYSQL_SERVER_SUFFIX= "29.22"\-DWITH_INNODB_DISALLOW_WRITES=ON\-DWITH_WSREP=ON\-DWITH_UNIT_TESTS=0\-DWITH_READLINE=system\ -DWITHOUT_TOKUDB=ON\-DWITHOUT_ROCKSDB=ON\-DCOMPILATION_COMMENT= "Percona XtraDB Cluster binary (GPL) 5.7.19-29.22 Revision c10027a"\-DWITH_PAM=ON\-DWITH_INNODB_MEMCACHED=ON\-DDOWNLOAD_BOOST=1\-DWITH_BOOST= "/ usr/local/boost"\-DWITH_SCALABILITY_METRICS=ONmake & & make install IV. Compile configuration file

4.1 compile configuration file

Vim / usr/local/mysql/ my.cnf [client] socket=/tmp/mysql.sockport = 3306default-character-set = utf8 [mysqld] socket=/tmp/mysql.sockbasedir = / usr/local/mysqldatadir = / usr/local/mysql/dataport = 3306server_id = 10215pid-file = / usr/local/mysql/mysql.pidkey_buffer_size = 128Mmax_allowed_packet = 16Mtable_open_cache = 512max_connections = 200sort_buffer_size = 20Mread_buffer_size = 20Mread_rnd_buffer_size = 8Mmyisam _ sort_buffer_size = 64Mthread_cache_size = 8query_cache_size = 32Mcharacter-set-server=utf8innodb_buffer_pool_size = 256Minnodb_log_file_size = 48Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_file_per_table=1lower_case_table_names=1innodb_temp_data_file_path = ibtmp1:12M:autoextend:max:5120Mexplicit_defaults_for_timestamp=TRUEsql_mode=NO_ENGINE_SUBSTITUTION STRICT_TRANS_TABLES,only_full_group_byskip-name-resolvelog-bin = / usr/local/mysql/binlog/mysql-binexpire_logs_days = 7 indexed stablerecoverylocationallogstableinfidelogicativedbinformationschemaschemaformastbinlogformatted ROWloglogslaveupdatessymbolboliclylinks0defaultstoragepowered engineered innovative DBinnodbandautoincinception lockout modeboxes 2logcolor errorUSUSUSLULAMLmysqlypdatamysqldhouse error.logwsrepclustercards name = ycpxc # specify the logical name of your cluster. It must be the same for all nodes in the cluster. Wsrep_provider=/usr/local/mysql/lib/libgalera_smm.sowsrep_cluster_address='gcomm://192.168.10.215192.168.10.214192.168.10.213'### specifies the IP address of the nodes in the cluster, and at least one node is required to join the cluster, but it is recommended that you list the addresses of all nodes. Port used by wsrep_sst_receive_address=192.168.10.215### for SST delivery wsrep_node_incoming_address=192.168.10.215### defines the IP address and port that the node expects the client to connect to. Wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.10.215;ist.recv_addr=192.168.10.215;" # gmcast.listen### addresses from other nodes Galera listening for connections. Can be used to override the default port to listen, which is obtained from the connection address. # ist.recv_addr### address listens for incremental status transmission. Wsrep_slave_threads= 4wsrep_log_conflictswsrep_node_address=192.168.10.215### cluster node address wsrep_sst_method=xtrabackup-v2### by default, Percona XtraDB clusters use Percona XtraBackup for stateful snapshot transfer (SST). Wsrep_sst_auth=sstuser:passw0rd # # specifies the authentication credentials for SST as:. You must create this user wsrep_log_conflictswsrep_retry_autocommit=8secure_file_priv= "" innodb_page_cleaners= 8 [mysqldump] quickmax_allowed_packet = 16m [MySQL] no-auto-rehashport = 3306default-character-set = utf8socket=/tmp/ mysql.sock [myisamchk] key_buffer_size = 256Msort_buffer_size = 256Mread_buffer = 2Mwrite_buffer = 2m [mysqlhotcopy] interactive-timeout

Note: it is best to specify the location of sock in [client], [mysqld] and [mysql] to prevent initialization and startup times from finding the default configuration file.

Ports involved in the 4.2pxc environment

# mysql instance port: 3306.

# Port for pxc cluster to communicate with each other: 4567

Port for group communication, default 4567. It can be changed by the option:

Wsrep_provider_options = "gmcast.listen_addr=tcp://0.0.0.0:4567;"

# Port for SST transfer: 4444

Port for State Transfer, default 4444. It can be changed by the option:

Wsrep_sst_receive_address=10.11.12.205:4444

# Port for IST transfer: 4568

Port for Incremental State Transfer, default port for group communication + 1 (4568). It can be changed by the option:

Wsrep_provider_options = "ist.recv_addr=10.11.12.206:4568;"

4.1 create users for wsrep_sst_auth transport

When booting the first node and providing it with the necessary permissions:

Mysql > CREATE USER 'sstuser'@'localhost' IDENTIFIED BY' passw0rd'

Mysql > GRANT RELOAD, LOCK TABLES, PROCESS, REPLICATION CLIENT ON. TO 'sstuser'@'localhost'

Mysql > FLUSH PRIVILEGES

Initialize and start the pxc master node

5.1 initialize pxc

Chown-R mysql:mysql / usr/local/mysql

/ usr/local/mysql/bin/mysqld-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data-user=mysql-initialize

Initialization errors can empty files in the msyql/data/ directory

Pay attention to recording the password

5.2 start mysql

/ usr/local/mysql/bin/mysqld-defaults-file=./my.cnf-wsrep-new-cluster &

Note that-- wsrep-new-cluster is added to the startup of the primary node, but not to other nodes.

Enter MySQL with the password you just initialized

/ usr/local/mysql/bin/mysql-uroot-p$ {mypasswd}

5.3 change password

The first time you go in, you will be prompted to change the password.

ALTER USER 'root'@'localhost' IDENTIFIED BY' 123456'

6. Configure other nodes

6.1 Node Profil

192.168.10.214

The installation method is the same as the master node. Be sure to uninstall the original mysql and change the cluster information and server_id of the configuration file.

List only the differences:

Server_id = 10214wsrep_sst_receive_address=192.168.10.214:6615### Port used for SST transport wsrep_node_incoming_address=192.168.10.214### defines the IP address and port that the node expects the client to connect to. Wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.10.214;ist.recv_addr=192.168.10.214:6618;" wsrep_node_address=192.168.10.214### cluster node address

192.168.10.213

Server_id = 10213wsrep_sst_receive_address=192.168.10.213### Port used for SST transport wsrep_node_incoming_address=192.168.10.213### defines the IP address and port that the node expects the client to connect to. Wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.10.213;ist.recv_addr=192.168.10.213;" wsrep_node_address=192.168.10.213### cluster node address

6.2 start other nodes

# No need to add-- wsrep-new-cluster when other nodes are started directly

/ usr/local/mysql/bin/mysqld-- defaults-file=../my.cnf

7. Use garbd

The minimum number of pxc clusters is 3. If not, the arbitrator garbd can be used to solve the problem.

You can find it on a server in a network segment. It can also be on the existing node, but be careful that the default port does not conflict.

7.1 # enable garbd

After cd / usr/local/mysql/bin/./garbd-- group=pxc-cluster-- address=gcomm://192.168.10.215192.168.10.214-- option=gmcast.listen_addr=tcp://192.168.10.213-d-l / tmp/garbd.log# is all finished, you can see the number of nodes and clusters.

7.2 if you want to start garbd on a server with pxc, you need to change the communication port of the default pxc cluster

Cd / usr/local/mysql/bin/. / garbd-- group=pxc-cluster-- address=gcomm://192.168.10.215192.168.10.214-- option=gmcast.listen_addr=tcp://192.168.10.214:5567-d-l / tmp/garbd.log # after all, you can see the number of nodes and cluster 8. Check # to see the number of MySQL nodes mysql > show global status like 'wsrep_cluster_size' +-+-+ | Variable_name | Value | +-+-+ | wsrep_cluster_size | 3 | +-+-+ 1 row in set (0.00 sec)

Three indicate that the pxc cluster has been built successfully. You can create a table on one node, and the other nodes can query it to indicate that the cluster is running normally.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report