mariadb galera Cluster 多主集群安装实录

1: 创建MariaDB.repo
#vim /etc/yum.repos.d/MariaDB.repo



# MariaDB 10.0 CentOS repository list - created 2013-08-23 13:08 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1



#yum install MariaDB-Galera-server MariaDB-client galera
安装过程中出现
Transaction check error:
  file /etc/my.cnf from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/Index.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/armscii8.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/ascii.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp1250.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp1256.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp1257.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp850.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp852.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/cp866.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/dec8.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/geostd8.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/greek.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/hebrew.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/hp8.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/keybcs2.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/koi8r.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/koi8u.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/latin1.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/latin2.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/latin5.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/latin7.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/macce.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/macroman.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/charsets/swe7.xml from install of MariaDB-common-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/czech/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/danish/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/dutch/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/english/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/estonian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/french/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/german/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/greek/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/hungarian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/italian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/japanese/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/korean/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/norwegian-ny/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/norwegian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/polish/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/portuguese/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/romanian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/russian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/serbian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/slovak/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/spanish/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/swedish/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64
  file /usr/share/mysql/ukrainian/errmsg.sys from install of MariaDB-Galera-server-10.0.12-1.el6.x86_64 conflicts with file from package mariadb-libs-1:5.5.35-3.el7.x86_64

的错误,原因可能是之前安装过了mysql或者mariadb引起的冲突,先把之前的包卸载了
#yum -y remove mariadb-libs-1:5.5.35-3.el7.x86_64

然后再安装
#yum install MariaDB-Galera-server MariaDB-client galera
ok,现在一切顺利

拷贝配置文件:
#cp /usr/share/mysql/wsrep.cnf /etc/my.cnf.d/

node1的配置文件,修改一下几个选项:
#vim /etc/my.cnf.d/wsrep.cnf



bind-address=127.0.0.1
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://"
wsrep_sst_method=rsync
wsrep_sst_receive_address=192.168.150.137



node1添加sst用户,以让其他的node可以以此用户同步数据
[[email protected] ~]# mysql -uroot -pxxxxxxxx
MariaDB [(none)]> > GRANT USAGE ON *.* to [email protected]‘%‘ IDENTIFIED BY ‘sstpass‘;
MariaDB [(none)]> > GRANT ALL PRIVILEGES on *.* to [email protected]‘%‘;
MariaDB [(none)]> > FLUSH PRIVILEGES;
MariaDB [(none)]> > quit

node2的配置文件,修改一下几个选项:
#vim /etc/my.cnf.d/wsrep.cnf



bind-address=127.0.0.1
wsrep_provider=/usr/lib64/galera/libgalera_smm.so
wsrep_cluster_address="gcomm://192.168.150.137:4567"
wsrep_sst_method=rsync
wsrep_sst_receive_address=192.168.150.136
wsrep_sst_auth=sst:sstpass



node1,node2设置防火墙,打开端口3306和4567
#iptables -A INPUT -i eno16777736 -p tcp --dport 3306 -j ACCEPT
#iptables -A INPUT -i eno16777736 -p tcp --dport 4567 -j ACCEPT

node1,node2关闭selinux
#setenforce 0

node1 启动:
#/etc/init.d/mysql bootstrap

node2 启动:
#/etc/init.d/mysql start
发现不能启动

查看日志
#more /var/lib/mysql/localhost.localdomain.err



140801 15:32:51 [Note] WSREP: New cluster view: global state: 412b064f-1944-11e4-b9f8-a70b3179cc21:6, view# 5: Primary, number of nodes: 3, my index: 0, protocol version 3
140801 15:32:51 [Warning] WSREP: Gap in state sequence. Need state transfer.
140801 15:32:53 [Note] WSREP: Running: ‘wsrep_sst_rsync --role ‘joiner‘ --address ‘127.0.0.1‘ --auth ‘sst:sstpass‘ --datadir ‘/var/lib/mysql/‘ --defaults-file ‘/etc/my.cnf‘ --parent ‘8388‘  ‘‘ ‘
140801 15:32:54 [Note] WSREP: Prepared SST request: rsync|127.0.0.1:4444/rsync_sst
140801 15:32:54 [Note] WSREP: wsrep_notify_cmd is not defined, skipping notification.
140801 15:32:54 [Note] WSREP: REPL Protocols: 5 (3, 1)
140801 15:32:54 [Note] WSREP: Service thread queue flushed.
140801 15:32:54 [Note] WSREP: Assign initial position for certification: 6, protocol version: 3
140801 15:32:54 [Note] WSREP: Service thread queue flushed.
140801 15:32:54 [Warning] WSREP: Failed to prepare for incremental state transfer: Local state UUID (00000000-0000-0000-0000-000000000000) does not match group state UUID (412b064f-1944-11e4-b9f8-a70b3179cc21): 1 (Operation not permitted)
         at galera/src/replicator_str.cpp:prepare_for_IST():447. IST will be unavailable.
