Percona XtraDB Cluster how to install two Cluster nodes on one server

Source: Internet
Author: User
Tags percona

Percona XtraDB Cluster how to install two Cluster nodes on one server

I think it makes no sense to run two or more Percona XtraDB Cluster (PXC) nodes on a single physical server, except for educational and testing purposes, however, this method is still useful in this case. The most popular implementation method seems to be server virtualization, such as using stray boxes. However, in the same way, you can run multiple MySQL instances on the parallel operating system level and the concurrent mysqld formation process. Therefore, you can also have multiple Percona XtraDB Cluster nodes. The method for achieving this goal is exactly the same: use dedicated datadirs and set different ports for each node.

Which port?

Pecona XtraDB Cluster uses four TCP ports:

  • Regular MySQL port (3306 by default)

  • (Galera) (4567 by default)

  • Status transmission port (4444 by default)

  • Incremental status transmission port (default: group communication port (4567) + 1 = 4568)

Of course, when you have the default values of multiple instances on the same server and do not apply to everyone, we need to define new ports for other instances to ensure that the local firewall is open to them, if there is an activity (iptables, selinux ,...).

Install Percona XtraDB cluster, configure and start the first node

My testing server uses a brand new CentOS (community enterprise operating system) version 6.5 With the Percona yum tool installed, I installed the latest Percona XtraDB cluster (5.6.20-25.7.888.el6) through tools. Note: you may need to install EPEL (additional Linux package for Enterprise Edition) and socat (Socket CAT) tools, these two tools are independent (See bug ). To avoid conflicts, I have stopped mysql Service self-starting:

Chkconfig -- level 3 mysql off
Chkconfig -- del mysql

I originally planned to install PXC (Percona XtraDB Cluster) from the compressed package, but then I decided to install it using the yum tool so that all dependent packages can be automatically downloaded. This is my initial/etc/my. cnf file (note the use of the default value ):

[Mysqld]
Datadir =/var/lib/mysql
Port = 3306
Socket =/var/lib/mysql/mysql-node1.sock
Pid-file =/var/lib/mysql/mysql-node1.pid
Log-error =/var/lib/mysql/mysql-node1.err
Binlog_format = ROW
Innodb_autoinc_lock_mode = 2
Wsrep_provider =/usr/lib64/libgalera_smm.so
Wsrep_cluster_name = singlebox
Wsrep_node_name = node1
Wsrep_cluster_address = gcomm ://

I used the following command to manually start the cluster boot program on a node:

$ Mysqld_safe -- defaults-file =/etc/my. cnf -- wsrep-new-cluster

After startup, you should be able to access the node through the Local interface:

$ Mysql-S/var/lib/mysql/mysql-node1.sock

Configure and start the second node

Then, I created a configuration similar to the second instance configuration file. My name is/etc/my2.cnf and the following changes are made:

[Mysqld]
Datadir =/var/lib/mysql2
Port = 3307
Socket =/var/lib/mysql2/mysql-node2.sock
Pid-file =/var/lib/mysql2/mysql-node2.pid
Log-error =/var/lib/mysql2/mysql-node2.err
Binlog_format = ROW
Innodb_autoinc_lock_mode = 2
Wsrep_provider =/usr/lib64/libgalera_smm.so
Wsrep_cluster_name = singlebox
Wsrep_node_name = node2
Wsrep_cluster_address = gcomm: // 127.0.0.1: 4567,127.0 .0.1: 5020
Wsrep_provider_options = "base_port = 5020 ;"

Note the use of base_port: defined through it, port 5020 is used for group communication and 5020 (above) is reserved for IST (as simple as using gmcast. listen_addr = tcp: // 127.0.0.1: 5021 ).

You need to create and set the correct permissions for datadir in the second instance. Otherwise, MySQL cannot create some files (such as. pid and. err), although you do not need to run the mysql_install_db script:

$ Chown-R mysql: mysql/var/lib/mysql2

Then, you can run the following command to start the second instance:

$ Mysqld_safe -- defaults-file =/etc/my2.cnf

At the beginning, check the log to observe the start of the second node, communicate with the master node and join the cluster. From the beginning, the instance is executed on different terminals:

$ Tail-f/var/log/mysql2/mysql-node2.err

Remember, you can use mysqladmin to stop a node at any time. You only need to provide the correct socket as the parameter, such:

$ Mysqladmin-S/var/lib/mysql/mysql-node1.sock shutdown

Finally, once you have the entire cluster, edit the first vertex in my. cnf with a complete wsrep_cluster_addres, which is displayed on/etc/my2.cnf.

Percona XtraDB Cluster: How to run a 2-node cluster on a single server

Percona XtraDB Cluster details: click here
Percona XtraDB Cluster: click here

This article permanently updates the link address:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.