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

Construction of PXC three-node cluster system

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

Share

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

1. Concept:

Percona Xtradb Cluster, abbreviated as PXC. Is a MySQL cluster based on the Galera plug-in.

For more details, please follow my other article: understanding the principle of PXC Cluster

two。 Build:

Address of the official manual: https://www.percona.com/doc/percona-xtradb-cluster/LATEST/index.html

Environment: PXC101 IP:192.168.1.101 port: 3306 version 5.7CentOS7

PXC102 IP:192.168.1.102 port: 3306 version 5.7CentOS7

PXC103 IP:192.168.1.103 port: 3306 version 5.7CentOS7

1. Turn off the system firewall

# systemctl stop firewalld # systemctl disable firewalld # cancel firewall boot self-startup

two。 Close selinux

# vim / etc/selinux/config SELINUX=permissive # getenforce # check whether it is closed

3. Install dependencies and related diagnostic softwar

# yum install lsof socat telnet # telnet to check the port

4. Download and extract the binary installation package (executed on all three hosts):

(choosing a binary installation package can avoid various compilation or Yum installation dependencies, which saves the most time and is convenient to upgrade in the future.)

101version corresponds to REHL series version, 100corresponds to DEBIAN series version, there is a difference

# wget https://www.percona.com/downloads/Percona-XtraDB-Cluster-LATEST/Percona-XtraDB-Cluster-5.7.19-29.22-3/binary/tarball/Percona-XtraDB-Cluster-5.7.19-rel17-29.22.3.Linux.x86_64.ssl101.tar.gz-P / usr/local/src # tar-zxf / usr/local/src/Percona-Xtra (...). Tar.gz-C / usr/local # create symbolic links That is, create a shortcut, which is also a tip for easy upgrade in the future. # ln-s / usr/local/Percona-XtraDB-Cluster-5.7.19-rel17-29.22.3.Linux.x86_64.ssl101 / usr/local/mysql # associate the executable location to the path It is convenient to directly call # echo "PATH=$PATH:/usr/local/mysql/bin" like a program installed by Yum | cat > > / etc/profile # source / etc/profile

5. Create MySQL users and user groups, related to permissions (executed by all three hosts):

# useradd-d / usr/local/mysql-s / sbin/nologin-U-M mysql # mkdir-p / data/mysql/3306/ {data,logs,tmp} # chown-R mysql.mysql / data/*

6. Create a configuration file (executed on all three hosts):

Cat / data/mysql/3306/my.cnf [client] # omit [mysql] # omit [mysqld] basedir = / usr/local/mysql datadir = / data/mysql/3306/data/ socket = / data/mysql/3306/tmp/mysql3306.sock pid-file = PXC3306.pid # omit # # log log-bin = mysql-bin sync_binlog = 1 innodb_flush_log_at_trx_commit = 1 # omit # # InnoDB innodb_file_per_table = 1 # # InnoDB IO innodb_data_file_path = ibdata1:1G: Autoextend innodb_thread_concurrency = 0 # replication server-id = 1013306 # IP+PORT master_info_repository = TABLE relay_log_info_repository = TABLE binlog_format = row relay_log_recovery = 1 relay-log-purge = 1 # # GTID Gtid_mode = on # must be enforce_gtid_consistency = 1 # must be # omitted # # PXC MODE wsrep_provider=/usr/local/mysql/lib/libgalera_smm.so # galera plugin location Wsrep_cluster_name=zrz # Cluster name wsrep_cluster_address=gcomm://192.168.1.101192.168.1.102192.168.1.103 # Cluster all host addresses wsrep_node_name=PXC101 # this node name wsrep _ node_address=192.168.1.101 # this node IP wsrep_sst_method=xtrabackup-v2 # write set full synchronous transmission method wsrep_sst_auth=dba:123456 # write set transmission authentication user and password pxc_ Strict_mode=ENFORCING # must When it comes to cluster data security binlog_format=ROW # must default_storage_engine=InnoDB # must innodb_autoinc_lock_mode=2 # self-increment lock discrete allocation self-increment primary key EOF

First comment out the PXC MODE-related configuration items in the above configuration file (preceded by #)

# / usr/local/mysql/bin/mysqld-defaults-file=/data/mysql/3306/my.cnf-initialize-user=mysql &

Get the initial password and change the root password to create a full write set to transfer users

# grep-I password / data/mysql/3306/error.log # mysqld-- defaults-file=/data/mysql/3306/my.cnf & # launch in single instance mode MySQL # mysql-u root-p # enter the password just obtained by grep # enter the password you just checked and enter the password > set password='123456' # change root user password > flush privileges; > create user dba@'localhost' identified by '123456password; # create full write set transfer user > GRANT PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *. * TO' dba'@'localhost'; > flush privileges; > shutdown; # close instance > exit

8. Start the first node of PXC

First re-enable the PXC MODE-related configuration items commented out in the previous step (delete # before)

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

At the same time, tail-f / data/mysql/3306/error.log will observe:

9. Start the second and third node

# execute # / usr/local/mysql/bin/mysqld--defaults-file=/data/mysql/3306/my.cnf on the second node-- user=mysql& # execute # / usr/local/mysql/bin/mysqld--defaults-file=/data/mysql/3306/my.cnf-- user=mysql& on the third node

At this point, you can observe the error log on the error node of the first node.

It can be observed on either the second node or the third node:

OK, all started successfully.

3. View WSREP write set synchronization

1. View parameters related to write set synchronization

Execute on any instance that has entered the synchronization state

> show global status like "wsrep%"

The output is as follows:

two。 Check synchronization

Create a database on instance 3

> create database dba

It can be observed on both instance 1 and instance 2:

> show database

OK, at this point, we have completed the creation of the entire PXC cluster

4. Note:

The first node needs to add the-- wsrep-new-cluster parameter when it starts.

If a node joins a cluster that has already been started, this parameter is not required, just follow the normal startup mode.

For more troubleshooting, please visit my next post: PXC build troubleshooting

Attachment: http://down.51cto.com/data/2368756

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