0

0

PXC(PerconaXtraDBCluster)集群安装

php中文网

php中文网

发布时间:2016-06-07 16:10:38

|

2256人浏览过

|

来源于php中文网

原创

作者在2014oracle数据库嘉年华中有幸听到了关于去哪网的mysql数据库基于pxc的高可用架构设计主题。 MySQL和Oracle是完全不同的两种数据库,Oracle重于管理,而MySQL更重要的是架构设计。笔者对MySQL以及新技术也是充满了好奇,索性回来自己搭建一个测试环境

作者在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 ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 7

Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023


Copyright (c) 2009-2014 Percona LLC and/or its affiliates

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


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 dexdb

Database changed

mysql> 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 ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023


Copyright (c) 2009-2014 Percona LLC and/or its affiliates

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


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 1

mysql> show databases ;

+--------------------+

| Database           |

+--------------------+

| information_schema |

| dexdb              |

| mysql              |

| performance_schema |

| test               |

+--------------------+

5 rows in set (0.01 sec)


mysql> use dexdb

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Database changed

mysql> select * from dextb ;

+------+------+

| id   | name |

+------+------+

|    1 | 22   |

|    1 | 22   |

+------+------+

2 rows in set (0.00 sec)





[root@pxc3 ~]# service mysql start

MySQL (Percona XtraDB Cluster) is not running, but lock file (/var/lock/subsys/mysql) exists[FAILED]

Starting MySQL (Percona XtraDB Cluster).....[  OK  ]

[root@pxc3 ~]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 6

Server version: 5.5.39-36.0-55 Percona XtraDB Cluster (GPL), Release rel36.0, Revision 824, WSREP version 25.11, wsrep_25.11.r4023


Copyright (c) 2009-2014 Percona LLC and/or its affiliates

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> use dexdb

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A


Database changed

mysql> select * from dextb ;

+------+------+

| id   | name |

+------+------+

|    1 | 22   |

|    1 | 22   |

+------+------+

2 rows in set (0.00 sec)


热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
微信文件过期恢复教程
微信文件过期恢复教程

本专题整合了微信文件过期恢复方法、技巧教程,阅读专题下面的文章了解更多详细内容。

0

2026.02.04

抖音网页版入口与视频观看指南 抖音官网视频在线访问
抖音网页版入口与视频观看指南 抖音官网视频在线访问

本专题汇总了抖音网页版的入口链接、官方登录页面以及视频观看入口,帮助用户快速访问抖音网页版,提供免登录访问方式和直接进入视频播放页面的方法,确保顺利浏览和观看抖音视频。

63

2026.02.04

学习通网页版入口与在线学习指南 学习通官网登录与使用方法
学习通网页版入口与在线学习指南 学习通官网登录与使用方法

本专题详细汇总了学习通网页版入口与登录方法,提供学习通官方网页端入口、学生登录平台、网页版使用指南等内容,帮助用户快速稳定地登录学习通官网,顺利进入学习平台,提升学习效率和体验。

9

2026.02.04

Python Web 框架 Django 深度开发
Python Web 框架 Django 深度开发

本专题系统讲解 Python Django 框架的核心功能与进阶开发技巧,包括 Django 项目结构、数据库模型与迁移、视图与模板渲染、表单与认证管理、RESTful API 开发、Django 中间件与缓存优化、部署与性能调优。通过实战案例,帮助学习者掌握 使用 Django 快速构建功能全面的 Web 应用与全栈开发能力。

9

2026.02.04

Java 流式处理与 Apache Kafka 实战
Java 流式处理与 Apache Kafka 实战

本专题专注讲解 Java 在流式数据处理与消息队列系统中的应用,系统讲解 Apache Kafka 的基础概念、生产者与消费者模型、Kafka Streams 与 KSQL 流式处理框架、实时数据分析与监控,结合实际业务场景,帮助开发者构建 高吞吐量、低延迟的实时数据流管道,实现高效的数据流转与处理。

3

2026.02.04

Golang 容器化与 Docker 实战
Golang 容器化与 Docker 实战

本专题深入讲解 Golang 应用的容器化与 Docker 部署,涵盖 Docker 基础概念、容器构建与镜像管理、Go 应用的 Dockerfile 编写、跨平台容器部署与优化、Docker Compose 和 Kubernetes 部署工具。通过实际案例,帮助学习者掌握 如何将 Golang 应用容器化并实现高效部署与管理,提升系统的可扩展性与运维效率。

3

2026.02.04

全国统一发票查询平台入口合集
全国统一发票查询平台入口合集

本专题整合了全国统一发票查询入口地址合集,阅读专题下面的文章了解更多详细入口。

59

2026.02.03

短剧入口地址汇总
短剧入口地址汇总

本专题整合了短剧app推荐平台,阅读专题下面的文章了解更多详细入口。

110

2026.02.03

植物大战僵尸版本入口地址汇总
植物大战僵尸版本入口地址汇总

本专题整合了植物大战僵尸版本入口地址汇总,前往文章中寻找想要的答案。

56

2026.02.03

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
TypeScript 教程
TypeScript 教程

共19课时 | 2.7万人学习

Pandas 教程
Pandas 教程

共15课时 | 1万人学习

关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号