溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

如何在三臺vm上安裝Orchestrator?

發(fā)布時(shí)間:2020-05-28 17:40:23 來源:億速云 閱讀:467 作者:鴿子 欄目:系統(tǒng)運(yùn)維

一、環(huán)境說明:

1.1、3臺vm虛擬機(jī)系統(tǒng)環(huán)境介紹:

3臺VM系統(tǒng)為:

[root@mgr01 ~]# cat /etc/redhat-release 
CentOS Linux release 7.2.1511 (Core)

3臺VM centos 系統(tǒng)都關(guān)閉iptables,關(guān)閉selinux
3臺虛擬機(jī)系統(tǒng)時(shí)間同步:
ntpdate ntp1.aliyun.com
3臺vm虛擬機(jī)上各安裝一個(gè)orchestrator mysql

orchestrator版本為:orchestrator-3.1.4-linux-amd64.tar.gz
下載地址:
https://github.com/github/orchestrator/releases

mysql的版本為mysql5.7.24 GA 二進(jìn)制版本安裝

三臺機(jī)器ip:

10.0.0.130    172.16.0.130
10.0.0.131    172.16.0.131
10.0.0.132    172.16.0.132

三臺vm綁定主機(jī)名:

[root@mgr01 bin]# cat /etc/hosts
172.16.0.130 mgr01
172.16.0.131 mgr03
172.16.0.132 mgr02
[root@mgr02 ~]# cat /etc/hosts
172.16.0.132 mgr02
172.16.0.131 mgr03
172.16.0.130 mgr01
[root@mgr03 bin]# cat /etc/hosts
172.16.0.132 mgr02
172.16.0.131 mgr03
172.16.0.130 mgr01

提示:orchestrator 建議使用機(jī)器名,而不是ip來管理MySQL實(shí)例,比如change master to 中的 master_host 如果指定的是ip,有可能導(dǎo)致主從切換或者故障切換出現(xiàn)問題
所以最好是綁定hosts,設(shè)置主機(jī)名

1.2、三臺vm上安裝mysql說明

 安裝MySQL的步驟省略,和常規(guī)安裝MySQL一樣。

提前配置好一主2從mysql 基于Gtid 過濾復(fù)制

    172.16.0.131  master
    172.16.0.130  slave 
    172.16.0.132  slave

三臺vm實(shí)例mysql的配置文件都要開啟如下參數(shù):
說明:開啟gtid,只復(fù)制測試庫test001下的表,其他的數(shù)據(jù)庫都忽略掉

[root@mgr01 orchestrator]# egrep -i 'gtid|replicate_wild' /data/mysql/mysql3306/my3306.cnf
####: for gtid
#gtid_executed_compression_period    =1000                          #   1000
gtid_mode                           =on                            #    off
enforce_gtid_consistency            =on                            #    off
replicate_wild_do_table=test001.%
replicate_wild_ignore_table=information_schema.%
replicate_wild_ignore_table=performance_schema.%
replicate_wild_ignore_table=mysql.%
replicate_wild_ignore_table=orchestrator.%  

172.16.0.131: master操作:

mysql -uroot -p'123456' -e "reset mater;"
mysql -e "grant replication slave on *.* to repuser@'172.16.0.%' identified by 'JuwoSdk21TbUser'; flush privileges;"
mysqldump -uroot -p'123456' -B -A -F --set-gtid-purged=OFF  --master-data=2 --single-transaction  --events|gzip >/opt/test_$(date +%F).sql.gz

172.16.0.130:slave 操作:

mysql < /test_$(date +%F).sql.gz
mysql  -e "CHANGE MASTER TO MASTER_HOST='mgr03',MASTER_PORT=3306,MASTER_USER='repuser',MASTER_PASSWORD='JuwoSdk21TbUser',MASTER_AUTO_POSITION = 1;start slave;show slave status\G" |grep -i "yes"

172.16.0.132 slave 操作:

