Mysql集群的搭建___PXC集群
之前我们介绍了MHA集群,那么为什么还要介绍PXC集群呢
这就涉及到了MHA集群维护中的一些缺点:
1 管理服务监控到主服务器宕机服务会自动停止
2 宕机的服务器再添加到集群里,要手动配置主从及同步数据
3 客户端连接访问的是VIP地址
4 用来搭建集群的服务器必须是主从结构
5 配置时还要配置免密登录

一 PXC概述

是基于Galera的mysql高可用集群
PXC集群由Percona Server with XtraDB和Write Set Replication patches两部分组成
是一款开源软件,可以在官网http://galeracluster.com下载

二 部署PXC

1 修改主机名配置文件

使得所有服务器都能通过主机名进行连接
vim /etc/hosts
ip 主机名

2 配置服务

①修改数据库服务运行参数配置文件
vim /etc/percona-xtradb-cluster.conf.d/mysqld.cnf
server-id这一项不允许相同,都要进行修改
②修改PXC集群配置文件
vim /etc/percona-xtradb-cluster.conf.d/wsrep.cnf

(#集群成员列表)
wsrep_cluster_address=gcomm://ip1,ip2,ip3…//
(#本机ip)
wsrep_node_address=
(#集群名称,所有服务器必须保持一致)
wsrep_cluster_name=pxc-cluster
(#本机主机名)
wsrep_node_name=
(#sst数据同步授权用户与密码)
wsrep_sst_auth=“sstuser:密码”

3 启动服务

①启动集群服务(在任意一台启动即可)
systemctl start [email protected]
②添加授权用户
查看数据库初始密码
grep password /var/log/mysqld.log
mysql -uroot -p’初始密码’
修改数据库密码
alter user [email protected]“localhost” identified by “密码”;
授权用户
grant reload,lock tables,replication client,process on . to [email protected]“localhost” identified by “密码”;
③在其他数据库服务器启动mysql服务
systemctl start mysql

相关文章:

  • 2021-12-10
  • 2022-01-11
  • 2021-07-27
  • 2021-08-01
  • 2021-12-06
  • 2021-11-13
  • 2022-02-10
  • 2022-01-12
猜你喜欢
  • 2021-09-15
  • 2021-04-05
  • 2022-03-15
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案