140801 15:32:54 [Note] WSREP: Member 0.0 (localhost.localdomain) requested state transfer from ‘*any*‘. Selected 1.0 (localhost.localdomain)(SYNCED) as donor.
140801 15:32:54 [Note] WSREP: Shifting PRIMARY -> JOINER (TO: 6)
140801 15:32:54 [Note] WSREP: Requesting state transfer: success, donor: 1
140801 15:32:54 [Warning] WSREP: 1.0 (localhost.localdomain): State transfer to 0.0 (localhost.localdomain) failed: -255 (Unknown error 255)
140801 15:32:54 [ERROR] WSREP: gcs/src/gcs_group.c:gcs_group_handle_join_msg():723: Will never receive state. Need to abort.
140801 15:32:54 [Note] WSREP: gcomm: terminating thread
140801 15:32:54 [Note] WSREP: gcomm: joining thread
140801 15:32:54 [Note] WSREP: gcomm: closing backend



发现Prepared SST request: rsync|127.0.0.1:4444/rsync_sst启用了4444端口来做数据的同步,而这个端口并没有在iptables中设置,和前面一样,设置一下
#iptables -A INPUT -i eno16777736 -p tcp --dport 4444 -j ACCEPT

测试:
在任何一台服务器进行添加,删除,修改操作,都会同步到其他的服务器,是现在主主的模式,当然前提是表引擎必须是innodb,因为galera目前只支持innodb的表。

PS:
对于只有2个节点的Galera Cluster和其他集群软件一样,需要面对极端情况下的"脑裂"状态。
为了避免这种问题,Galera引入了"arbitrator(仲裁人)"。
"仲裁人"节点上没有数据,它在集群中的作用就是在集群发生分裂时进行仲裁,集群中可以有多个"仲裁人"节点。
"仲裁人"节点加入集群的方法如下:
# garbd -a gcomm://192.168.1.137:4567 -g my_wsrep_cluster -d
# 注释:参数说明: -d:以daemon模式运行 -a:集群地址 -g: 集群名称9.测试集群是否配置好参数:登陆数据库:查看如下几个参数:

MariaDB [(none)]> SHOW VARIABLES LIKE ‘wsrep_cluster_address‘;
#如果配置了指向集群地址,上面那个参数值,应该是你指定集群的IP地址

# 此参数查看是否开启
MariaDB [(none)]> show status like ‘wsrep_ready‘;

# 查看集群的成员数
MariaDB [(none)]> show status like ‘wsrep_cluster_size‘;

# 这个查看wsrep的相关参数
MariaDB [(none)]> show status like ‘wsrep%‘;

mariadb galera Cluster 多主集群安装实录

时间: 2024-09-28 15:37:24

mariadb galera Cluster 多主集群安装实录的相关文章

Mysql上的RAC:Percona XtraDB Cluster负载均衡集群安装部署手册

 Percona XtraDB Cluster安装部署手册 引言 编写目的 编写此文档,供PerconaXtraDB Cluster部署时使用. 预期读者 系统维护人员及实施人员. 编制依据及参考资料 目标 通过阅读该手册,让读者明确PerconaXtraDB Cluster的安装.配置和维护情况,为后续数据库运维工作提供指导. 应用部署方案 环境准备 服务器列表 序号 IP 用途 HOSTNAME 操作系统 1 192.168.0.7 Percona XtraDB Cluster RedHat

Galera Cluster mysql+keepalived集群部署