mysql < /test_$(date +%F).sql.gz
mysql  -e "CHANGE MASTER TO MASTER_HOST='mgr03',MASTER_PORT=3306,MASTER_USER='repuser',MASTER_PASSWORD='JuwoSdk21TbUser',MASTER_AUTO_POSITION = 1;start slave;show slave status\G" |grep -i "yes"

二、三臺vm上安裝Orchestrator

2.1、機(jī)器角色說明:

orchestrator機(jī)器:172.16.0.130  172.16.0.131 172.16.0.132
orchestrator后端元數(shù)據(jù)庫MySQL:172.16.0.131
監(jiān)控目標(biāo)數(shù)據(jù)庫:172.16.0.130  172.16.0.131 172.16.0.132

2.2、每臺VM機(jī)器都執(zhí)行下面命令

安裝orchestrator:
下載orchestrator安裝包,orchestrator-3.1.4-linux-amd64.tar.gz
https://github.com/github/orchestrator/releases

解壓orchestrator安裝包:
tar -xf orchestrator-3.1.4-linux-amd64.tar.gz 
會多出usr 、etc下面2個(gè)目錄:
[root@mgr01 ~]# ls -lrt /root/
drwxr-xr-x  3 root root      4096 Jan 26 22:05 usr
drwxr-xr-x  3 root root      4096 Jan 26 22:05 etc

將usr/local/orchestrator/orchestrator-sample.conf.json移動到/etc下,并命名為orchestrator.conf.json

cp /root/usr/local/orchestrator/orchestrator-sample.conf.json /etc/orchestrator.conf.json

安裝完成后創(chuàng)建orchestrator需要用到的庫和用戶:

CREATE DATABASE orchestrator;
CREATE USER 'orchestrator'@'127.0.0.1' IDENTIFIED BY 'orchestrator';
GRANT ALL PRIVILEGES ON `orchestrator`.* TO 'orchestrator'@'127.0.0.1';
這里元數(shù)據(jù)庫MySQL和orchestrator在同一臺機(jī)器上,所以創(chuàng)建賬號的時(shí)候用的'127.0.0.1',
如果不在同一臺機(jī)器上,將IP換成orchestrator所在機(jī)器ip。

監(jiān)控目標(biāo)數(shù)據(jù)庫授權(quán):

在需要監(jiān)控的目標(biāo)數(shù)據(jù)庫上進(jìn)行授權(quán)
CREATE USER 'orchestrator'@'172.16.0.%'  IDENTIFIED BY 'orchestrator';
GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orchestrator'@'172.16.0.%';
GRANT SELECT ON mysql.slave_master_info TO 'orchestrator'@'172.16.0.%';
提示:
MySQLTopologyUser 賬號的權(quán)限應(yīng)該設(shè)置為super,process,reload,select,replicatiopn slave,
官網(wǎng)文檔中缺少了select權(quán)限,orchestrator切換過程中需要通過讀取從庫的mysql.slave_master_info表,獲取復(fù)制賬號和密碼,如果沒有select權(quán)限,將導(dǎo)致讀取失敗,并且不會有任何錯(cuò)誤信息報(bào)出來。

2.3、每臺VM修改orchestrator配置文件

修改/etc/orchestrator.conf.json如下:

####配置orchestrator后端元數(shù)據(jù)庫信息

"MySQLOrchestratorHost": "127.0.0.1",
"MySQLOrchestratorPort": 3306,
"MySQLOrchestratorDatabase": "orchestrator",
"MySQLOrchestratorUser": "orchestrator",
"MySQLOrchestratorPassword": "orchestrator",

###配置orchestrator監(jiān)控的目標(biāo)數(shù)據(jù)庫信息

"MySQLTopologyUser": "orchestrator",
"MySQLTopologyPassword": "orchestrator",

2.4、只單獨(dú)啟動一臺orchestrator服務(wù)

單獨(dú)啟動172.16.0.131 機(jī)器上的orchestrator服務(wù),默認(rèn)監(jiān)聽的端口是3000
啟動命令:

