介紹
在MySQL高可用架構中,目前使用比較多的是Percona的PXC,Galera以及MySQL 5.7之后的MGR等,其他的還有的MHA,今天介紹另一個比較好用的MySQL高可用復制管理工具:Orchestrator(orch)。
Orchestrator(orch):go編寫的MySQL高可用性和復制拓撲管理工具,支持復制拓撲結構的調整,自動故障轉移和手動主從切換等。后端數據庫用MySQL或SQLite存儲元數據,並提供Web界面展示MySQL復制的拓撲關系及狀態,通過Web可更改MySQL實例的復制關系和部分配置信息,同時也提供命令行和api接口,方便運維管理。相對比MHA來看最重要的是解決了管理節點的單點問題,其通過raft協議保證本身的高可用。GitHub的一部分管理也在用該工具進行管理。關於Orchestrator更詳細的介紹可以看Github的介紹,大致的特點有:
① 自動發現MySQL的復制拓撲,並且在web上展示。
② 重構復制關系,可以在web進行拖圖來進行復制關系變更。
③ 檢測主異常,並可以自動或手動恢復,通過Hooks進行自定義腳本。
④ 支持命令行和web界面管理復制。
部署如下
試驗環境
mysql服務器 orchestrator & master:10.72.16.112 slave1:10.72.16.50 slave2:10.72.16.59
1、安裝orchestrator
orchestrator-cli-3.0.11-1.x86_64.rpm安裝程序需要依賴包,安裝依賴包jq-1.5、oniguruma-5.9.5
並且最好在redhat 7的操作系統安裝。
yum install orchestrator-3.1.2-1.x86_64.rpm jq-1.5-1.el7.x86_64.rpm oniguruma-5.9.5-3.el7.x86_64.rpm 安裝完成后,目錄在/usr/local/orchestrator
2、配置主機解析
[root@hchtest4 ~]# cat /etc/hosts 10.72.16.112 hchtest4 10.72.16.50 hchtest3 10.72.16.59 hchtest-elk
3、3台MySQL主從復制省略
4、orchestrator的后台管理端數據庫權限配置(112上執行)
在orch后端數據庫112上: CREATE DATABASE IF NOT EXISTS orchestrator; CREATE USER 'orchestrator'@'%' IDENTIFIED BY 'hch123'; GRANT ALL PRIVILEGES ON orchestrator.* TO 'root'@'%';
5、3台orch管理的數據庫集群上,權限及數據庫執行(3台數據庫執行)
CREATE USER 'orchestrator'@'%' IDENTIFIED BY 'hch123'; GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orchestrator'@'%'; GRANT SELECT ON mysql.slave_master_info TO 'orchestrator'@'%'; CREATE DATABASE IF NOT EXISTS meta; GRANT SELECT ON meta.* TO 'orchestrator'@'%';
6、修改配置文件
cp /usr/local/orchestrator/conf/orchestrator-sample.conf.json /etc/orchestrator.conf.json vim /etc/orchestrator.conf.json #被管理MySQL數據庫的用戶權限數據庫賬號密碼 "MySQLTopologyUser": "root", "MySQLTopologyPassword": "hch123", #orchestrator管理后台數據庫賬號密碼 "MySQLOrchestratorHost": "10.72.16.112", "MySQLOrchestratorPort": 3306, "MySQLOrchestratorDatabase": "orchestrator", "MySQLOrchestratorUser": "orchestrator", "MySQLOrchestratorPassword": "hch123", "DiscoverByShowSlaveHosts": false,
DiscoverByShowSlaveHosts": ture 這種情況下,必須配置report_host
$ vim /etc/my_3306.cnf
report_host=192.168.225.128 //ip為自身的ip
說明:不加report_host ,show slave hosts 不會顯示host,會導致程序報錯的
report_host為只讀參數,必須重啟才可生效
說明:
DiscoverByShowSlaveHosts": false 也可以,這樣就不需要設置report_host了
7、創建命令軟鏈接
ln -s /usr/local/orchestrator/orchestrator /usr/bin/
8、啟動orchestrator
orchestrator --debug --config=/etc/orchestrator.conf.json http 查看端口 [root@orchestrator ~]# netstat -tnpl |grep :3000 tcp6 0 0 :::3000 :::* LISTEN 6084/orchestrator
8、命令行發現:
orchestrator -c discover -i 10.72.16.50 orchestrator -c discover -i 10.72.16.59 orchestrator -c clusters ----查看集群
9、訪問網頁
http://10.72.16.51:3000
參考
Orchestrator部署配置 - qq_26496673的博客 - CSDN博客 https://blog.csdn.net/qq_26496673/article/details/82810671
MySQL高可用復制管理工具 —— Orchestrator介紹 - jyzhou - 博客園 https://www.cnblogs.com/zhoujinyi/p/10387581.html
MySQL高可用復制管理工具 —— Orchestrator使用 - jyzhou - 博客園 https://www.cnblogs.com/zhoujinyi/p/10394389.html
orchestrator 安裝?參數?VIP腳本? - wangxin3618的博客 - CSDN博客 https://blog.csdn.net/wangxin3618/article/details/97013376
orchestrator簡介 - fearless11的博客 - CSDN博客 https://blog.csdn.net/fearless11/article/details/77170764
Orchestrator管理mysql復制 - 個人文章 - SegmentFault 思否 https://segmentfault.com/a/1190000017838535?utm_source=tag-newest
MySQL復制拓撲管理工具Orchestrator - 簡書 https://www.jianshu.com/p/62e95a131028
MySQL高可用探索之orchestrator | Yangtze River's blog https://riverdba.github.io/2019/03/19/orchestrator/