1.卸载mysql 查找本机安装的mysqlrpm -qa | grep -i mysql --nodeps --force rpm -ev MySQL-server-5.6.15-1.el6.x86_64rpm -ev --nodeps mysql-libs-5.1.71-1.el6.x86_64 (强制卸载) 查找之前老版本mysql的目录.并且删除老版本mysql的文件和库 find / -name mysql rm -rf /usr/lib64/mysql 卸载后/etc/my.cnf不

MariaDB Galera Cluster集群

一.MariaDB Galera Cluster概要: 1.简述: MariaDB Galera Cluster 是一套在mysql innodb存储引擎上面实现multi-master及数据实时同步的系统架构,业务层面无需做读写分离工作,数据库读写压力都能按照既定的规则分发到 各个节点上去.在数据方面完全兼容 MariaDB 和 MySQL. 2.特性: (1).同步复制 Synchronous replication (2).Active-active multi-master 拓扑逻辑 (

利用MariaDB Galera Cluster实现mariadb的多主复制

利用MariaDB Galera Cluster实现mariadb的多主复制 时间:2014年01月08日 | 分类:MariaDB | 评论:0 条 | 浏览:870 次 一.MariaDB Galera Cluster概要: 1.简述: MariaDB Galera Cluster 是一套在mysql innodb存储引擎上面实现multi-master及数据实时同步的系统架构,业务层面无需做读写分离工作,数据库读写压力都能按照既定的规则分发到 各个节点上去.在数据方面完全兼容 MariaD

MariaDB Galera Cluster实现mariadb的多主复制

一.MariaDB Galera Cluster概要: 1.简述: MariaDB Galera Cluster 是一套在mysql innodb存储引擎上面实现multi-master及数据实时同步的系统架构,业务层面无需做读写分离工作,数据库读写压力都能按照既定的规则分发到各个节点上去.在数据方面完全兼容 MariaDB 和 MySQL. 2.特性: (1).同步复制 Synchronous replication (2).Active-active multi-master 拓扑逻辑 (3

Centos7安装mariadb galera cluster数据库集群 & 详解

#Galera集群特点 集群之间无延时,同步复制.而master-slave主从异步复制,存在延迟. active-active多主,集群内部服务器都是同时写,必须等所有集群内所有数据库都完成数据写入,才会反馈完成,所以不存在数据丢失的情况. 集群节点自动故障转移,如果集群中单个节点故障,失效节点会自动被清除. 扩展方便,只要将新的节点添加到集群,新节点自动复制数据. #Galera集群原理     #主要通过galera插件保证数据的一致性,该数据复制的过程是可认证的复制,原理如下: #解析

MariaDB Galera Cluster集群企业版编译安装与配置

安装环境 系统:CentOS 6.8 x86_64 软件:MariaDB 10.1.16 节点一:192.168.11.132 4C 8GB 节点二:192.168.11.133 4C 8GB 软件获取 访问MariaDB企业版下载地址 https://mariadb.com/my_portal/download/mariadb-enterprise 登录帐号后选择 10.1.16GA版本 源代码包下载. 从MariaDB Enterprise 10.1版本开始,企业版软件包与集群功能集成到一起

MariaDB Galera Cluster 部署(如何快速部署 MariaDB 集群)

MariaDB Galera Cluster 部署(如何快速部署 MariaDB 集群)  OneAPM蓝海讯通7月3日 发布 推荐 4 推荐 收藏 14 收藏,1.1k 浏览 MariaDB 作为 Mysql 的一个分支,在开源项目中已经广泛使用,例如大热的 openstack,所以,为了保证服务的高可用性,同时提高系统的负载能力,集群部署是必不可少的. MariaDB Galera Cluster 介绍 MariaDB 集群是 MariaDB 同步多主机集群.它仅支持 XtraDB/ Inn

MariaDB Galera Cluster 部署(如何快速部署MariaDB集群)

MariaDB作为Mysql的一个分支,在开源项目中已经广泛使用,例如大热的openstack,所以,为了保证服务的高可用性,同时提高系统的负载能力,集群部署是必不可少的. MariaDB Galera Cluster 介绍 MariaDB集群是MariaDB同步多主机集群.它仅支持XtraDB/ InnoDB存储引擎(虽然有对MyISAM实验支持 - 看wsrep_replicate_myisam系统变量). 主要功能: 同步复制 真正的multi-master,即所有节点可以同时读写数据库