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. 解决:CannotAcquireResourceException: A ResourcePool could not acquire a resource from its primary factory or source.

    log4j给出的异常信息有下面几句: Caused by: org.hibernate.exception.GenericJDBCException: Unable to acquire JDBC C ...

  2. 共享内存 & Actor并发模型哪个更快?

    HI,前几天被.NET圈纪检委@懒得勤快问到共享内存和Actor并发模型哪个速度更快. 前文传送门: 说实在,我内心10w头羊驼跑过...... 先说结论 首先两者对于并发的风格模型不一样. 共享内存 ...

  3. SignalR的客户端.NET Client介绍

    SignalR支持两种客户端:JavaScript Client和.NET Client.一个简单的SignalR例子中的SignalRDemo(点赞页面)就是JavaScript Client(HT ...

  4. npm命令,nrm命令,n命令, nvm命令

    npm命令 npm/yarn config set registry https://registry.npm.taobao.org 设置淘宝镜像npm/yarn config get registr ...

  5. Android 开发必备的知识点——JVM基础【转】

    image 1.JVM与操作系统的关系 Java Virtual Machine JVM 全称 Java Virtual Machine,也就是我们耳熟能详的 Java 虚拟机.它能识别 .class ...

  6. 关于 pip 的 15 个使用小技巧

    认识pip 众所周知,pip可以对python的第三方库进行安装.更新.卸载等操作,十分方便. pip的全称:package installer for python,也就是Python包管理工具. ...

  7. Python中input()函数用法

    input()函数获取用户输入数据,实现用户交互 语法格式: 变量 = input("提示信息") input()返回的是字符串,无论输入的是数字还是字符串,默认的输入结束键是回车 ...

  8. 面试了一位33岁Android程序员,只会面向百度编程,居然要25k,脸呢?

    最近逛论坛看到这样一个帖子: 面试了一位工作12年的程序员, 这位老哥有3年java开发经验,2年H5,7年Android开发经验,简历上写着精通Java,Android,熟悉H5开发.没有具体的技术 ...

  9. GitHub创建图床

    GitHub 写第一篇文章时发现从typora粘贴过来的文章会出现下面的情况 经常在Windows用typora的小伙一定遇到过一个问题:不管是用截图工具截图后直接粘贴,还是通过选择文件夹选择图片的方 ...

  10. Linux 学习Shell一部分指令

    接下来就是shell命令的一些演示了 set (超级多的变量和系统默认值) echo $?查看上一条指令是否执行成功 返回0意味着成功,返回1意味着失败 echo 是个 env 设置变量 解释一下上面 ...