pxc群集搭建

1.环境

Percona-XtraDB 5.7.22-22-29.26-log

percona-xtrabackup-24-2.4.12

192.168.99.210:3101(第一节点)

192.168.99.211:3101

192.168.99.212:3101

2.安装

\\安装依赖包
yum install -y git scons gcc gcc-c++ openssl check cmake bison boost-devel asio-devel libaio-devel ncurses-devel readline-devel pam-devel socat \\安装xtrabackup
yum localinstall percona-xtrabackup-24-2.4.12-1.el7.x86_64.rpm
tar -xzvf tarball/Percona-XtraDB-Cluster-5.7.22-rel22-29.26.1.Linux.x86_64.ssl102.tar.gz /opt/ ln -s /opt/Percona-XtraDB-Cluster-5.7.22-rel22-29.26.1.Linux.x86_64.ssl102/ /usr/local/pxc

3.初始化第一节点

mkdir /data/pxc/mysql3101/{data,logs,tmp}
chown -R mysql:mysql /data/pxc/*
ln -s /data/pxc/mysql3101/ /3101
loose_wsrep_cluster_name=pxc_wenyz
loose_wsrep_cluster_address=gcomm://192.168.99.210,192.168.99.211,192.168.99.212
loose_wsrep_node_address=192.168.99.210
#//建议将原SST使用的4444端口改为其他端口,因为4444是msblast蠕虫病毒使用端口,在有云安全产品下可能会被拦截.
wsrep_sst_receive_address =192.168.99.210:4588
loose_wsrep_provider=/usr/local/pxc/lib/libgalera_smm.so
#wsrep_sst_method=reync
loose_wsrep_sst_method=xtrabackup-v2
loose_wsrep_sst_auth=sst:zstxxx
  • 初始化实例和启动
初始化:/usr/local/pxc/bin/mysqld --defaults-file=/3101/my_pxc.cnf --initialize-insecure
启动:
/usr/local/pxc/bin/mysqld --defaults-file=/3101/my_pxc.cnf --wsrep-new-cluster&
  • 创建sst账号:
\\登录mysql
GRANT RELOAD, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'sst'@'%' identified by 'zstxxx';

4.其他节点

其他节点不用初始化,直接启动就可以.但启动过程中会遇到很多报错,需要逐一排除.

/usr/local/pxc/bin/mysqld --defaults-file=/3101/my_pxc.cnf&
  • 成功加入的过程(第二节点)
刚启动时监听端口状态:
#netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4588(SST) 0.0.0.0:* LISTEN 22451/socat
tcp 0 0 0.0.0.0:3508 0.0.0.0:* LISTEN 16289/mysqld
tcp 0 0 0.0.0.0:4567(PXC通信) 0.0.0.0:* LISTEN 21978/mysqld [root@db212_08:58:42 /3101] \\节点初始化完成后的端监听状态:
#netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:4567 0.0.0.0:* LISTEN 22431/mysqld
tcp6 0 0 :::3101 (mysql) :::* LISTEN 22431/mysqld
  • 登录节点查看状态:
root@localhost [(none)]>show global status like 'wsrep_%';
+----------------------------------+------------------------------------------------------------------+
| Variable_name | Value |
+----------------------------------+------------------------------------------------------------------+
| wsrep_local_state_uuid | 8c3106bd-9a40-11e8-8088-822c237073c1 |
| wsrep_protocol_version | 8 |
| wsrep_last_applied | 6 |
| wsrep_last_committed | 6 |
| wsrep_replicated | 1 |
| wsrep_replicated_bytes | 400 |
| wsrep_repl_keys | 2 |
| wsrep_repl_keys_bytes | 40 |
| wsrep_repl_data_bytes | 295 |
| wsrep_repl_other_bytes | 0 |
| wsrep_received | 40 |
| wsrep_received_bytes | 5939 |
| wsrep_local_commits | 0 |
| wsrep_local_cert_failures | 0 |
| wsrep_local_replays | 0 |
| wsrep_local_send_queue | 0 |
| wsrep_local_send_queue_max | 2 |
| wsrep_local_send_queue_min | 0 |
| wsrep_local_send_queue_avg | 0.250000 |
| wsrep_local_recv_queue | 0 |
| wsrep_local_recv_queue_max | 1 |
| wsrep_local_recv_queue_min | 0 |
| wsrep_local_recv_queue_avg | 0.000000 |
| wsrep_local_cached_downto | 5 |
| wsrep_flow_control_paused_ns | 0 |
| wsrep_flow_control_paused | 0.000000 |
| wsrep_flow_control_sent | 0 |
| wsrep_flow_control_recv | 0 |
| wsrep_flow_control_interval | [ 173, 173 ] |
| wsrep_flow_control_interval_low | 173 |
| wsrep_flow_control_interval_high | 173 |
| wsrep_flow_control_status | OFF |
| wsrep_cert_deps_distance | 1.000000 |
| wsrep_apply_oooe | 0.000000 |
| wsrep_apply_oool | 0.000000 |
| wsrep_apply_window | 1.000000 |
| wsrep_commit_oooe | 0.000000 |
| wsrep_commit_oool | 0.000000 |
| wsrep_commit_window | 1.000000 |
| wsrep_local_state | 4 |
| wsrep_local_state_comment | Synced |
| wsrep_cert_index_size | 2 |
| wsrep_cert_bucket_count | 22 |
| wsrep_gcache_pool_size | 336152 |
| wsrep_causal_reads | 0 |
| wsrep_cert_interval | 0.000000 |
| wsrep_ist_receive_status | |
| wsrep_ist_receive_seqno_start | 0 |
| wsrep_ist_receive_seqno_current | 0 |
| wsrep_ist_receive_seqno_end | 0 |
| wsrep_incoming_addresses | 192.168.99.212:3101,192.168.99.211:3101,192.168.99.210:3101 |
| wsrep_desync_count | 0 |
| wsrep_evs_delayed | 2c3c416a-9aa6-11e8-a518-77bd362692b0:tcp://192.168.99.212:4567:1 |
| wsrep_evs_evict_list | |
| wsrep_evs_repl_latency | 0/0/0/0/0 |
| wsrep_evs_state | OPERATIONAL |
| wsrep_gcomm_uuid | 8d6121e1-9a42-11e8-98e7-6b000d25448a |
| wsrep_cluster_conf_id | 29 |
| wsrep_cluster_size | 3 |
| wsrep_cluster_state_uuid | 8c3106bd-9a40-11e8-8088-822c237073c1 |
| wsrep_cluster_status | Primary |
| wsrep_connected | ON |
| wsrep_local_bf_aborts | 0 |
| wsrep_local_index | 1 |
| wsrep_provider_name | Galera |
| wsrep_provider_vendor | Codership Oy <info@codership.com> |
| wsrep_provider_version | 3.26(r) |
| wsrep_ready | ON |
+----------------------------------+------------------------------------------------------------------+
68 rows in set (0.00 sec) root@localhost [(none)]>

5.遇到过的报错

  • [ERROR] socat not found
  • 解决办法:yum install -y socat
29.26.1.Linux.x86_64.ssl102/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
2018-08-07T04:25:23.504726Z WSREP_SST: [ERROR] ******************* FATAL ERROR **********************
2018-08-07T04:25:23.505847Z WSREP_SST: [ERROR] socat not found in path: /usr/sbin:/sbin:/opt/Percona-XtraDB-Cluster-5.7.22-rel22-29.26.1.Linux.x86_64.ssl102/bin:/usr/local/mysql/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
2018-08-07T04:25:23.506926Z WSREP_SST: [ERROR] ******************************************************
2018-08-07T04:25:23.507286Z 0 [ERROR] WSREP: Failed to read 'ready <addr>' from: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.99.210' --datadir '/3101/data/' --defaults-file '/3101/my_pxc.cnf' --defaults-group-suffix '' --parent '20904' ''
Read: '(null)'
2018-08-07T04:25:23.507316Z 0 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.99.210' --datadir '/3101/data/' --defaults-file '/3101/my_pxc.cnf' --defaults-group-suffix '' --parent '20904' '' : 2 (No such file or directory)
2018-08-07T04:25:23.507360Z 1 [ERROR] WSREP: Failed to prepare for 'xtrabackup-v2' SST. Unrecoverable.
2018-08-07T04:25:23.507371Z 1 [ERROR] Aborting
  • Possible timeout in receving first data from donor in gtid/keyring stage

    在donor的error.log里查看发现无法连接192.168.99.211:4444 将4444改为其他端口即可解决
2018-08-07T04:50:52.153284Z 0 [Note] WSREP: gcomm: closing backend
2018-08-07T04:50:52.758009Z WSREP_SST: [ERROR] ******************* FATAL ERROR **********************
2018-08-07T04:50:52.759154Z WSREP_SST: [ERROR] Possible timeout in receving first data from donor in gtid/keyring stage
2018-08-07T04:50:52.760273Z WSREP_SST: [ERROR] ******************************************************
2018-08-07T04:50:52.761583Z WSREP_SST: [ERROR] Cleanup after exit with status:32
2018-08-07T04:50:54.579876Z 0 [Note] WSREP: (756ee09e, 'tcp://0.0.0.0:4567') turning message relay requesting off
2018-08-07T04:50:55.579830Z 0 [Note] WSREP: (756ee09e, 'tcp://0.0.0.0:4567') connection to peer b83607a8 with addr tcp://192.168.99.210:4567 timed out, no messages seen in PT3S (gmcast.peer_timeout)
2018-08-07T04:50:55.579922Z 0 [Note] WSREP: (756ee09e, 'tcp://0.0.0.0:4567') turning message relay requesting on, nonlive peers: tcp://192.168.99.210:4567
2018-08-07T04:50:57.079838Z 0 [Note] WSREP: (756ee09e, 'tcp://0.0.0.0:4567') reconnecting to b83607a8 (tcp://192.168.99.210:4567), attempt 0
2018-08-07T04:50:57.653421Z 0 [Note] WSREP: declaring node with index 1 suspected, timeout PT5S (evs.suspect_timeout)
2018-08-07T04:50:57.653448Z 0 [Note] WSREP: evs::proto(756ee09e, LEAVING, view_id(REG,756ee09e,20)) suspecting node: b83607a8
2018-08-07T04:50:57.653457Z 0 [Note] WSREP: evs::proto(756ee09e, LEAVING, view_id(REG,756ee09e,20)) suspected node without join message, declaring inactive
2018-08-07T04:50:57.653484Z 0 [Note] WSREP: Current view of cluster as seen by this node
view (view_id(NON_PRIM,756ee09e,20)
  • Possible timeout in receving first data from donor in gtid/keyring

    解决办法 :yum install -y git scons gcc gcc-c++ openssl check cmake bison boost-devel asio-devel libaio-devel ncurses-devel readline-devel pam-devel socat
018-08-07T12:05:49.545630Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:50.313182Z WSREP_SST: [ERROR] ******************* FATAL ERROR **********************
2018-08-07T12:05:50.314371Z WSREP_SST: [ERROR] Possible timeout in receving first data from donor in gtid/keyring stage
2018-08-07T12:05:50.315523Z WSREP_SST: [ERROR] ******************************************************
2018-08-07T12:05:50.316914Z WSREP_SST: [ERROR] Cleanup after exit with status:32
2018-08-07T12:05:50.326100Z 0 [ERROR] WSREP: Process completed with error: wsrep_sst_xtrabackup-v2 --role 'joiner' --address '192.168.99.212:4588' --datadir '/3101/data/' --defaults-file '/3101/my_pxc.cnf' --defaults-group-suffix '' --parent '17660' '' : 32 (Broken pipe)
2018-08-07T12:05:50.326134Z 0 [ERROR] WSREP: Failed to read uuid:seqno from joiner script.
2018-08-07T12:05:50.326146Z 0 [ERROR] WSREP: SST script aborted with error 32 (Broken pipe)
2018-08-07T12:05:50.326182Z 0 [ERROR] WSREP: SST failed: 32 (Broken pipe)
2018-08-07T12:05:50.326202Z 0 [ERROR] Aborting 2018-08-07T12:05:50.326207Z 0 [Note] WSREP: Signalling cancellation of the SST request.
2018-08-07T12:05:50.326239Z 0 [Note] WSREP: SST request was cancelled
2018-08-07T12:05:50.546015Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:51.546468Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:52.546924Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:53.547325Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:54.547722Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:55.548121Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:56.548496Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:57.548894Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:58.549273Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:05:59.549743Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable
2018-08-07T12:06:00.550210Z 0 [Warning] WSREP: Member 2.0 (db212) requested state transfer from '*any*', but it is impossible to select State Transfer donor: Resource temporarily unavailable

pxc群集搭建的更多相关文章

  1. MySQL集群PXC的搭建

    MySQL集群PXC的搭建 最近公司某客户要求我们的数据库搭建PXC集群以保证他们的系统高性能和搞稳定性 以后花费了一些时间去搭建和测试,也踩过一些坑,准备分享出来 系统:centos6.6PXC:5 ...

  2. 数据库_MHA群集搭建

    MHA概念介绍,群集搭建与测试 一, MHA介绍 1.概念:MHA master high availability,由日本DeNA公司开发,解决mysql故障切换可以做到0-30秒,而且在故障切换过 ...

  3. 基于Ubuntu Hadoop的群集搭建Hive

    Hive是Hadoop生态中的一个重要组成部分,主要用于数据仓库.前面的文章中我们已经搭建好了Hadoop的群集,下面我们在这个群集上再搭建Hive的群集. 1.安装MySQL 1.1安装MySQL ...

  4. Nginx+Tomcat+Session 高性能群集搭建

    随着IT行业的发展,linux服务器在企业中应用广泛,人们对linux上的应用服务要求也越来越高,早先的apache服务器.apache有优点也 有不足,apache渐渐不能满足人们的要求,目前ngi ...

  5. 超详细干货!Docker+PXC+Haproxy搭建高可用强一致性的MySQL集群

    前言 干货又来了,全程无废话,可先看目录了解. MySQL搭建集群最常见的是binlog方式,但还有一种方式是强一致性的,能保证集群节点的数据一定能够同步成功,这种方式就是pxc,本篇就使用图文方式一 ...

  6. Redis + keepalived 高可用群集搭建

    本次实验环境介绍: 操作系统: Centos 7.3 IP : 192.168.10.10 Centos 7.3 IP : 192.168.10.20  VIP    地址   : 192.168.1 ...

  7. Docker搭建MySQL的PXC集群

    原文:Docker搭建MySQL的PXC集群 一.简介 PXC属于一套近乎完美的mysql高可用集群解决方案,相比那些比较传统的基于主从复制模式的集群架构MHA和MM+keepalived,galer ...

  8. 数据库_PXC群集与存储引擎

    1. PXC介绍与群集搭建; 2.数据存储引擎. 一, PXC介绍 1.介绍 PXC(Percona XtraDB Cluster)基于Galara的一台开源软件,应用于解决mysql的高可用集群问题 ...

  9. Hyper-V 2012 R2 故障转移群集

    和终端用户相比,企业用户对于业务的连续性和可靠性更为在意.相对而言,企业一般不会将追逐单一硬件的性能排在第一位. 如何衡量业务是否持续可用,一般使用"x 个 9"这种方式来定义.如 ...

随机推荐

  1. 使用mac电脑,对Github客户端的简单操作1----开源项目

    工作之余自己也会一写一些小的程序项目,由于一直没时间“折腾”开源,之前写博客都是直接粘代码片段,今天看别人写技术博客大都会放出项目Github地址,突然感觉自己有点点out and low,作为一个励 ...

  2. 【bzoj2763】[JLOI2011]飞行路线 分层图最短路

    题目描述 Alice和Bob现在要乘飞机旅行,他们选择了一家相对便宜的航空公司.该航空公司一共在n个城市设有业务,设这些城市分别标记为0到n-1,一共有m种航线,每种航线连接两个城市,并且航线有一定的 ...

  3. 【bzoj1029】[JSOI2007]建筑抢修 贪心+堆

    题目描述 小刚在玩JSOI提供的一个称之为“建筑抢修”的电脑游戏:经过了一场激烈的战斗,T部落消灭了所有z部落的入侵者.但是T部落的基地里已经有N个建筑设施受到了严重的损伤,如果不尽快修复的话,这些建 ...

  4. 【bzoj1738】[Usaco2005 mar]Ombrophobic Bovines 发抖的牛 Floyd+二分+网络流最大流

    题目描述 FJ's cows really hate getting wet so much that the mere thought of getting caught in the rain m ...

  5. Python 日志输出中添加上下文信息

    Python日志输出中添加上下文信息 除了传递给日志记录函数的参数(如msg)外,有时候我们还想在日志输出中包含一些额外的上下文信息.比如,在一个网络应用中,可能希望在日志中记录客户端的特定信息,如: ...

  6. CF#508 1038E Maximum Matching

    ---题面--- 题解: 感觉还是比较妙的,复杂度看上去很高(其实也很高),但是因为n只有100,所以还是可以过的. 考虑一个很暴力的状态f[i][j][x][y]表示考虑取区间i ~ j的方格,左右 ...

  7. 【CKplayer】使用CKplayer插件在网页中嵌入视频的方法

    在做网站中有时候我们需要在网页中嵌入视频,一般视频嵌入有以下几种方法: 1. 优酷代码嵌入 优点:简单,方便,可靠. 缺点:有广告,现在的网站非常注重用户体验,如果打开一个在线视频是有长广告的一定会崩 ...

  8. BZOJ4568:[SCOI2016]幸运数字——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=4568 https://www.luogu.org/problemnew/show/P3292 A ...

  9. HTML5 canvas 创意:飞翔的凤凰

    当我看到这件作品的时候,我表示非常喜欢.这个作品的产生不仅仅需要编程和算法,作者肯定是个充满了艺术细胞的人.倘若有什么canvas艺术作品比赛的话,我想它就是获奖的那个. 先观赏下演示吧.注意,要看到 ...

  10. IntelliJ IDEA 详细图解最常用的配置 ,适合新人,解决eclipse转idea的烦恼

    刚刚使用IntelliJ IDEA 编辑器的时候,会有很多设置,会方便以后的开发,磨刀不误砍柴工. 比如:设置文件字体大小,代码自动完成提示,版本管理,本地代码历史,自动导入包,修改注释,修改tab的 ...