Mysql高可用 - Fabric安装配置

Fabric简介

mysql fabric是oracle推出的,它可以简化管理mysql集群,提供两大特性:

1  通过故障检测和故障转移提供高可用

2  通过自动数据分片实现可扩展性

Fabric前提条件

  • MySQL server 5.6.10 or later for Fabric MySQL servers.(fabric是基于mysql 5.6的新特性gtid实现的)
  • MySQL server 5.6.x or later for the backing store.
  • Python 2 (2.6 or later) for the mysqlfabric utility.
  • A Fabric-aware connector to use Fabric in applications. Permitted connectors and versions are:
    • Connector/Python 1.2.1 or later
    • Connector/J 5.1.27 or later

以上都是mysql fabric官网介绍的

Fabric所需安装包

server节点:

MySQL-server-5.6.21-1.el6.x86_64  # mysql server包,安装这个包需要先卸载mysql-libs这个包

MySQL-client-5.6.21-1.el6.x86_64  # mysql client包,可以不装,没装就没有mysql命令行命令了

MySQL-shared-5.6.21-1.el6.x86_64

MySQL-shared-compat-5.6.21-1.el6.x86_64  # 卸载了mysql-libs包会有一些依赖问题,安装MySQL-shared这两个包可以解决依赖

client节点:

MySQL-client-5.6.21-1.el6.x86_64  # mysql client包,可以不装,没装就没有mysql命令行命令了

mysql-connector-python-2.0.1-1.el6.noarch # app连接fabric的驱动,跟MySQL-python这个包不一样

fabric节点:

mysql-connector-python-2.0.1-1.el6.noarch # app连接fabric的驱动,fabric节点可以不装

mysql-utilities-1.5.2-1.el6.noarch # mysqlfabric包含在这个包里

MySQL-server-5.6.21-1.el6.x86_64  # mysql server包,安装这个包需要先卸载mysql-libs这个包

MySQL-client-5.6.21-1.el6.x86_64  # mysql client包,可以不装,没装就没有mysql命令行命令了

MySQL-shared-5.6.21-1.el6.x86_64

MySQL-shared-compat-5.6.21-1.el6.x86_64  # 卸载了mysql-libs包会有一些依赖问题,安装MySQL-shared这两个包可以解决依赖

Fabric具体配置

我的环境:

linux系统  centos 6.5 x86_64

controller1  192.168.141.110  server节点

controller2  192.168.141.120  server节点

controller3  192.168.141.130  fabric节点

[[email protected] ~]# mysql -uroot -p   # fabric节点需要在backing store mysql server上创建一个fabric database,这里fabric节点和backing store mysql server在同一台机器上
mysql> create user ‘fabric‘@‘localhost‘ identified by ‘fabric‘  # 连接backing store mysql server认证的用户
mysql> grant all on fabric.* to ‘fabric‘@‘localhost‘
[[email protected] ~]# mysqlfabric help commands  # 显示所有的mysqlfabric命令

[[email protected] ~]# cd /etc/mysql/   # 编辑fabric.cfg配置文件
[[email protected] mysql]# cp fabric.cfg fabric.cfg.bak  # 备份fabric.cfg配置文件
[[email protected] mysql]# vim fabric.cfg
[DEFAULT]
prefix = 
sysconfdir = /etc  # 配置文件目录
logdir = /var/log  #日志目录
[statistics]  # How often the internal event log is pruned, in seconds and also the age of events in the event log that is used to present statistics.
prune_time = 3600
[logging]
url = file:///var/log/fabric.log
level = INFO  # 日志级别
[storage]
auth_plugin = mysql_native_password
database = fabric #连接backing store mysql server的数据库名
user = fabric  # 连接backing store mysql server fabric数据库的用户名
address = localhost:3306  # backing store mysql server的地址和端口,localhost说明backing store mysql server和fabric节点在同一个机器上
connection_delay = 1  
connection_timeout = 6
password = fabric # 连接backing store mysql server fabric数据库的密码
connection_attempts = 6  
[failure_tracking]
notification_interval = 60
notification_clients = 50
detection_timeout = 1
detection_interval = 6
notifications = 300
detections = 3
failover_interval = 0
prune_time = 3600
[servers]
password = oracle   # fabric节点连接mysql HAgroup中的server认证的密码
user = oracle # fabric节点连接mysql HAgroup中的server认证的用户名
unreachable_timeout = 5
[connector]
ttl = 1
[client]  # This section is used by the mysql client when called from MySQL Fabric and is not used MySQL Fabric.
password = oracle 
[protocol.xmlrpc] # This section contains information about how the client connects to a MySQL Fabric node and configuration parameters for the XML-RPC protocol on the server
disable_authentication = no
ssl_cert = 
realm = MySQL Fabric
ssl_key = 
ssl_ca = 
threads = 5
user = admin
address = controller3:32274
password = admin 
[executor]  # The executor executes procedures in a serial order, which guarantees that requests do not conflict.
executors = 5
[sharding]  # To perform operations such as moving and splitting shards, MySQL Fabric relies on the mysqldump and mysqlclient programs.
prune_limit = 10000
mysqldump_program = /usr/bin/mysqldump  
mysqlclient_program = /usr/bin/mysql
[protocol.mysql]  # 官方文档上我没找到这个的解释,我想跟protocol.xmlrpc应该是一样是类似的吧
disable_authentication = no
ssl_cert = 
ssl_key = 
ssl_ca = 
user = admin
address = localhost:32275
password = admin

