Install Percona XtraDb Cluster 5.6.20 on CentOS 6.5
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的更多相关文章
- 如何搭建Percona XtraDB Cluster集群
一.环境准备 主机IP 主机名 操作系统版本 PXC 192.168.244.146 node1 ...
- 使用percona xtradb cluster的IST方式添加新节点
使用percona xtradb cluster的IST(Incremental State Transfer)特性添加新节点,防止新节点加入时使用SST(State SnapShop Transfe ...
- Installing Percona XtraDB Cluster on CentOS
PXC简介 Percona XtraDB Cluster(简称PXC集群)提供了MySQL高可用的一种实现方法. 1.集群是有节点组成的,推荐配置至少3个节点,但是也可以运行在2个节点上. 2.每个节 ...
- 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 ...
- PXC(Percona XtraDB Cluster)集群的安装与配置
Percona XtraDB Cluster是针对MySQL用户的高可用性和扩展性解决方案,基于Percona Server .其包括了Write Set REPlication补丁,使用Galera ...
- mysql高可用之PXC(Percona XtraDB Cluster)
简介 Percona XtraDB Cluster是MySQL高可用性和可扩展性的解决方案,Percona XtraDB Cluster提供的特性如下: 1).同步复制,事务要么在所有节点提交或不提交 ...
- PXC5.7(Percona XtraDB Cluster)+HAproxy+Keepalived 集群部署
Percona-XtraDB-Cluster+Haproxy 搭建集群环境 环境准备及服务器信息: 配置防火墙 firewall-cmd --add-port=3306/tcp --permanent ...
- MySQL高可用方案-PXC(Percona XtraDB Cluster)环境部署详解
MySQL高可用方案-PXC(Percona XtraDB Cluster)环境部署详解 Percona XtraDB Cluster简称PXC.Percona Xtradb Cluster的实现是在 ...
- Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication
Percona XtraDB Cluster vs Galera Cluster vs MySQL Group Replication Overview Galera Cluster 由 Coders ...
随机推荐
- Android从一个Fragment跳转到另一个Fragment后原来的组件不消失
问题描述 Activity上放置了一个Fragment,Fragment上有按钮,点了按钮后,应该跳转到另一个Fragment, but 原来的Fragment的按钮不会消失,新的Fragment不是 ...
- 线性反馈移位寄存器(LFSR)
LFSR用于产生可重复的伪随机序列PRBS,该电路有n级触发器和一些异或门组成,如下图所示. 其中,gn为反馈系数,取值只能为0或1,取为0时表明不存在该反馈之路,取为1时表明存在该反馈之路:这里的反 ...
- 技能篇:git的简易教程
在学校,或许凭借一个人的力量就能负责整个项目的开发到上线.但是在公司,因为项目的复杂性和紧急性,一个项目的往往是由多个人实现,此时就有一个问题,代码提交和代码合并.git和svn,这篇文章来讲讲git ...
- 手写Pascal解释器(三)
目录 一.part7 抽象语法树和具体语法树(解析树) 代码实现 二.part8 一.part7 资料来源:https://ruslanspivak.com/lsbasi-part7/ 看作者博客的标 ...
- selenium元素定位之 动态id, class元素定位
1.直接进入正题 如下图, 有些元素每次进入都会刷新, 造成元素无法重复定位 怎么办? "xpath部分属性值"定位方法可以帮到我们 1.包含属性定位 driver.find_el ...
- 身边好几个技术一般的程序员都面上了,阿里P7门槛降低?
经常在网上的论坛里看到讨论程序员的级别,尤其在跳槽类的信息里可以看到对标阿里P7,百度T6,腾讯3.1等字眼,似乎大厂的级别俨然可以成为业内的通用货币,类似于高考分数一样,哪一档就对应着什么样的待遇. ...
- 知乎1578赞:Android 中为什么需要 Handler?
要理解 Handler,就得先理解 Android 的 Message 机制. 这里以用户滑动微信朋友圈为例,讲解一下 Android 的 Message 机制是怎么运行的,Message 机制中的各 ...
- 用AutoHotkey做汉字到Unicode字符串的转换
要把汉字转换为搜的形式,也就是在汉字的Unicode Big Endian编码前面加"&#x",后面加分号.例如""字转换后为"搜" ...
- canvas也能实现事件系统????
前言 大家好! 我是热爱图形的fly, 之前在群里和粉丝讨论canvas 如何事件系统, 然后呢? 我自己其实也对这个比较感兴趣, 我看过很多canvas 实现的项目, 比如canvas 实现思维导图 ...
- awk-05-数组
数组 数组: 存储一系列相同类型的元素,键/值方式存储,通过下标(键)来访问值 awk 中数组称为关联数组,不仅可以使用数字作为下标,还可以使用字符串作为下标 数组元素的键和值存储在 awk 程序内部 ...