1. 準備
操作系統7(因爲要求glibc版本)
vim /etc/hosts (所有機器都要寫,都要編輯)
iptables 、 selinux 都要關閉
下載地址:https://github.com/github/orchestrator/releases/
2. 安裝
安裝要求:
操作系統7(因爲要求glibc版本>=2.14)
關閉iptables或開通orch所使用的端口 和 selinux
vim /etc/hosts : ip host
1.安裝orch(orchestrator、orchestrator-client)
rpm -ivh orch*
安裝依賴包jq-1.5、oniguruma-5.9.5
2.因orch依賴數據庫,這裏採用MySQL數據庫:orch與DB是1:1的關係
安裝MySQL(略)
在orch後端數據庫:
CREATE DATABASE IF NOT EXISTS orchestrator;
CREATE USER ‘orchestrator’@’%’ IDENTIFIED BY ‘123123’;
GRANT ALL PRIVILEGES ON orchestrator
.* TO ‘orchestrator’@’%’;
3.安裝orch管理的數據庫集羣上(這兒是一主兩從,也可以是雙master)
CREATE USER ‘orchestrator’@’%’ IDENTIFIED BY ‘123123’;
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’@’%’;
數據庫my.cnf 要加上 report_host= 、 report_port= log_slave_updates=1
4.修改配置文件orchestrator.conf.json
模板:
{
"Debug": true, #debug模式,輸出詳細信息
"EnableSyslog": false, #是否輸出到系統日誌裏
"ListenAddress": ":3000",#orch監聽的端口,web端口
"MySQLTopologyUser": "orchestrator", #後端被管理的集羣賬號:所有實例都要有
"MySQLTopologyPassword": "123123", #後端被管理的集羣密碼
"MySQLTopologyCredentialsConfigFile": "", #後端集羣的用戶密碼配置文件,賬號密碼可以直接寫入文件,讀取
"MySQLTopologySSLPrivateKeyFile": "", #SSL相關
"MySQLTopologySSLCertFile": "",
"MySQLTopologySSLCAFile": "",
"MySQLTopologySSLSkipVerify": true, #跳過SSL驗證
"MySQLTopologyUseMutualTLS": false, #是否使用TLS驗證
"MySQLOrchestratorHost": "192.168.192.30", #orch使用的數據庫所在主機
"MySQLOrchestratorPort": 3307, #orch使用的數據庫端口
"MySQLOrchestratorDatabase": "orchestrator", #連接 orch使用的數據庫的 庫名
"MySQLOrchestratorUser": "orchestrator", #連接 orch使用的數據庫的 用戶名
"MySQLOrchestratorPassword": "123123", #連接 orch使用的數據庫的 密碼
"MySQLOrchestratorCredentialsConfigFile": "", #orch使用數據庫的密碼驗證配置文件
"MySQLOrchestratorSSLPrivateKeyFile": "", #SSL相關
"MySQLOrchestratorSSLCertFile": "",
"MySQLOrchestratorSSLCAFile": "",
"MySQLOrchestratorSSLSkipVerify": true, #跳過SSL驗證
"MySQLOrchestratorUseMutualTLS": false, #是否使用TLS驗證
"MySQLConnectTimeoutSeconds": 1, #orch連接MySQL超時秒數
"DefaultInstancePort": 3306, #mysql 集羣實例端口,對外提供服務的實例(儘量做到集羣內實例端口一致)
"DiscoverByShowSlaveHosts": true, #是否使用show slave hosts自動發現集羣
"InstancePollSeconds": 5, #使用show slave hosts 探測間隔秒數
"UnseenInstanceForgetHours": 240, #忽略不可見的實例的小時數
"SnapshotTopologiesIntervalHours": 0, #快照拓撲調用之間的小時間隔。默認:0(表示禁用)
"InstanceBulkOperationsWaitTimeoutSeconds": 10,#執行批量操作時,在單個實例上等待的時間
"HostnameResolveMethod": "default", #解析主機名,默認使用主機名:default;不解析爲none,直接用IP
"MySQLHostnameResolveMethod": "@@hostname", #解析主機名,發出select @@hostname或發出select @@report_host(需要配置report_host);不解析用"",直接用IP。
"SkipBinlogServerUnresolveCheck": true, #跳過檢查 將未解析的主機名解析爲和binlog服務器相同的主機名
"ExpiryHostnameResolvesMinutes": 60, #域名檢測過期週期(分鐘)
"RejectHostnameResolvePattern": "", #禁止使用正則表達式表示域名
"ReasonableReplicationLagSeconds": 100, #複製延遲高於100S表示異常
"ProblemIgnoreHostnameFilters": [], #將主機做正則匹配篩選成最小化
"VerifyReplicationFilters": false, #在拓撲重構之前檢查複製篩選器
"ReasonableMaintenanceReplicationLagSeconds": 20, #複製延遲高於該值會上下移動調整MySQL拓撲
"CandidateInstanceExpireMinutes": 60, #該時間之後,使用實例作爲候選從庫(在主故障轉移時提升)的建議到期
"AuditLogFile": "", #審計日誌,空的時候禁用
"AuditToSyslog": false, #審計日誌是否寫入到系統日誌
"RemoveTextFromHostnameDisplay": ":3306", #去除集羣的文本
"ReadOnly": false, #全局只讀
"AuthenticationMethod": "", #身份驗證類型
"HTTPAuthUser": "", #http驗證用戶名
"HTTPAuthPassword": "",
"AuthUserHeader": "",
"PowerAuthUsers": [
"*"
],
"ClusterNameToAlias": { #正則表達式匹配集羣名稱和別名之間的映射
"127.0.0.1": "test suite"
},
"SlaveLagQuery": "", #使用show slave status 進行延遲判斷
"DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)",#查詢集羣別名
"DetectClusterDomainQuery": "",#可選查詢,返回集羣主服務器的VIP/別名/域名。
"DetectInstanceAliasQuery": "",#可選查詢,返回實例的別名
"DetectPromotionRuleQuery": "",#可選查詢,返回實例的提升規則
"DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com",#從主機名稱中提取數據中心名稱
"PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com", #從主機名中提取物理環境信息
"PromotionIgnoreHostnameFilters": [], #不使用主機名匹配模式來提升副本
"DetectSemiSyncEnforcedQuery": "", #檢測是否強制半同步
"ServeAgentsHttp": false, #產生一個專用於orche-client的HTTP端口
"AgentsServerPort": ":3001", #可選,對於raft設置,此節點將向其他節點通告HTTP的地址
"AgentsUseSSL": false, #當爲true時,orch將使用SSL偵聽代理端口已經通過SSL連接的代理
"AgentsUseMutualTLS": false, #當爲true時,使用TLS服務器與代理通信
"AgentSSLSkipVerify": false, #爲代理使用SSL
"AgentSSLPrivateKeyFile": "", #
"AgentSSLCertFile": "",
"AgentSSLCAFile": "",
"AgentSSLValidOUs": [],
"UseSSL": false, #在服務器WEB端口上使用SSL
"UseMutualTLS": false, #true時使用TLS作爲服務器的WEB和API連接
"SSLSkipVerify": false,
"SSLPrivateKeyFile": "",
"SSLCertFile": "",
"SSLCAFile": "",
"SSLValidOUs": [], #使用TLS交互
"URLPrefix": "", #在非跟web路徑上運行orch的URL前綴
"StatusEndpoint": "/api/status", #狀態查看
"StatusSimpleHealth": true,
"StatusOUVerify": false,
"AgentPollMinutes": 60, #代理之間輪詢的分鐘數
"UnseenAgentForgetHours": 6, #忘記不可見代理的小時數
"StaleSeedFailMinutes": 60, #無進展60分鐘後被認爲失敗
"SeedAcceptableBytesDiff": 8192, #種子源和目標源數據大小的字節差異仍被視爲成功複製
"PseudoGTIDPattern": "", #爲空時,禁用基於僞GTID的重構
"PseudoGTIDPatternIsFixedSubstring": false, #如爲TRUE,則上個參數不被視爲正則表達式而被視爲固定子字符串
"PseudoGTIDMonotonicHint": "asc:", #Pseudo-GTID條目中的子字符串,表示Pseudo-GTID條目預計會單調遞增
"DetectPseudoGTIDQuery": "", #可選查詢,用於決定是否在實例上啓用僞GTID
"BinlogEventsChunkSize": 10000, #show binlog events 塊的大小。較小意味着更少的鎖定和工作要做
"SkipBinlogEventsContaining": [], #掃描/比較Pseudo-GTID的binlog 時,跳過包含給定文本的條目。這些不是正則表達式(掃描binlog時會消耗太多的CPU),只需查找子字符串
"ReduceReplicationAnalysisCount": true, #如果爲true,則複製分析將報告可能首先處理問題的可能性的實例。 如果爲false,則爲每個已知實例提供一個條目
"FailureDetectionPeriodBlockMinutes": 60, #在該時間內再次出現故障,不會被再次發現
"RecoveryPeriodBlockSeconds": 3600, #在該時間內再次出現故障,不會進行failover,避免出現併發恢復和不穩定
"RecoveryIgnoreHostnameFilters": [], #恢復會忽略的主機
"RecoverMasterClusterFilters": [ #只對能匹配這些正則表達式模式的集羣進行主故障恢復
"*"
],
"RecoverIntermediateMasterClusterFilters": [ #只對能匹配這些正則表達式模式的集羣進行主故障恢復(“*”模式匹配所有)
"*"
],
"OnFailureDetectionProcesses": [ #檢測到主故障時執行的命令和腳本
"echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
],
"PreGracefulTakeoverProcesses": [ #在執行故障轉移之前執行的命令和腳本
"echo 'Planned takeover about to take place on {failureCluster}. Master will switch to read_only' >> /tmp/recovery.log"
],
"PreFailoverProcesses": [ #執行恢復操作前執行
"echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
],
"PostFailoverProcesses": [ #在failover全部成功後執行
"echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
"PostUnsuccessfulFailoverProcesses": [], #在failover失敗後執行
"PostMasterFailoverProcesses": [ #在主恢復成功結束時執行
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
"PostIntermediateMasterFailoverProcesses": [ #在中間主成功恢復結束時執行
"echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
],
"PostGracefulTakeoverProcesses": [ #在新主晉升之後執行
"echo 'Planned takeover complete' >> /tmp/recovery.log"
],
"CoMasterRecoveryMustPromoteOtherCoMaster": true, #當false時,任何實例都可以得到提升;當true時,將提升共同主人,否則失敗
"DetachLostSlavesAfterMasterFailover": true, #恢復過程中可能會丟失一些副本。如果爲true,將通過detach-replica命令強制中斷其複製,並認爲它們不正常運行。
"ApplyMySQLPromotionAfterMasterFailover": true, #在主上執行reset slave all,並設置read_only=0
"PreventCrossDataCenterMasterFailover": false, #如果爲true(默認值:false),則不允許跨DC主故障轉移,orchestrator將盡其所能僅在同一DC內進行故障轉移,否則不進行故障轉移。
"MasterFailoverDetachSlaveMasterHost": false, #是否應該在新升級的master上發出detach-replica-master-host,這樣可以確保新master不會嘗試複製正常之後的舊的master。如果參數ApplyMySQLPromotionAfterMasterFailover爲True,則該參數無意義。
"MasterFailoverLostInstancesDowntimeMinutes": 0, #主故障轉移後丟失的服務器停機的分鐘數(包括失敗的主和丟失的從)。0表示禁用
"PostponeSlaveRecoveryOnLagMinutes": 0, #在崩潰恢復時,延遲超過給定分鐘的從庫在主被選出後才復活。 值爲0將禁用此功能。
"OSCIgnoreHostnameFilters": [],
"GraphiteAddr": "",
"GraphitePath": "",
"GraphiteConvertHostnameDotsToUnderscores": true,
"ConsulAddress": "",
"ConsulAclToken": ""
"RaftEnabled": true, #raft模式
"BackendDB": "mysql", #後臺數據庫類型
"RaftBind": "192.168.192.20", #綁定之地,本機IP
"RaftDataDir": "/var/lib/orchestrator", #數據目錄,如果不存在,則自動創建
"DefaultRaftPort": 10008, #raft通信端口,所有機器必須保持一致
"RaftNodes": [ #raft節點,必須包含所有節點
"192.168.192.20",
"192.168.192.21",
"192.168.192.22"
]
}
5.啓動
注意:一定要使用非絕對路徑進行啓動
cd /usr/local/orchestrator
./orchestrator --debug --config=/usr/local/orchestrator/orchestrator.conf.json http &
6.WEB界面
參考:
https://www.cnblogs.com/geek-ace/p/9441706.html#commentform
https://www.cnblogs.com/zhoujinyi/p/10387581.html
VIP腳本
參考以下腳本自己寫的腳本路徑:
https://download.csdn.net/download/wangxin3618/11421332
https://download.csdn.net/download/wangxin3618/11421340