环境说明后台管理节点172.16.0.128:3306
被监测MYSQL集群172.16.0.125:3306172.16.0.126:3306
被监测MYSQL集群mysql5.6以上,开启GTID复制
后台管理节点CentOS Linux release 7.2以上,不然可能会出现缺少依赖包。安装MySQL数据库,在启动Orchestrator程序的时候,会自动在数据库里创建orchestrator数据库,保存orchestrator的一些数据信息。
下载安装包https://github.com/github/orchestrator/releaseswget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-3.1.2-1.x86_64.rpm -服务包wget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-cli-3.1.2-1.x86_64.rpm -二进制命令wget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-client-3.1.2-1.x86_64.rpm -命令行工具
MYSQL集群和orch后台管理节点都安装[root@localhost ~]# rpm -ivh orchestrator-*Preparing... ################################# [100%]Updating / installing... 1:orchestrator-cli-1:3.1.2-1 ################################# [100%]Preparing... ################################# [100%]Updating / installing... 1:orchestrator-1:3.1.2-1 ################################# [100%] 安装后会在/usr/local下生成orchestrator目录,包含以下文件和目录:orchestrator-sample-sqlite.conf.json 采用SQLite库模板orchestrator-sample.conf.json 默认的配置模板orchestrator 应用程序resources orchestrator相关的文件:client、web、伪GTID等相关文件
创建后台管理节点的库和用户CREATE DATABASE IF NOT EXISTS orchestrator;GRANT ALL PRIVILEGES ON `orchestrator`.* TO 'orc_server_user'@'%' IDENTIFIED BY 'chengce243';
被监测的MYSQL授权GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'%' IDENTIFIED BY 'chengce243';
my.cnf 中配置[mysqld] report-host=IP125配置report_host=172.16.0.125
126配置report_host=172.16.0.126
128配置report_host=172.16.0.128
三台 /etc/hosts均需要配置172.16.0.125 testdb172.16.0.126 testdb2172.16.0.128 testdb3
修改配置文件cd /usr/local/orchestrator/cp orchestrator-sample.conf.json orchestrator.conf.json
{ "Debug": false, "EnableSyslog": false, "ListenAddress": ":3000", "MySQLTopologyUser": "orc_client_user", "MySQLTopologyPassword": "chengce243", "MySQLTopologyCredentialsConfigFile": "", "MySQLTopologySSLPrivateKeyFile": "", "MySQLTopologySSLCertFile": "", "MySQLTopologySSLCAFile": "", "MySQLTopologySSLSkipVerify": true, "MySQLTopologyUseMutualTLS": false, "MySQLOrchestratorHost": "172.16.0.128", "MySQLOrchestratorPort": 3306, "MySQLOrchestratorDatabase": "orchestrator", "MySQLOrchestratorUser": "orc_server_user", "MySQLOrchestratorPassword": "chengce243", "MySQLOrchestratorCredentialsConfigFile": "", "MySQLOrchestratorSSLPrivateKeyFile": "", "MySQLOrchestratorSSLCertFile": "", "MySQLOrchestratorSSLCAFile": "", "MySQLOrchestratorSSLSkipVerify": true, "MySQLOrchestratorUseMutualTLS": false, "MySQLConnectTimeoutSeconds": 1, "DefaultInstancePort": 3306, "DiscoverByShowSlaveHosts": true, "InstancePollSeconds": 5, "DiscoveryIgnoreReplicaHostnameFilters": [ "a_host_i_want_to_ignore[.]example[.]com", ".*[.]ignore_all_hosts_from_this_domain[.]example[.]com", "a_host_with_extra_port_i_want_to_ignore[.]example[.]com:3307" ], "UnseenInstanceForgetHours": 240, "SnapshotTopologiesIntervalHours": 0, "InstanceBulkOperationsWaitTimeoutSeconds": 10, "HostnameResolveMethod": "default", "MySQLHostnameResolveMethod": "@@hostname", "SkipBinlogServerUnresolveCheck": true, "ExpiryHostnameResolvesMinutes": 60, "RejectHostnameResolvePattern": "", "ReasonableReplicationLagSeconds": 10, "ProblemIgnoreHostnameFilters": [], "VerifyReplicationFilters": false, "ReasonableMaintenanceReplicationLagSeconds": 20, "CandidateInstanceExpireMinutes": 60, "AuditLogFile": "", "AuditToSyslog": false, "RemoveTextFromHostnameDisplay": ".mydomain.com:3306", "ReadOnly": false, "AuthenticationMethod": "", "HTTPAuthUser": "", "HTTPAuthPassword": "", "AuthUserHeader": "", "PowerAuthUsers": [ "*" ], "ClusterNameToAlias": { "172.16.0.125": "liangguojun_cluster" }, "SlaveLagQuery": "", "DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)", "DetectClusterDomainQuery": "", "DetectInstanceAliasQuery": "", "DetectPromotionRuleQuery": "", "DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com", "PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com", "PromotionIgnoreHostnameFilters": [], "DetectSemiSyncEnforcedQuery": "", "ServeAgentsHttp": false, "AgentsServerPort": ":3001", "AgentsUseSSL": false, "AgentsUseMutualTLS": false, "AgentSSLSkipVerify": false, "AgentSSLPrivateKeyFile": "", "AgentSSLCertFile": "", "AgentSSLCAFile": "", "AgentSSLValidOUs": [], "UseSSL": false, "UseMutualTLS": false, "SSLSkipVerify": false, "SSLPrivateKeyFile": "", "SSLCertFile": "", "SSLCAFile": "", "SSLValidOUs": [], "URLPrefix": "", "StatusEndpoint": "/api/status", "StatusSimpleHealth": true, "StatusOUVerify": false, "AgentPollMinutes": 60, "UnseenAgentForgetHours": 6, "StaleSeedFailMinutes": 60, "SeedAcceptableBytesDiff": 8192, "PseudoGTIDPattern": "", "PseudoGTIDPatternIsFixedSubstring": false, "PseudoGTIDMonotonicHint": "asc:", "DetectPseudoGTIDQuery": "", "BinlogEventsChunkSize": 10000, "SkipBinlogEventsContaining": [], "ReduceReplicationAnalysisCount": true, "FailureDetectionPeriodBlockMinutes": 60, "RecoveryPeriodBlockSeconds": 3600, "RecoveryIgnoreHostnameFilters": [], "RecoverMasterClusterFilters": [ "_master_pattern_" ], "RecoverIntermediateMasterClusterFilters": [ "_intermediate_master_pattern_" ], "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": [ "echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log" ], "PostUnsuccessfulFailoverProcesses": [], "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" ], "PostTakeMasterProcesses": [ "echo 'Running PostTakeMasterProcesses Hook' >> /tmp/recovery.log" ], "PostGracefulTakeoverProcesses": [ "echo 'Planned takeover complete' >> /tmp/recovery.log" ], "CoMasterRecoveryMustPromoteOtherCoMaster": true, "DetachLostSlavesAfterMasterFailover": true, "ApplyMySQLPromotionAfterMasterFailover": true, "PreventCrossDataCenterMasterFailover": false, "PreventCrossRegionMasterFailover": false, "MasterFailoverDetachSlaveMasterHost": false, "MasterFailoverLostInstancesDowntimeMinutes": 0, "PostponeSlaveRecoveryOnLagMinutes": 0, "OSCIgnoreHostnameFilters": [], "GraphiteAddr": "", "GraphitePath": "", "GraphiteConvertHostnameDotsToUnderscores": true, "ConsulAddress": "", "ConsulAclToken": ""}
官方参考配置:https://github.com/github/orchestrator/blob/master/docs/configuration-sample.md
启动/usr/local/orchestrator/orchestrator -config=/usr/local/orchestrator/orchestrator.conf.json http &
查看端口[root@localhost orchestrator]# netstat -nltp|grep 3000tcp6 0 0 :::3000 :::* LISTEN 574969/orchestrator
命令行注册集群orchestrator -config=/usr/local/orchestrator/orchestrator.conf.json -c discover -i 172.16.0.125:3306
命令行查看集群orchestrator -c clusters
通过web访问http://172.16.0.128:3000
被监测MYSQL集群172.16.0.125:3306172.16.0.126:3306
被监测MYSQL集群mysql5.6以上,开启GTID复制
后台管理节点CentOS Linux release 7.2以上,不然可能会出现缺少依赖包。安装MySQL数据库,在启动Orchestrator程序的时候,会自动在数据库里创建orchestrator数据库,保存orchestrator的一些数据信息。
下载安装包https://github.com/github/orchestrator/releaseswget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-3.1.2-1.x86_64.rpm -服务包wget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-cli-3.1.2-1.x86_64.rpm -二进制命令wget https://github.com/github/orchestrator/releases/download/v3.1.2/orchestrator-client-3.1.2-1.x86_64.rpm -命令行工具
MYSQL集群和orch后台管理节点都安装[root@localhost ~]# rpm -ivh orchestrator-*Preparing... ################################# [100%]Updating / installing... 1:orchestrator-cli-1:3.1.2-1 ################################# [100%]Preparing... ################################# [100%]Updating / installing... 1:orchestrator-1:3.1.2-1 ################################# [100%] 安装后会在/usr/local下生成orchestrator目录,包含以下文件和目录:orchestrator-sample-sqlite.conf.json 采用SQLite库模板orchestrator-sample.conf.json 默认的配置模板orchestrator 应用程序resources orchestrator相关的文件:client、web、伪GTID等相关文件
创建后台管理节点的库和用户CREATE DATABASE IF NOT EXISTS orchestrator;GRANT ALL PRIVILEGES ON `orchestrator`.* TO 'orc_server_user'@'%' IDENTIFIED BY 'chengce243';
被监测的MYSQL授权GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'%' IDENTIFIED BY 'chengce243';
my.cnf 中配置[mysqld] report-host=IP125配置report_host=172.16.0.125
126配置report_host=172.16.0.126
128配置report_host=172.16.0.128
三台 /etc/hosts均需要配置172.16.0.125 testdb172.16.0.126 testdb2172.16.0.128 testdb3
修改配置文件cd /usr/local/orchestrator/cp orchestrator-sample.conf.json orchestrator.conf.json
{ "Debug": false, "EnableSyslog": false, "ListenAddress": ":3000", "MySQLTopologyUser": "orc_client_user", "MySQLTopologyPassword": "chengce243", "MySQLTopologyCredentialsConfigFile": "", "MySQLTopologySSLPrivateKeyFile": "", "MySQLTopologySSLCertFile": "", "MySQLTopologySSLCAFile": "", "MySQLTopologySSLSkipVerify": true, "MySQLTopologyUseMutualTLS": false, "MySQLOrchestratorHost": "172.16.0.128", "MySQLOrchestratorPort": 3306, "MySQLOrchestratorDatabase": "orchestrator", "MySQLOrchestratorUser": "orc_server_user", "MySQLOrchestratorPassword": "chengce243", "MySQLOrchestratorCredentialsConfigFile": "", "MySQLOrchestratorSSLPrivateKeyFile": "", "MySQLOrchestratorSSLCertFile": "", "MySQLOrchestratorSSLCAFile": "", "MySQLOrchestratorSSLSkipVerify": true, "MySQLOrchestratorUseMutualTLS": false, "MySQLConnectTimeoutSeconds": 1, "DefaultInstancePort": 3306, "DiscoverByShowSlaveHosts": true, "InstancePollSeconds": 5, "DiscoveryIgnoreReplicaHostnameFilters": [ "a_host_i_want_to_ignore[.]example[.]com", ".*[.]ignore_all_hosts_from_this_domain[.]example[.]com", "a_host_with_extra_port_i_want_to_ignore[.]example[.]com:3307" ], "UnseenInstanceForgetHours": 240, "SnapshotTopologiesIntervalHours": 0, "InstanceBulkOperationsWaitTimeoutSeconds": 10, "HostnameResolveMethod": "default", "MySQLHostnameResolveMethod": "@@hostname", "SkipBinlogServerUnresolveCheck": true, "ExpiryHostnameResolvesMinutes": 60, "RejectHostnameResolvePattern": "", "ReasonableReplicationLagSeconds": 10, "ProblemIgnoreHostnameFilters": [], "VerifyReplicationFilters": false, "ReasonableMaintenanceReplicationLagSeconds": 20, "CandidateInstanceExpireMinutes": 60, "AuditLogFile": "", "AuditToSyslog": false, "RemoveTextFromHostnameDisplay": ".mydomain.com:3306", "ReadOnly": false, "AuthenticationMethod": "", "HTTPAuthUser": "", "HTTPAuthPassword": "", "AuthUserHeader": "", "PowerAuthUsers": [ "*" ], "ClusterNameToAlias": { "172.16.0.125": "liangguojun_cluster" }, "SlaveLagQuery": "", "DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)", "DetectClusterDomainQuery": "", "DetectInstanceAliasQuery": "", "DetectPromotionRuleQuery": "", "DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com", "PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com", "PromotionIgnoreHostnameFilters": [], "DetectSemiSyncEnforcedQuery": "", "ServeAgentsHttp": false, "AgentsServerPort": ":3001", "AgentsUseSSL": false, "AgentsUseMutualTLS": false, "AgentSSLSkipVerify": false, "AgentSSLPrivateKeyFile": "", "AgentSSLCertFile": "", "AgentSSLCAFile": "", "AgentSSLValidOUs": [], "UseSSL": false, "UseMutualTLS": false, "SSLSkipVerify": false, "SSLPrivateKeyFile": "", "SSLCertFile": "", "SSLCAFile": "", "SSLValidOUs": [], "URLPrefix": "", "StatusEndpoint": "/api/status", "StatusSimpleHealth": true, "StatusOUVerify": false, "AgentPollMinutes": 60, "UnseenAgentForgetHours": 6, "StaleSeedFailMinutes": 60, "SeedAcceptableBytesDiff": 8192, "PseudoGTIDPattern": "", "PseudoGTIDPatternIsFixedSubstring": false, "PseudoGTIDMonotonicHint": "asc:", "DetectPseudoGTIDQuery": "", "BinlogEventsChunkSize": 10000, "SkipBinlogEventsContaining": [], "ReduceReplicationAnalysisCount": true, "FailureDetectionPeriodBlockMinutes": 60, "RecoveryPeriodBlockSeconds": 3600, "RecoveryIgnoreHostnameFilters": [], "RecoverMasterClusterFilters": [ "_master_pattern_" ], "RecoverIntermediateMasterClusterFilters": [ "_intermediate_master_pattern_" ], "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": [ "echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log" ], "PostUnsuccessfulFailoverProcesses": [], "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" ], "PostTakeMasterProcesses": [ "echo 'Running PostTakeMasterProcesses Hook' >> /tmp/recovery.log" ], "PostGracefulTakeoverProcesses": [ "echo 'Planned takeover complete' >> /tmp/recovery.log" ], "CoMasterRecoveryMustPromoteOtherCoMaster": true, "DetachLostSlavesAfterMasterFailover": true, "ApplyMySQLPromotionAfterMasterFailover": true, "PreventCrossDataCenterMasterFailover": false, "PreventCrossRegionMasterFailover": false, "MasterFailoverDetachSlaveMasterHost": false, "MasterFailoverLostInstancesDowntimeMinutes": 0, "PostponeSlaveRecoveryOnLagMinutes": 0, "OSCIgnoreHostnameFilters": [], "GraphiteAddr": "", "GraphitePath": "", "GraphiteConvertHostnameDotsToUnderscores": true, "ConsulAddress": "", "ConsulAclToken": ""}
官方参考配置:https://github.com/github/orchestrator/blob/master/docs/configuration-sample.md
启动/usr/local/orchestrator/orchestrator -config=/usr/local/orchestrator/orchestrator.conf.json http &
查看端口[root@localhost orchestrator]# netstat -nltp|grep 3000tcp6 0 0 :::3000 :::* LISTEN 574969/orchestrator
命令行注册集群orchestrator -config=/usr/local/orchestrator/orchestrator.conf.json -c discover -i 172.16.0.125:3306
命令行查看集群orchestrator -c clusters
通过web访问http://172.16.0.128:3000
1.出现如下错误
2019-10-21 14:25:07 ERROR ReadTopologyInstance(testdb:3306) show slave hosts: ReadTopologyInstance(testdb:3306) 'show slave hosts' returned row with <host,port>: <,3306>
解决:
Mysql主从复制,在master上查看从的信息:show slave hosts
http://dinglin.iteye.com/blog/1255160
默认不记录从的host信息,只记录端口和Server_id信息,需要设置my.cnf 中的[mysqld] report-host=IP
参考:https://riverdba.github.io/2019/03/19/orchestrator/