bco 发表于 2018-10-1 13:30:58

Mysql高可用 - Fabric安装配置

# 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'
  
# mysqlfabric help commands# 显示所有的mysqlfabric命令
  

  
# cd /etc/mysql/   # 编辑fabric.cfg配置文件
  
# cp fabric.cfg fabric.cfg.bak# 备份fabric.cfg配置文件
  
# vim fabric.cfg
  

  
prefix =
  
sysconfdir = /etc# 配置文件目录
  
logdir = /var/log#日志目录
  
# 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
  

  
url = file:///var/log/fabric.log
  
level = INFO# 日志级别
  

  
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
  

  
notification_interval = 60
  
notification_clients = 50
  
detection_timeout = 1
  
detection_interval = 6
  
notifications = 300
  
detections = 3
  
failover_interval = 0
  
prune_time = 3600
  

  
password = oracle   # fabric节点连接mysql HAgroup中的server认证的密码
  
user = oracle # fabric节点连接mysql HAgroup中的server认证的用户名
  
unreachable_timeout = 5
  

  
ttl = 1
  
# This section is used by the mysql client when called from MySQL Fabric and is not used MySQL Fabric.
  
password = oracle
  
# 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
  
# The executor executes procedures in a serial order, which guarantees that requests do not conflict.
  
executors = 5
  
# 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.xmlrpc应该是一样是类似的吧
  
disable_authentication = no
  
ssl_cert =
  
ssl_key =
  
ssl_ca =
  
user = admin
  
address = localhost:32275
  
password = admin
  

  
# fabric节点的my.cnf配置文件
  
# cat /etc/my.cnf
  

  
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数据库
  
# mysqlfabric manage setup --param=storage.user=fabric --param=storage.password=fabric#如果报错见下面的Trouble Shooting
  
# 成功执行,会让你输入admin用户的密码
  
mysqlfabric manage start --daemonize # 启动fabric管理系统
  
mysqlfabric group create mysql_group # 创建管理组mysql_group
  
mysqlfabric group lookup_groups# 查看管理组信息
  

  
# 在每个mysql server添加到管理组mysql_group之前,需要在每个mysql server上创建授权用户
  
# mysql -uroot -e "grant all on *.* to oracle@'%' identified by 'oracle';"
  
# mysql -uroot -e "grant all on *.* to oracle@'%' identified by 'oracle';"
  
mysqlfabric group add mysql_group controller1:3306
  
mysqlfabric group add mysql_group controller2:3306# 添加完节点后,查看组信息,两个都为secondary,记得在/etc/hosts文件写controller1、从controller2的ip映射
  
mysqlfabric group lookup_servers mysql_group
  
mysqlfabric group health mysql_group# 这两种方式都可以查看节点状态信息
  
mysqlfabric group promote mysql_group # promote之后,fabric会选举出一台作为primary , demote是取消primary选举
  
mysqlfabric group activate mysql_group#激活失败检测
  
# 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 SECONDARYREAD_ONLY    1.0
  
0c826bd0-4f8c-11e4-8ee8-5254003d38c9 controller1:3306   PRIMARY READ_WRITE    2.0


页: [1]
查看完整版本: Mysql高可用 - Fabric安装配置