作者在2014Oracle数据库嘉年华中有幸听到了关于去哪网的MySQL数据库基于PXC的高可用架构设计主题。

MySQL和Oracle是完全不同的两种数据库,Oracle重于管理,而MySQL更重要的是架构设计。笔者对MySQL以及新技术也是充满了好奇,索性回来自己搭建一个测试环境。

操作系统:CentOS 6.6

软件版本:5.5.39-36.0-55 PerconaXtraDB Cluster (GPL)

节点信息:

pxc1 192.168.0.200
pxc2 192.168.0.201
pxc3 192.168.0.202

安装过程

安装PXC,这里使用的是Percona以及EPEL的官方repositories :

http://www.percona.com/doc/percona-server/5.5/installation/yum_repo.html?id=repositories:yum

http://fedoraproject.org/wiki/EPEL

yum installhttp://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
yum installhttp://mirrors.ustc.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
yum -y install Percona-XtraDB-Cluster-serverPercona-XtraDB-Cluster-client Percona-Server-shared-compat percona-xtrabackup

每台机器开启PXC,之后添加SST账户:

DELETE FROM mysql.user WHERE user='';
GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'sstuser'@'localhost' IDENTIFIED BY 'sstuser';;
FLUSH PRIVILEGES;

每个节点关闭PXC。编辑第一个节点的PXC设置。

[mysqld]
server_id=1
wsrep_provider=/usr/lib64/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.0.200,192.168.0.201,192.168.0.202"
wsrep_sst_auth=sstuser:sstuser
wsrep_provider_options="gcache.size=4G"
wsrep_cluster_name=Percona
wsrep_sst_method=xtrabackup
wsrep_node_name=pxc1
wsrep_slave_threads=4
log_slave_updates
innodb_locks_unsafe_for_binlog=1
innodb_autoinc_lock_mode=2

开启第一个节点(如果集群关闭,每次拥有正确信息的节点使用此命令开启集群)

[root@pxc1 ~]# service mysql bootstrap-pxc
Bootstrapping PXC (Percona XtraDBCluster)Starting MySQL (Percona XtraDB Cluster)..[  OK  ]

编辑另外两个节点的my.cnf配置文件需要修改的内容:

server_id=2
wsrep_node_name=pxc2

将其他两个节点加入到集群中

service mysql start

至此,集群安装结束。

遇到的问题

以下是配置过程中的报错信息以及解决方法:

现象:

开启PXC节点的时候遇到

Failed to read output of: 'ip addr show | grep -E '^[ ]*inet' | grep -m1global | awk '{ print $2 }' | sed -e 's/\/.*//''
........
141120 22:46:35 [ERROR] WSREP: Permission denied
141120 22:46:35 [ERROR] WSREP: failed to open gcomm backend connection: 13:error while trying to listen 'tcp://0.0.0.0:4567?socket.non_blocking=1', asioerror 'Permission denied': 13 (Permission denied)

原因:

由于开启了SELINUX。

解决方法:

编辑文件/etc/sysconfig/selinux

把SELINUX设为disabled

重启后就会忽略selinux,或者直接执行命令

setenforce 0

立即生效。

现象:

添加节点到集群中的时候遇到

last inactive check morethan PT1.5S ago (PT3.50529S), skipping check

卡在这里

原因:

iptables

解决方法:

关闭iptables

chkconfig iptables off

service iptables stop

简单测试

[root@pxc1 ~]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 7Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023Copyright (c) 2009-2014 Percona LLC and/or its affiliatesCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show global status like 'wsrep_cluster_size';+--------------------+-------+| Variable_name      | Value |+--------------------+-------+| wsrep_cluster_size | 2     |+--------------------+-------+1 row in set (0.00 sec)mysql> show global status like 'wsrep_cluster_size';+--------------------+-------+| Variable_name      | Value |+--------------------+-------+| wsrep_cluster_size | 3     |+--------------------+-------+1 row in set (0.00 sec)mysql> create database dexdb ;Query OK, 1 row affected (0.01 sec)mysql> use dexdbDatabase changedmysql> create table dextb (id int ,name char(10))  engine=innodb ;Query OK, 0 rows affected (0.03 sec)mysql> insert into dextb values (1,'22') ;Query OK, 1 row affected (0.01 sec)mysql> insert into dextb values (1,'22') ;Query OK, 1 row affected (0.00 sec)mysql> commit ;Query OK, 0 rows affected (0.00 sec)mysql> select * from dextb ;+------+------+| id   | name |+------+------+|    1 | 22   ||    1 | 22   |+------+------+2 rows in set (0.00 sec)[root@pxc2 ~]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023Copyright (c) 2009-2014 Percona LLC and/or its affiliatesCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> show database ;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'database' at line 1mysql> show databases ;+--------------------+| Database           |+--------------------+| information_schema || dexdb              || mysql              || performance_schema || test               |+--------------------+5 rows in set (0.01 sec)mysql> use dexdbReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select * from dextb ;+------+------+| id   | name |+------+------+|    1 | 22   ||    1 | 22   |+------+------+2 rows in set (0.00 sec)[root@pxc3 ~]# service mysql startMySQL (Percona XtraDB Cluster) is not running, but lock file (/var/lock/subsys/mysql) exists[FAILED]Starting MySQL (Percona XtraDB Cluster).....[  OK  ][root@pxc3 ~]# mysqlWelcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 6Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023Copyright (c) 2009-2014 Percona LLC and/or its affiliatesCopyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use dexdbReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select * from dextb ;+------+------+| id   | name |+------+------+|    1 | 22   ||    1 | 22   |+------+------+2 rows in set (0.00 sec)

