Operating system Centos7.4,mysql installed under/data/mysql, MySQL belongs to MySQL user
1. Download the source package
Download pxc-5.7.19
Mkdir-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
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
Download 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
2. 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
Configuring the Epel Library
Wget-o/etc/yum.repos.d/epel.repo Http://mirrors.aliyun.com/repo/epel-7.repo
3. Compiling the installation
3.1 Compiling and installing 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.2 Compiling and installing percona-xtradb-cluster-5.7.19-29.22
It is best to uninstall the local MySQL database before compiling the installation.
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
Compiling garbd,libgalera_smm.so
Cd/usr/local/mysql
CD "Percona-xtradb-cluster-galera"
Get 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 the PXC installation directory
Mkdir-p/usr/local/mysql/{bin,lib}
Copy the compiled results file to the PXC installation directory
CP Garb/garbd/usr/local/mysql/bin
CP Libgalera_smm.so/usr/local/mysql/lib
Compiling percona-xtradb-cluster-5.7.19-29.22
-dmysql_server_suffix Value Acquisition
cd/usr/local/percona-xtradb-cluster-5.7.19-29.22
Wsrep_version= "$ (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.22
SOURCE VERSION
Mysql_version= "$MYSQL _version_major. $MYSQL _version_minor. $MYSQL _version_patch"
Echo $MYSQL _version
Revision= "$ (cd" $SOURCEDIR "; grep ' ^short: ' docs/info_src |sed-e ' s/short://')"
-dcompilation_comment value
echo "Percona XtraDB Cluster binary (GPL) $MYSQL _version-$WSREP _version Revision $REVISION"
Compiling percona-xtradb-cluster-5.7.16-27.19
Cd/usr/local/mysql
CMake./
-dbuild_config=mysql_release \
-dcmake_build_type=relwithdebinfo \
-dwith_embedded_server=off \
-dfeature_set=community \
-denable_dtrace=off \
-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=on
Make && make install
4. Compiling the configuration file
Vim/usr/local/mysql/my.cnf
[Client]
Socket=/tmp/mysql.sock
Port = 6612
Default-character-set = UTF8
[Mysqld]
Socket=/tmp/mysql.sock
Basedir =/usr/local/mysql
DataDir =/usr/local/mysql/data
Port = 6612
server_id = 10215
Pid-file =/usr/local/mysql/mysql.pid
Key_buffer_size =128m
Max_allowed_packet = 16M
Table_open_cache = 512
Max_connections = 200
Sort_buffer_size = 20M
Read_buffer_size = 20M
Read_rnd_buffer_size = 8M
Myisam_sort_buffer_size = 64M
Thread_cache_size = 8
Query_cache_size = 32M
Character-set-server=utf8
Innodb_buffer_pool_size = 256M
Innodb_log_file_size = 48M
Innodb_log_buffer_size = 8M
Innodb_flush_log_at_trx_commit = 1
Innodb_file_per_table=1
Lower_case_table_names=1
Innodb_temp_data_file_path = ibtmp1:12m:autoextend:max:5120m
Explicit_defaults_for_timestamp=true
Sql_mode=no_engine_substitution,strict_trans_tables,only_full_group_by
Skip-name-resolve
Log-bin =/usr/local/mysql/binlog/mysql-bin
Expire_logs_days = 7
#binlog-do-db=plateform_stable,finance_stable,location_log_stable
#binlog-ignore-db=mysql,information_schema,test
Binlog_format=row
Log_slave_updates
Symbolic-links=0
Default_storage_engine=innodb
innodb_autoinc_lock_mode=2
Log-error=/usr/local/mysql/data/mysqld-error.log
Wsrep_cluster_name = ycpxc # # #指定您的群集的逻辑名称. It must be the same for all nodes in the cluster.
wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so
wsrep_cluster_address= ' gcomm:// 192.168.10.215,192.168.10.214 ' # # #指定群集中节点的IP地址, nodes are required to join the cluster at least one, but it is recommended to list the addresses of all nodes.
wsrep_sst_receive_address=192.168.10.215:6615## #用于SST传送的端口
wsrep_node_incoming_address=192.168.10.215## #定义节点期望客户端连接的IP地址和端口.
Wsrep_provider_options = "gmcast.listen_addr=tcp://192.168.10.215;ist.recv_addr=192.168.10.215:6618;"
# # #gmcast. Listen
# # #来自其他节点的地址Galera侦听连接. Can be used to override the default port listening, which is obtained from the connection address.
# # #ist. RECV_ADDR
# # #地址监听增量状态传输.
wsrep_slave_threads= 4
wsrep_log_conflicts
wsrep_node_address=192.168.10.215## #集群节点地址
Wsrep_sst_ method=xtrabackup-v2## #默认情况下, Percona xtradb clusters use Percona xtrabackup for State Snapshot Transport (SST).
Wsrep_sst_auth=sstuser:passw0rd # # #将SST的身份验证凭据指定为 <sst_user>:<sst_pass>. You must create this user
Wsrep_log_conflicts
wsrep_retry_autocommit=8
secure_file_priv= ""
Innodb_page_cleaners=8
[Mysqldump]
Quick
Max_allowed_packet = 16M
[MySQL]
No-auto-rehash
Port = 6612
Default-character-set = UTF8
Socket=/tmp/mysql.sock
[Myisamchk]
Key_buffer_size = 256M
Sort_buffer_size = 256M
Read_buffer = 2M
Write_buffer = 2M
[Mysqlhotcopy]
Interactive-timeout
Note: In [client], [mysqld], [MySQL] It is best to specify the location of sock, avoid initialization and start the times wrong to find the default configuration file.
4.1 Creating a user for Wsrep_sst_auth transport
When you boot the first node and give it 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;
5. Initialize Start PXC master node
chmod +x/usr/local/mysql/my.cnf
Chown-r Mysql:mysql/usr/local/mysql
Su-mysql
/usr/local/mysql/bin/mysqld--defaults-file=./my.cnf--initialize--wsrep-new-cluster &
#要指定配置文件来初始化
#初始化有问题可以清空msyql files in the/data/directory
#记录密码
#注意主节点启动要加上--wsrep-new-cluster, other nodes are not used.
# # #用刚刚初始化的密码进去MySQL
/USR/LOCAL/MYSQL/BIN/MYSQL-UROOT-P${MYPASSWD}
# # #第一次进去会提示改密码
ALTER USER ' root ' @ ' localhost ' identified by ' 123456 ';
6. Configure additional nodes
Installation method is the same as the main node, note to uninstall the original MySQL, change the configuration file cluster information and server_id.
Only the Variance section is listed:
server_id = 10214
wsrep_sst_receive_address=192.168.10.214:6615## #用于SST传送的端口
wsrep_node_incoming_address=192.168.10.214## #定义节点期望客户端连接的IP地址和端口.
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.215## #集群节点地址
6.1 Starting other nodes
#其它节点直接启动不用再创建用户和密码
/usr/local/mysql/bin/mysqld--defaults-file=. /my.cnf
7. Using GARBD
PXC cluster is at least 3 units, if not, you can use the arbiter GARBD, to solve
Can be found on a network segment of the server. can also be on existing nodes but note the default ports do not conflict
#启用garbd
cd/usr/local/mysql/bin/
./garbd-a gcomm://192.168.10.214,192.168.10.215-g Ycpxc-l/usr/local/mysql/data/garbd.log-d
#全部起完了之后就可以看到节点数和集群
8. Check
#查看MySQL node points
Mysql> show global status like ' Wsrep_cluster_size ';
+--------------------+-------+
| variable_name | Value |
+--------------------+-------+
| Wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in Set (0.00 sec)
Is three indicates the success of the PXC cluster, you can create a table on a node, the boot node can query to the description of the cluster is working properly.
Percona-xtradb-cluster Compilation and Installation