# fabric节点的my.cnf配置文件
[[email protected] mysql]# cat /etc/my.cnf
[mysqld]
bind_address = localhost
datadir=/var/lib/mysql
collation-server = utf8_general_ci
init-connect = ‘SET NAMES utf8‘
character-set-server = utf8
default-storage-engine = innodb
innodb_file_per_table = 1
innodb_buffer_pool_size = 512M
log_bin                       
gtid_mode=on  
enforce_gtid_consistency=on  
log_slave_updates=1

# 初始化fabric数据库
[[email protected] mysql]# mysqlfabric manage setup --param=storage.user=fabric --param=storage.password=fabric  #如果报错见下面的Trouble Shooting
# 成功执行,会让你输入admin用户的密码
[[email protected]] mysqlfabric manage start --daemonize # 启动fabric管理系统
[[email protected]] mysqlfabric group create mysql_group # 创建管理组mysql_group
[[email protected]] mysqlfabric group lookup_groups  # 查看管理组信息

# 在每个mysql server添加到管理组mysql_group之前,需要在每个mysql server上创建授权用户
[[email protected] ~]# mysql -uroot -e "grant all on *.* to [email protected]‘%‘ identified by ‘oracle‘;"
[[email protected] ~]# mysql -uroot -e "grant all on *.* to [email protected]‘%‘ identified by ‘oracle‘;"
[[email protected]] mysqlfabric group add mysql_group controller1:3306
[[email protected]] mysqlfabric group add mysql_group controller2:3306  # 添加完节点后,查看组信息,两个都为secondary,记得在/etc/hosts文件写controller1、从controller2的ip映射
[[email protected]] mysqlfabric group lookup_servers mysql_group
[[email protected]] mysqlfabric group health mysql_group  # 这两种方式都可以查看节点状态信息
[[email protected]] mysqlfabric group promote mysql_group # promote之后,fabric会选举出一台作为primary , demote是取消primary选举
[[email protected]] mysqlfabric group activate mysql_group  #  激活失败检测
[[email protected] ~]# mysqlfabric group lookup_servers mysql_group
Fabric UUID:  5ca1ab1e-a007-feed-f00d-cab3fe13249e
Time-To-Live: 1
                         server_uuid          address    status       mode weight
------------------------------------ ---------------- --------- ---------- ------
086193ff-4f7f-11e4-8e93-525400788967 controller2:3306 SECONDARY  READ_ONLY    1.0
0c826bd0-4f8c-11e4-8ee8-5254003d38c9 controller1:3306   PRIMARY READ_WRITE    2.0

客户端通过Fabric connector连接操作就可,可是在openstack中客户端这部分连接操作的代码还没实现,还有fabric节点也要做高可用,希望oracle能尽快改进。

Trouble Shooting

1   初始化fabric数据库mysqlfabric manage setup --param=storage.user=fabric --param=storage.password=fabric执行时可能报错如下:

Error: Command (CREATE TABLE machines (machine_uuid VARCHAR(40) NOT NULL, provider_id VARCHAR(256) NOT NULL, av_zone VARCHAR(256), addresses TEXT, INDEX idx_machine_provider_id (provider_id)), ()) failed accessing (localhost:3306). 1071 (42000): Specified key was too long; max key length is 767 bytes.

原因:MySQL的varchar主键只支持不超过768个字节 或者 768/2=384个双字节 或者 768/3=256个三字节的字段 而 GBK是双字节的,UTF-8是三字节的。

参考链接:http://lsting.iteye.com/blog/707749

解决:

[[email protected] mysql]# vim /etc/my.cnf  # 编辑my.cnf文件,先注释掉下面这些utf-8的配置选项,重启mysql服务,然后再去初始化fabric数据库,初始化完毕后,再去掉注释。

[mysqld]
#collation-server = utf8_general_ci
#init-connect = ‘SET NAMES utf8‘
#character-set-server = utf8

2  当数据库某个节点故障后重新恢复,需要先将节点变成spare,再切换为seconary,这个真让人蛋疼,没有自动恢复的机制

[[email protected]] 
mysqlfabric server set_status 086193ff-4f7f-11e4-8e93-525400788967 SPARE
[[email protected]] 
mysqlfabric server set_status 086193ff-4f7f-11e4-8e93-525400788967 SECONDARY