PXC(Percona XtraDB Cluster)集群安装相关推荐

  1. Percona XtraDB Cluster 集群参数配置说明(PXC 5.7)

    从PXC5.7版本开始,集群的配置主要是通过wsrep.cnf配置来实现.这个文件有几个常用的参数配置.下文对其做简要说明. 一.PXC 5.7集群配置文件 如果是直接通过yum方式安装,那么配置文件 ...

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

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

  3. redis cluster 集群 安装 配置 详解

    redis cluster 集群 安装 配置 详解 张映 发表于 2015-05-01 分类目录: nosql 标签:cluster, redis, 安装, 配置, 集群 Redis 集群是一个提供在 ...

  4. mysql pxc galera_PXC / Galera Cluster集群概述及原理分析

    mariadb的galera cluster集群抄袭percona的PXC数据库集群,所以原理一样 ### Galera Cluster/ PXC 集群工作原理 client端向server端发送dm ...

  5. 阿里 mysql cluster_MySQL Cluster集群安装及使用-阿里云开发者社区

    MySQL Cluster MySQL集群 Linux最新版本7.3.2 文件 大小 md5 mysqlcluster-7.3.2-linux-x32.tar.gz 431.0MB 03093541b ...

  6. 深入分析redis cluster 集群安装配置详解

    Redis 集群是一个提供在多个Redis间节点间共享数据的程序集.redis3.0以前,只支持主从同步的,如果主的挂了,写入就成问题了.3.0出来后就可以很好帮我们解决这个问题. 目前redis 3 ...

  7. MySQL高可用架构之Percona XtraDB Cluster

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

  8. Mysql搭建PXC集群 - Percona XtraDB Cluster

    转载来源:https://blog.csdn.net/lvshaorong/article/details/80501905  pxc集群是Percona XtraDB Cluster的缩写,是基于p ...

  9. Percona XtraDB Cluster(PXC) Mysql 集群

    Percona XtraDB Cluster(PXC)   ---原理介绍篇         目录 一.简介 1 二.优缺点 2 三.区别/局限性 3 四. PXC复制原理 4 五. 服务解释 5   ...

最新文章

  1. git常用命令,分支操作,子模块
  2. While executing gem ... (Errno::EACCES)
  3. oracle的逻辑结构包括,oracle逻辑结构分析
  4. TensorFlow从入门到理解(六):可视化梯度下降
  5. 假如正则从来没来过,我们该如何去匹配一个字符串?
  6. (python初学者)利用python画简单几何图形
  7. sqlmap挂马命令
  8. 软件测试周刊(第50期):归结起来,焦虑的原因就两条:想同时做很多事情,又想立即看到效果。
  9. 多种多样的语音连麦方式
  10. 计算商品总金额以及购物券总金额
  11. WHQL认证环境部署攻略四  结果查看测试报告
  12. 堆和栈的区别 之 数据结构和内存
  13. 忆阻蔡氏电路matlab,基于有源带通滤波器的忆阻蔡氏电路研究.doc
  14. [转]Linux: 结束查看进程命令
  15. 如何从零开始搭建高性能直播平台?
  16. 2020春招---飞鱼科技 一面面经
  17. 计算机视觉自学进阶路上不可忽略的几个原创公众号
  18. Django-图片服务器-流程梳理
  19. 去除龙卷风收音机软件界面下广告的方法
  20. 用Compose来搞个水墨画效果吧

热门文章

  1. 靠一个微信小程序挣了 10.7 万(文末赠书)
  2. LeetCode题库第67题二进制求和
  3. python request下载word,下载word文档python
  4. 解决ORCLE-ORA-01122 01110 01210
  5. 免费和收费都只是形式 网文阅读最终还是比生态?
  6. android饺子视频去掉记忆播放
  7. 在UE4中实现虚函数
  8. 服务器跟虚拟主机,云服务器跟虚拟主机有什么区别
  9. 禁止屏幕滚动-开启屏幕滚动
  10. MATLAB车道线偏离预警设计[可增加GUI,预警,偏离参数等]