MySQL高可用工具Orchestrator raft模式部署
Posted _雪辉_
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySQL高可用工具Orchestrator raft模式部署相关的知识,希望对你有一定的参考价值。
文章目录
一、orchestrator介绍
代码库https://github.com/openark/orchestrator
Orchestrator是一款开源的mysql复制拓扑管理工具,采用go语言编写,支持MySQL主从复制拓扑关系的调整、支持MySQL主库故障自动切换、手动主从切换等功能。Orchestrator依赖MySQL或者SQLite存储元数据,能够提供Web界面展示MySQL集群的拓扑关系及实例状态,通过Web界面可更改MySQL实例的部分配置信息,同时也提供命令行和api接口,以便更加灵活的自动化运维管理。相比于MHA,Orchestrator更加偏重于复制拓扑关系的管理,能够实现MySQL任一复制拓扑关系的调整,并在此基础上,实现MySQL高可用,另外Orchestrator自身可以部署多个节点,通过raft分布式一致性协议,保证自身的高可用。
二、orchestrator分布式部署
2.1 orchestrator元数据库
数据库部署步骤略
#创建orchestrator用户和库,用户开放主机为orchestrator主机ip
CREATE DATABASE IF NOT EXISTS orchestrator;
CREATE USER 'orchestrator'@'%' IDENTIFIED BY 'orchestrator';
GRANT ALL PRIVILEGES ON `orchestrator`.* TO 'orchestrator'@'%';
GRANT SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'orchestrator'@'%'
目标监控数据库
CREATE USER 'orchestrator'@'%' IDENTIFIED BY 'orchestrator';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orchestrator'@'%';
GRANT SELECT ON mysql.slave_master_info TO 'orchestrator'@'%';
2.2 安装orchestrator
yum localinstall orchestrator-3.2.6-1.x86_64.rpm
软件安装在/usr/local/orchestrator/
[root@myrocks-mydb01 ~]# ll /usr/local/orchestrator/
total 19384
-rwxr-xr-x 1 root root 19794824 Jul 27 16:24 orchestrator
-rw-r--r-- 1 root root 7915 Dec 12 19:58 orchestrator.conf.json
-rw-rw-r-- 1 root root 5513 May 24 2021 orchestrator-sample.conf.json
-rw-rw-r-- 1 root root 5100 Jun 4 2020 orchestrator-sample-sqlite.conf.json
drwxr-xr-x 7 root root 4096 Dec 11 18:56 resources
2.3 修改orchestrator配置文件
#仅需更改以下配置,不同节点更改raft bind和raft advertise即可
#配置orchestrator监控的目标数据库信息
"MySQLTopologyUser": "orchestrator",
"MySQLTopologyPassword": "orchestrator",
#配置orchestrator后端元数据库信息
"MySQLOrchestratorHost": "10.0.213.157",
"MySQLOrchestratorPort": 33071,
"MySQLOrchestratorDatabase": "orchestrator",
"MySQLOrchestratorUser": "orchestrator",
"MySQLOrchestratorPassword": "orchestrator",
"RaftEnabled": true,
"RaftDataDir": "/data/orchestrator",
"RaftBind": "xxx.xxx.xxx.xxx",
"RaftAdvertise": "10.0.250.252",
"DefaultRaftPort": 10008,
"RaftNodes": [
"xxx.xxx.xxx.xxx",
"xxx.xxx.xxx.xxx",
"xxx.xxx.xxx.xxx"
]
2.4 启动orchestrator
启动命令,三个节点都需要启动
cd /usr/local/orchestrator && ./orchestrator --config=./orchestrator.conf.json http 2>&1 &
#三个节点都启动后观察日志可以看到Orchestrator做的事情
2021-12-19 23:29:07 DEBUG Connected to orchestrator backend: orchestrator:?@tcp(10.0.213.157:33071)/orchestrator?timeout=1s&readTimeout=30s&rejectReadOnly=false&interpolateParams=true
2021-12-19 23:29:07 DEBUG Orchestrator pool SetMaxOpenConns: 128
2021-12-19 23:29:07 DEBUG Initializing orchestrator
2021-12-19 23:29:07 INFO Connecting to backend 10.0.213.157:33071: maxConnections: 128, maxIdleConns: 32
2021-12-19 23:29:07 INFO Starting Discovery
2021-12-19 23:29:07 INFO Registering endpoints
2021-12-19 23:29:07 INFO continuous discovery: setting up
2021-12-19 23:29:07 DEBUG Setting up raft
2021-12-19 23:29:07 DEBUG raft: advertise=10.0.250.252:10008
2021-12-19 23:29:07 DEBUG Queue.startMonitoring(DEFAULT)
2021-12-19 23:29:07 DEBUG raft: transport=&connPool:map[] connPoolLock:state:0 sema:0 consumeCh:0xc000224240 heartbeatFn:<nil> heartbeatFnLock:state:0 sema:0 logger:0xc000222dc0 maxPool:3 shutdown:false shutdownCh:0xc0002242a0 shutdownLock:state:0 sema:0 stream:0xc0002200c0 timeout:10000000000 TimeoutScale:262144
2021-12-19 23:29:07 DEBUG raft: peers=[10.0.213.157:10008 10.0.219.146:10008 10.0.250.252:10008]
2021-12-19 23:29:07 DEBUG raft: logStore=&dataDir:/data/orchestrator backend:<nil>
2021-12-19 23:29:07 INFO Starting HTTP listener on :3000
2021-12-19 23:29:07 INFO raft: store initialized at /data/orchestrator/raft_store.db
2021-12-19 23:29:07 INFO new raft created
2021-12-19 23:29:07 INFO continuous discovery: starting
2021/12/19 23:29:07 [INFO] raft: Node at 10.0.250.252:10008 [Follower] entering Follower state (Leader: "")
2021/12/19 23:29:08 [DEBUG] raft-net: 10.0.250.252:10008 accepted connection from: 10.0.213.157:22129
2021/12/19 23:29:08 [DEBUG] raft: Node 10.0.250.252:10008 updated peer set (2): [10.0.213.157:10008 10.0.219.146:10008 10.0.250.252:10008]
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 2: leader-uri
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 3: request-health-report
2021-12-19 23:29:08 ERROR HttpGetLeader: got 500 status on http://10.0.213.157:3000/api/raft-follower-health-report/1f4a4bb6/10.0.250.252/10.0.250.252
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 4: request-health-report
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 5: request-health-report
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 6: request-health-report
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 7: request-health-report
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 8: heartbeat
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 9: request-health-report
2021-12-19 23:29:08 DEBUG orchestrator/raft: applying command 10: request-health-report
2.5 web 管理
发现节点,主会自动发现从节点,从节点会自动发现主节点
集群拓扑,红色为异常节点
以上是关于MySQL高可用工具Orchestrator raft模式部署的主要内容,如果未能解决你的问题,请参考以下文章
MySQL高可用工具Orchestrator raft模式部署
MySQL高可用工具Orchestrator raft模式部署
MySQL高可用工具Orchestrator系列一:单节点模式安装
沃趣科技MySQL高可用工具Orchestrator系列四:拓扑恢复