这是fabric管理系统的server状态切换图(http://mysqlmusings.blogspot.fr/2013/10/mysql-fabric-high-availability-groups.html),看这个应该都懂了吧!

参考链接

http://dev.mysql.com/doc/mysql-utilities/1.4/en/fabric.html

http://blog.itpub.net/25704976/viewspace-1180262

http://www.luocs.com/archives/862.html

http://www.percona.com/blog/2014/05/15/high-availability-mysql-fabric-part/

时间: 2024-08-02 00:14:23

Mysql高可用 - Fabric安装配置的相关文章

MySQL 高可用MMM安装部署以及故障转移详细资料汇总

1,      mmm简介 MMM(Master-Masterreplication manager for MySQL)是一套支持双主故障切换和双主日常管理的脚本程序.MMM使用Perl语言开发,主要用来监控和管理MySQL Master-Master(双主)复制,虽然叫做双主复制,但是业务上同一时刻只允许对一个主进行写入,另一台备选主上提供部分读服务,以加速在主主切换时刻备选主的预热,可以说MMM这套脚本程序一方面实现了故障切换的功能,另一方面其内部附加的工具脚本也可以实现多个slave的r

高可用Heartbeat安装配置

Heartbeat (Linux-HA)的工作原理:heartbeat最核心的包括两个部分,心跳监测部分和资源接管部分,心跳监测可以通过网络链路和串口进行,而且支持冗 余链路,它们之间相互发送报文来告诉对方自己当前的状态,如果在指定的时间内未收到对方发送的报文,那么就认为对方失效,这时需启动资源接管模块来接管运 行在对方主机上的资源或者服务. 测试环境: OS:CentOS6.6_64 master-ip:10.0.0.16 slave-ip: 10.0.0.17 vip-ip:10.0.0.1

MySQL 高可用MHA安装部署以及故障转移详细资料汇总 转

http://blog.itpub.net/26230597/cid-87082-list-2/ 1,简介 1.1mha简介 MHA,即MasterHigh Availability Manager and Tools for MySQL,是日本的一位MySQL专家采用Perl语言编写的一个脚本管理工具,该工具仅适用于MySQLReplication(二层)环境,目的在于维持Master主库的高可用性. MHA(Master High Availability)是自动的master故障转移和Sl

MySQL 高可用MHA安装部署以及故障转移详细资料汇总

1,简介 1.1mha简介 MHA,即MasterHigh Availability Manager and Tools for MySQL,是日本的一位MySQL专家采用Perl语言编写的一个脚本管理工具,该工具仅适用于MySQLReplication(二层)环境,目的在于维持Master主库的高可用性. MHA(Master High Availability)是自动的master故障转移和Slave提升的软件包.它是基于标准的MySQL复制(异步/半同步). MHA有两部分组成:MHA M

heartbeat v2配置高可用web集群和基于nfs搭建MySQL高可用集群

安装环境:Centos 6.4, httpd2.4,mysql5.5,heartbeat v2 提供两台机器node1和node2,在/etc/hosts文件中添加名称解析,并且主机名称要与节点名称要相同,即uname -n的名称要和hosts定义的名称必须一样. #   IP                         HOSTNAME             ALIAS 10.204.80.79     node1.mylinux.com     node1 10.204.80.80  

配置MySQL高可用集群MHA

配置MySQL高可用集群+++++++++++++++++++主机角色 :客户端 client50数据库服务器 mysql51 到 mysql55管理主机 mgm56VIP地址 192.168.4.100拓扑结构: client50 | mysql51主 | | | | | |mysql52 mysql53 mysql54 mysql55 mgm56从 从 从 从 管理集群备用主 备用主+++++++++++++++++++++++++++++++++++++++++++++++++++++++

Windows2012R2 Hyper-v3.0 高可用群集安装及配置(Live Migration)

Windows2012R2 高可用群集安装及配置(Live Migration) 近期闲着没事做了一些高可用相关的实验分享给大家,上一篇我们介绍了SQL Server2014的高可用,今天主要介绍一下windows server2012下Hyper-v3.0的高可用安装及配置:对于当下很多启用都会应用到虚拟机,所谓的虚拟化就是讲物理机转换为虚拟机.将物理机的应用服务运行到虚拟机下,当然虚拟化还是相对比较方便的,不管是从管理及应用上,都是占用相对的优势的,同样现在企业中的应用服务也要求比较严格,要

keepalived + mysqlroute +mysql实现mysql高可用

一.环境介绍: 1.1服务器角色配置: mysql-master 10.0.0.101(外) 172.168.1.101(内) mysql-slave 10.0.0.103 (外) 172.168.1.103(内) mysql-router01 10.0.0.102 (外) 172.168.1.102(内) mysql-router02 10.0.0.104 (外) 172.168.1.104(内) jumpserver 10.0.0.128 (外) 172.168.1.128(内) 1.2配置

Mysql+DRBD+Heartbeat 实现mysql高可用的双击热备(DRBD篇)

DRBD官方tar包下载地址:   http://oss.linbit.com/drbd/ 环境介绍: 系统版本:CentOS 6.4 (64位) 内核版本  2.6.32-358.el6.x86_64 软件版本:drbd-8.4.3.tar.gz 主:10.0.0.1   从:10.0.0.2 两台机器上的hosts都需要修改: [[email protected] ~]# vim /etc/hosts 10.0.0.1    node1 10.0.0.2    node2 两台服务器双网卡,