http://blog.51cto.com/hj192837/1546149

You should have odd number of real nodes.

node #1
hostname: percona1
IP: 192.168.70.71

node #2
hostname: percona2
IP: 192.168.70.72

node #3
hostname: percona3
IP: 192.168.70.73

1. disable selinux and iptables

service iptables stop
chkconfig iptables off; chkconfig ip6tables off

setenforce 0
vi /etc/selinux/config
SELINUX=disabled

2. cat << EOF > /etc/yum.repos.d/iso.repo
[iso]
name=iso
baseurl=http://mirrors.sohu.com/centos/6.5/os/x86_64
enable=1
gpgcheck=0
EOF

cat << EOF > /etc/yum.repos.d/epel.repo
[epel]
name=epel
baseurl=http://mirrors.sohu.com/fedora-epel/6Server/x86_64
enable=1
gpgcheck=0
EOF

( or rpm -ivh http://www.percona.com/redir/downloads/percona-release/percona-release-0.0-1.x86_64.rpm )

cat << EOF > /etc/yum.repos.d/percona.repo
[percona]
name=percona
baseurl=file:///percona (http://repo.percona.com/centos/6Server/os/x86_64/) 
enable=1
gpgcheck=0
EOF

3. yum -y install Percona-XtraDB-Cluster-56

on node 1:
vi /etc/my.cnf
[mysqld]
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.70.71,192.168.70.72,192.168.70.73
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.70.71
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_centos_cluster
wsrep_sst_auth="sstuser:s3cret"

expire_logs_days=10
max_binlog_size=100M

# just for creating a NEW cluster

service mysql bootstrap-pxc

or
service mysql start --wsrep_new_cluster
or
service mysql start --wsrep-cluster-address="gcomm://"

or for CentOS 7
systemctl start mysql@bootstrap.service

mysql -uroot
mysql> show status like 'wsrep%';

mysql> UPDATE mysql.user SET password=PASSWORD("Passw0rd") where user='root';
mysql> CREATE USER 'sstuser'@'localhost' IDENTIFIED BY 's3cret';
mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost';
mysql> FLUSH PRIVILEGES;

on node 2:
vi /etc/my.cnf
[mysqld]
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.70.71,192.168.70.72,192.168.70.73
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.70.72
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_centos_cluster
wsrep_sst_auth="sstuser:s3cret"

expire_logs_days=10
max_binlog_size=100M

service mysql start

on node 3:
vi /etc/my.cnf
[mysqld]
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address=gcomm://192.168.70.71,192.168.70.72,192.168.70.73
binlog_format=ROW
default_storage_engine=InnoDB
innodb_autoinc_lock_mode=2
wsrep_node_address=192.168.70.73
wsrep_sst_method=xtrabackup-v2
wsrep_cluster_name=my_centos_cluster
wsrep_sst_auth="sstuser:s3cret"

expire_logs_days=10
max_binlog_size=100M

service mysql start

Ports:

Galera: 4567
SST: 4444
SST incremental port: 4568
MySQL: 3306

Notes: http://www.percona.com/blog/2014/09/01/galera-replication-how-to-recover-a-pxc-cluster/

在vmware workstation测试环境中,不可能mysql一直开机

1. on three nodes:

chkconfig mysql off

2. poweroff sequence: node3 > node2 > node1

3. poweron sequence: node1 > node2 > node3

4. on node1: service mysql bootstrap-pxc

on node2 and node3: service mysql start

HAproxy配置:

percona node1: 192.168.70.71
percona node2: 192.168.70.72
percona node3: 192.168.70.73
haproxy server 1: 192.168.70.12
haproxy server 2: 192.168.70.13
haproxy VIP: 192.168.70.10

on three percona nodes:
yum -y install xinetd

vi /etc/services
mysqlchk    6033/tcp            # mysqlchk

vi /etc/xinetd.d/mysqlchk
#        port            = 9200 
        port            = 6033

service xinetd start

If you want to use a different username or password for clustercheck, vi /usr/bin/clustercheck

On one percona node:
mysql -uroot -p
mysql> CREATE USER 'haproxy'@'192.168.70.12';
mysql> CREATE USER 'haproxy'@'192.168.70.13';
mysql> grant process on *.* to 'clustercheckuser'@'localhost' identified by 'clustercheckpassword!';
mysql> flush privileges;

On two haproxy server:
yum -y install mysql

vi /etc/haproxy/haproxy.cfg
defaults
#    option                  httplog
#    option http-server-close
#    option forwardfor       except 127.0.0.0/8

listen mysqld-status 192.168.70.10:3306
        balance source
        mode tcp
        option tcpka
        option mysql-check user haproxy
        server MySQL1 192.168.70.71:3306 check weight 1
        server MySQL2 192.168.70.72:3306 check weight 1
        server MySQL2 192.168.70.73:3306 check weight 1

listen mysql-cluster 192.168.70.10:3306
        mode tcp
        balance source
        option  httpchk
        server MySQL1 192.168.70.71:3306 check port 6033 inter 12000 rise 3 fall 3
        server MySQL1 192.168.70.72:3306 check port 6033 inter 12000 rise 3 fall 3
        server MySQL1 192.168.70.73:3306 check port 6033 inter 12000 rise 3 fall 3

service haproxy reload

Testing:

On one percona server:
mysql -uroot -p
mysql> grant all on *.* to root@'%' identified by 'password' with grant option;

from mysql client:

mysql -h 192.168.70.10 -uroot -p

使用innobackupex备份数据库:

mkdir -p /data/backups

full backup:
1. innobackupex --user=sstuser --password=s3cret /data/backups

restore full backup:
1. innobackupex --apply-log /data/backups/2014-09-08_11-03-56
2. service mysql stop; rm -rf /var/lib/mysql/*
3. innobackupex --copy-back /data/backups/2014-09-08_11-03-56
4. chown -R mysql:mysql /var/lib/mysql
5. service mysql start

Incremental backup:
1. full backup
innobackupex --user=sstuser --password=s3cret /data/backups
2. incremental one, based on full backup
innobackupex --user=sstuser --password=s3cret --incremental /data/backups --incremental-basedir=/data/backups/2014-09-08_11-20-51
3. incremental two, based on incremental one
innobackupex --user=sstuser --password=s3cret --incremental /data/backups --incremental-basedir=/data/backups/2014-09-08_11-28-56

restore incremental backup:
1. innobackupex --apply-log --redo-only /data/backups/2014-09-08_11-20-51
2. innobackupex --apply-log --redo-only /data/backups/2014-09-08_11-20-51 --incremental-dir=/data/backups/2014-09-08_11-28-56
3. innobackupex --apply-log /data/backups/2014-09-08_11-20-51 --incremental-dir=/data/backups/2014-09-08_11-31-53
Notes: --redo-only should be used when merging all incrementals except the last one.
4. innobackupex --apply-log /data/backups/2014-09-08_11-20-51
5. service mysql stop; rm -rf /var/lib/mysql/*
6. innobackupex --copy-back /data/backups/2014-09-08_11-20-51
7. chown -R mysql:mysql /var/lib/mysql
8. service mysql start

Install Percona XtraDb Cluster 5.6.20 on CentOS 6.5的更多相关文章

  1. 如何搭建Percona XtraDB Cluster集群

    一.环境准备 主机IP                     主机名               操作系统版本     PXC 192.168.244.146     node1           ...

  2. 使用percona xtradb cluster的IST方式添加新节点

    使用percona xtradb cluster的IST(Incremental State Transfer)特性添加新节点,防止新节点加入时使用SST(State SnapShop Transfe ...

  3. Installing Percona XtraDB Cluster on CentOS

    PXC简介 Percona XtraDB Cluster(简称PXC集群)提供了MySQL高可用的一种实现方法. 1.集群是有节点组成的,推荐配置至少3个节点,但是也可以运行在2个节点上. 2.每个节 ...

  4. 15、高可用 PXC(percona xtradb cluster) 搭建

    安装环境: 集群名 pxc_lk 节点1: 192.168.1.20 节点2: 192.168.1.21 节点3: 192.168.1.22   所有节点安装 wget http://www.perc ...

  5. PXC(Percona XtraDB Cluster)集群的安装与配置

    Percona XtraDB Cluster是针对MySQL用户的高可用性和扩展性解决方案,基于Percona Server .其包括了Write Set REPlication补丁,使用Galera ...

  6. mysql高可用之PXC(Percona XtraDB Cluster)

    简介 Percona XtraDB Cluster是MySQL高可用性和可扩展性的解决方案,Percona XtraDB Cluster提供的特性如下: 1).同步复制,事务要么在所有节点提交或不提交 ...

  7. PXC5.7(Percona XtraDB Cluster)+HAproxy+Keepalived 集群部署

    Percona-XtraDB-Cluster+Haproxy 搭建集群环境 环境准备及服务器信息: 配置防火墙 firewall-cmd --add-port=3306/tcp --permanent ...

  8. MySQL高可用方案-PXC(Percona XtraDB Cluster)环境部署详解

    MySQL高可用方案-PXC(Percona XtraDB Cluster)环境部署详解 Percona XtraDB Cluster简称PXC.Percona Xtradb Cluster的实现是在 ...

  9. Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication

    Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication Overview Galera Cluster 由 Coders ...

随机推荐

  1. [考试总结]noip模拟26

    首先看到这样中二的题目心头一震.... 然而发现又是没有部分分数的一天. 然而正解不会打.... 那还是得要打暴力. 但是这套题目有两个题目只有一个参数. 所以... (滑稽).jpg 然后我就成功用 ...

  2. 数据库开发之ETL概念

    原文链接:https://blog.csdn.net/jianzhang11/article/details/104240047/ ETL基础概念 - 背景随着企业的发展,各业务线.产品线.部门都会承 ...

  3. 又一本springmvc学习指南 之---第22篇 springmvc 加载.xml文件的bean标签的过程

    writedby 张艳涛,今天看spring mvc 学习指南的第2章,特意提下这个作者是how tomcat works 俩个作者之一, 喜欢上一本书的风格,使用案例来讲述原理, 在做第一个案例的时 ...

  4. 租了一台华为云耀云服务器,却直接被封公网ip,而且是官方的bug导致!

    小弟在博客园也有十多个年头了,因为离开了.net圈子,所以很少发文,今天可算是被华为云气疯了.写下这篇文章,大家也要注意自查一下,避免无端端被封公网ip. 因为小弟创业公司业务发展,需要一个公网做宣传 ...

  5. QT: 如何移动和缩放一个无边框窗口

    一个QT窗口如下可以做到无边框: Window { id: window //Designer 竟然不支持..., 设计模式时要注意 flags: Qt.FramelessWindowHint wid ...

  6. noip模拟测试30

    考试总结:这次考试,不是很顺利,首先看了一眼题目,觉得先做T1,想了一会觉得没什么好思路,就去打暴力,结果我不会枚举子集,码了半天发现不对,就随便交了一份代码上去,结果CE了,然后去打T3,20min ...

  7. SpringCloud升级之路2020.0.x版-8.理解 NamedContextFactory

    本系列为之前系列的整理重启版,随着项目的发展以及项目中的使用,之前系列里面很多东西发生了变化,并且还有一些东西之前系列并没有提到,所以重启这个系列重新整理下,欢迎各位留言交流,谢谢!~ spring- ...

  8. Run Clojure Script with External Dependencies without leiningen

    The normal way of deploy clojure files is using leiningen. But if we have no leiningen, or the scrip ...

  9. SpringBoot开发十五-发布帖子

    需求介绍 使用 AJAX 异步通信实现网页能够增量的更新呈现到页面上而不需要刷新整个页面. 现在基本上都是服务器返回 JSON 字符串来解析 代码实现 使用 JQuery 发送 AJAX 请求. 首先 ...

  10. 【MySQL】自定义数据库连接池和开源数据库连接池的使用

    数据库连接池的概念 数据库连接背景 数据库连接是一种关键的.有限的.昂贵的资源,这一点在多用户的网页应用程序中体现得尤为突出.对数据库连接的管理能显著影响到整个应用程序的伸缩性和健壮性,影响到程序的性 ...