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 ...
随机推荐
- TCP协议与HTTP协议区别
一.TCP协议与HTTP协议区别 1.直观认识 TCP协议对应于传输层,而HTTP协议对应于应用层,从本质上来说,二者没有可比性.Http协议是建立在TCP协议基础之上的,当浏览器需要从服务器获取网页 ...
- C++第五十二篇 -- 多线程之消息传递
主线程向子线程发送消息 参考链接:https://www.cnblogs.com/ranjiewen/p/5729539.html 1. 创建线程语句 HANDLE hThread; DWORD dw ...
- ZooKeeper(2181、2171) 未授权访问
下载地址http://archive.apache.org/dist/zookeeper/zookeeper-3.4.14/ tar -xzvf zookeeper-3.4.14.tar.gz cd ...
- 用KeePass管理密码并用Synology_Drive或者GoodSync实时双向同步电脑桌面和群晖NAS2021年8月5日
用KeePass管理密码并用Synology_Drive或者GoodSync实时双向同步电脑桌面和群晖NAS2021年8月5日 我通常会把所有办公文档.办公表格和办公图片都实时同步保存到 Synolo ...
- C++手写内存池
引言 使用new expression为类的多个实例分配动态内存时,cookie导致内存利用率可能不高,此时我们通过实现类的内存池来降低overhead.从不成熟到巧妙优化的内存池,得益于union的 ...
- 软件安装管理(RPM)
目录 一.linux应用程序 1.1 应用程序与系统命令关系 1.2 典型应用程序的目录结构 1.3 常见的软件包封装工具 二.RPM软件包管理工具 2.1RPM软件包管理器Red-Hat Packa ...
- 干了5年Android开发,突然感觉自己啥也不会,啥也不想干,还要继续吗?
这是在某论坛看到的一名同行的吐槽: 我干了差不多5年,不过给人感觉跟只有两三年的人一样. 我觉得我不适合干程序员,主要是新东西的接受能力比其他人慢,Android技术又更新得很快,感觉总是跟不上.年纪 ...
- 1549页Android最新面试题含答案
在今年年初的疫情中,成了失业人员之一,于是各种准备面试,发现面试题网上很多,但是都是很凌乱的,而且一个地方一点,没有一个系统的面试题库,有题库有的没有答案或者是答案很简洁,没有达到面试的要求.所以一直 ...
- CentOS后台服务管理类
目录 一.service 后台服务管理(临时,只对当前有效) 二.chkconfig 设置后台服务的自启配置(永久) 三.CentOS7 后添加的命令:systemctl 一.service 后台服务 ...
- 数据结构与算法-排序(七)希尔排序(Shell Sort)
摘要 看希尔排序需要先想象出一个二维的矩阵,在这个矩阵中,有多少列数据全看步长(一定的规则得到).处理完之后,就再接着用另一个步长组成矩阵处理.直到步长全部使用完. 这里的巧妙之处就是没有把序列先处理 ...