设为首页 加入收藏

TOP

MySQL分片高可用集群之Fabric部署使用(二)
2015-11-12 21:29:24 来源: 作者: 【 】 浏览:12
Tags:MySQL 分片 可用 集群 Fabric 部署 使用
ailover_interval = 0


detections = 3


detection_interval = 6


detection_timeout = 1


prune_time = 3600


?


[connector]


ttl = 1



配置好后,需要初始化fabric的元数据
?


$ mysqlfabric manage setup


。。。。。。


Finishing initial setup


=======================


Password for admin user is not yet set.


Password for admin/xmlrpc:? ? ? ? ? ? ? ? 这里需要设置admin的密码


Repeat Password:? ? ? ? ? ? ? ? ? ? ? ? ? 重复输入密码


Password set.


Password set.


这时fa00这个数据库已经有了fabric的元数据,我们可以用mysql客户端查看。


然后启动


$ mysqlfabric manage start



自此虽然启动了fabric,但是还没有和前面配置的后两个业务数据库产生联系,接下来我们需要用命令行建立联系。我先看一下mysqlfabric的分组相关帮助,


$ mysqlfabric help group


Commands available in group 'group' are:


? ? group activate group_id? [--synchronous]


? ? group description group_id? [--description=NONE] [--synchronous]


? ? group deactivate group_id? [--synchronous]


? ? group create group_id? [--description=NONE] [--synchronous]


? ? group remove group_id server_id? [--synchronous]


? ? group add group_id address? [--timeout=NONE] [--update_only] [--synchronous]


? ? group health group_id?


? ? group lookup_servers group_id? [--server_id=NONE] [--status=NONE] [--mode=NONE]


? ? group destroy group_id? [--synchronous]


? ? group demote group_id? [--update_only] [--synchronous]


? ? group promote group_id? [--slave_id=NONE] [--update_only] [--synchronous]


? ? group lookup_groups? [--group_id=NONE]



我们首先需要创建一个组group-1:


$ mysqlfabric group create group-1


然后将两个业务数据库10011和10012放入这个组中:


$ mysqlfabric group add group-1 127.0.0.1:10011


$ mysqlfabric group add group-1 127.0.0.1:10012



然后可以查看这时group-1这个组的状态


$ mysqlfabric group lookup_servers group-1


Fabric UUID:? 5ca1ab1e-a007-feed-f00d-cab3fe13249e


Time-To-Live: 1


?


? ? ? ? ? ? ? ? ? ? ? ? server_uuid? ? ? ? address? ? status? ? ? mode weight


------------------------------------ --------------- --------- --------- ------


d4919ca2-754a-11e5-8a5e-34238703623c 127.0.0.1:10011 SECONDARY READ_ONLY? ? 1.0


d6597f06-754a-11e5-8a5e-34238703623c 127.0.0.1:10012 SECONDARY READ_ONLY? ? 1.0


从status 和 mode 这两个字段可以看出,这个时候刚加入的两个服务器还没有正式生效,都是作为从库只读的身份,两个库还没有建立实质的联系,我们需要将其中一个数据库提升为可写的主:


$ mysqlfabric group promote group-1


?


$ mysqlfabric group lookup_servers group-1


Fabric UUID:? 5ca1ab1e-a007-feed-f00d-cab3fe13249e


Time-To-Live: 1


? ? ? ? ? ? ? ? ? ? ? ? server_uuid? ? ? ? address? ? status? ? ? mode weight


------------------------------------ --------------- --------- ---------- ------


d4919ca2-754a-11e5-8a5e-34238703623c 127.0.0.1:10011 SECONDARY? READ_ONLY? ? 1.0


d6597f06-754a-11e5-8a5e-34238703623c 127.0.0.1:10012? PRIMARY READ_WRITE? ? 1.0


用promote命令提升后,其中一台会被提升为主数据库,其他的都为从。主从也可以通过mysql客户端查看,在从库执行下面的命令显示如下,主库执行则没有信息


mysql> show slave status \G;


*************************** 1. row ***************************


? ? ? ? ? ? ? Slave_IO_State: Waiting for master to send event


? ? ? ? ? ? ? ? ? Master_Host: 127.0.0.1


? ? ? ? ? ? ? ? ? Master_User: fabric


? ? ? ? ? ? ? ? ? Master_Port: 10012


? ? ? ? ? ? ? ? Connect_Retry: 60


? ? ? ? ? ? ? Master_Log_File: mysql-bin.000001


? ? ? ? ? Read_Master_Log_Pos: 151


? ? ? ? ? ? ? Relay_Log_File: lyw-hp-relay-bin.000002


? ? ? ? ? ? ? ? Relay_Log_Pos: 361


? ? ? ? Relay_Master_Log_File: mysql-bin.000001


? ? ? ? ? ? Slave_IO_Running: Yes


? ? ? ? ? ? Slave_SQL_Running: Yes


? ? ? ? ? ? ? ? ? ? ? ? ? 。。。。。。



至此主从方式以基本可用,我们迫不及待地想要尝试下客户端如何使用了。官方提供python和java两种客户的,因此如果用Fabric,业务语言最好是这两种。


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇解决MySQL Slave同步问题 下一篇MySQL与MariaDB 传统主从集群配置

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: