The previous blog compares the various MySQL cluster scenarios, this blog will explain in the synchronous replication function of the excellent Percona xtradb cluster installation steps
First, if the server already has the default MySQL (many Linux installation comes with MySQL) need to first delete, otherwise it will report a conflict
Rpm-qa | Grep-i Mysql-server | Xargs sudo rpm-e--nodeps
Installing a dependent Package
wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RPM-IVH epel-release-6-8.noarch.rpm
wget http://mirror.centos.org/centos/6/os/x86_64/Packages/nc-1.84-22.el6.x86_64.rpm
RPM-IVH nc-1.84-22.el6.x86_64.rpm
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/socat-1.7.2.4-1.el6.rf.x86_64.rpm
RPM-IVH socat-1.7.2.4-1.el6.rf.x86_64.rpm
Installing percona-xtradb-cluster-56
Yum Install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
Yum Install percona-xtradb-cluster-56
Start after installation
/etc/init.d/mysql start
Then create a user for synchronous replication, and the username and password used here are Sstuser
CREATE USER ' sstuser ' @ ' localhost ' identified by ' sstuser ';
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT on *. * to ' sstuser ' @ ' localhost ';
FLUSH privileges;
If the create user times lost connection, need to upgrade, start MySQL after execution:
Mysql_upgrade-uroot-p--skip-version-check
After creating the user, stop MySQL, modify/etc/my.cnf, my my.cnf for
[client]socket=/var/lib/mysql/mysql.sock[mysqld]server_id=1datadir=/var/lib/mysqlsocket=/var/lib/mysql/ Mysql.sockuser=mysqlbinlog_format=row#bind-address=0.0.0.0default-storage-engine=innodbinnodb_autoinc_lock_ Mode=2wsrep_provider=/usr/lib64/libgalera_smm.sowsrep_provider_options= "gcache.size=300m; gcache.page_size=1g "Wsrep_cluster_name=" mycluster "wsrep_cluster_address=" gcomm://200.200.168.24,200.200.168.25 "wsrep_sst_method=rsyncwsrep_node_address=200.200.168.24 # Native IP address #wsrep_sst_method=xtrabackup-v2wsrep_sst_auth=" Sstuser:sstuser "Wsrep_node_name=pxc1 wsrep_slave_threads=4[mysql_safe]log-error=/var/log/mysqld.logpid-file=/ Var/run/mysqld/mysqld.pid
There are two places to be aware of:
1, wsrep_node_address=200.200.168.24 to install each MySQL service, you need to modify its own IP
2. Wsrep_sst_method: The slave node needs to be set to rsync in order to synchronize successfully when it is just installed
The MySQL service in each cluster is installed as per the above steps
After the installation is complete, you can start MySQL.
The way to start MySQL, if it is the primary server, use/etc/init.d/mysql BOOTSTRAP-PXC, if it is a backup server, use/etc/init.d/mysql start.
Start The primary server, and when you start the backup server, you will see that the backup server automatically synchronizes the data.
In addition, if the startup fails, first, look at the MySQL log, above the my.cnf specified in the Var/log/mysqld.log (if not specified, the default is in the directory/var/lib/mysql/), to see if there is no permission deny problem, if there is, Perform
Yum-y Install Policycoreutils-python
Semanage permissive-a mysqld_t
Reference Documentation:
http://www.percona.com/doc/percona-xtradb-cluster/5.6/
http://hj192837.blog.51cto.com/655995/1546149
Http://blog.chinaunix.net/uid-20776139-id-4041319.html
http://blog.csdn.net/china_world/article/details/25424903
http://blog.csdn.net/renfengjun/article/details/41379901
Percona xtradb cluster installation steps