cd /root/usr/local/orchestrator && ./orchestrator --config=/etc/orchestrator.conf.json http &
[root@mgr01 ~]# ps -ef|grep orc
root       3478   3477  6 23:47 pts/3    00:00:02 ./orchestrator --config=/etc/orchestrator.conf.json http
root       3489   2648  0 23:48 pts/2    00:00:00 grep --color=auto orc
[root@mgr01 ~]# ss -lntup|grep orc
tcp    LISTEN     0      128      :::3000                 :::*                   users:(("orchestrator",pid=3478,fd=5))

日志中有報(bào)錯(cuò):

2020-02-20 23:47:40 ERROR ReadTopologyInstance(mgr01:3306) show slave hosts: ReadTopologyInstance(mgr01:3306) 'show slave hosts' returned row with <host,port>: <,3306>
2020-02-20 23:47:41 DEBUG Waiting for 15 seconds to pass before running failure detection/recovery
2020-02-20 23:47:41 ERROR ReadTopologyInstance(mgr02:3306) show slave hosts: ReadTopologyInstance(mgr02:3306) 'show slave hosts' returned row with <host,port>: <,3306>

報(bào)錯(cuò)的解決辦法:
在MySQL配置文件my.cnf中report_host參數(shù),
report_host為只讀參數(shù),必須重啟mysql服務(wù)才可生效
report_host=x.x.x.x  //ip為服務(wù)器自身的ip
提示:關(guān)于mysql的report-系列參數(shù)說明如下:
#report-系列Report系列是設(shè)置在從庫上的,包含四個(gè)參數(shù) report-[host|port|user|password].
當(dāng)my.cnf中設(shè)置了report-host時(shí),在從庫執(zhí)行start slave的時(shí)候,會將report-host和report-port(默認(rèn)3306)發(fā)給主庫,主庫記錄在全局哈希結(jié)構(gòu)變量 slave_list 中
同時(shí)需要注意的是 mysql對report_host限制為最長60個(gè)字節(jié)長度,也就是非中文的60個(gè)字符,所以mysql服務(wù)器的主機(jī)名要小于60個(gè)字符,否則在做主從復(fù)制時(shí),slave會報(bào)錯(cuò)
參考:https://www.jianshu.com/p/9a5b7d30b0ae

原因:my.cnf配置文件不加report_host ,在orchestrator程序中 show slave hosts 不會顯示host,會導(dǎo)致程序報(bào)錯(cuò)的
或者是修改/etc/orchestrator.conf.json 配置文件參數(shù)DiscoverByShowSlaveHosts 為false,重啟orchestrator 服務(wù),這樣就不需要設(shè)置report_host了

2.5、Web頁面訪問介紹

http://10.0.0.130:3000/web/status

初次打開web頁面是看不到mysql cluster 集群名稱的,需要點(diǎn)擊discover發(fā)現(xiàn)instance,如下圖:
如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?
如何在三臺vm上安裝Orchestrator?

再次點(diǎn)擊Clusters,便出現(xiàn)集群別名和Instance:
如何在三臺vm上安裝Orchestrator?

選擇home下的status,可以看到當(dāng)前的健康的節(jié)點(diǎn):
如何在三臺vm上安裝Orchestrator?
查看詳細(xì)的復(fù)制拓?fù)?

如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?
查看關(guān)于復(fù)制失敗的分析:
如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?

關(guān)于復(fù)制失敗的診斷:

如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?

查看復(fù)制的詳細(xì)的信息:
如何在三臺vm上安裝Orchestrator?

在線調(diào)整復(fù)制關(guān)系有1主2從變?yōu)榧壜?lián)復(fù)制:
如何在三臺vm上安裝Orchestrator?

如何在三臺vm上安裝Orchestrator?

再由級聯(lián)復(fù)制變?yōu)?主2從:
如何在三臺vm上安裝Orchestrator?

以上就是關(guān)于的orchestrator服務(wù)單節(jié)點(diǎn)啟動管理mysql復(fù)制集群的簡單web頁面應(yīng)用介紹,

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI