安装git

  1. sudo yum install git
  1. docker build -t orchestrator:latest .
  1. docker run -d -p 3000:3000 \
  2. -v /docker/orchestrator/conf.json:/etc/orchestrator.conf.json \
  3. --name orc dzd624175217/orchestrator

下列环境变量可用,并且如果没有配置文件绑定安装到容器中,则以下环境变量生效 /etc/orchestrator.conf.json
ORC_TOPOLOGY_USER:默认为 orchestrator
ORC_TOPOLOGY_PASSWORD:默认为 orchestrator
ORC_DB_HOST:默认为 db
ORC_DB_PORT:默认为 3306
ORC_DB_NAME:默认为 orchestrator
ORC_USER:默认为orc_server_user
ORC_PASSWORD:默认为 orc_server_password
要设置这些变量,可以将它们添加到环境文件中,然后在其中添加它们key=value(每行一对)。然后,您可以将此环境文件传递给docker命令,添加—env-file=path/to/env-file到该docker run命令中

conf.json

  1. {
  2. "Debug": true,
  3. "EnableSyslog": false,
  4. "ListenAddress": ":3000",
  5. "MySQLTopologyUser": "orc_client_user",
  6. "MySQLTopologyPassword": "orc_client_password",
  7. "MySQLTopologyCredentialsConfigFile": "",
  8. "MySQLTopologySSLPrivateKeyFile": "",
  9. "MySQLTopologySSLCertFile": "",
  10. "MySQLTopologySSLCAFile": "",
  11. "MySQLTopologySSLSkipVerify": true,
  12. "MySQLTopologyUseMutualTLS": false,
  13. "BackendDB": "sqlite",
  14. "SQLite3DataFile": "/usr/local/orchestrator/orchestrator.sqlite3",
  15. "MySQLConnectTimeoutSeconds": 1,
  16. "DefaultInstancePort": 3306,
  17. "DiscoverByShowSlaveHosts": true,
  18. "InstancePollSeconds": 5,
  19. "DiscoveryIgnoreReplicaHostnameFilters": [
  20. "a_host_i_want_to_ignore[.]example[.]com",
  21. ".*[.]ignore_all_hosts_from_this_domain[.]example[.]com",
  22. "a_host_with_extra_port_i_want_to_ignore[.]example[.]com:3307"
  23. ],
  24. "UnseenInstanceForgetHours": 240,
  25. "SnapshotTopologiesIntervalHours": 0,
  26. "InstanceBulkOperationsWaitTimeoutSeconds": 10,
  27. "HostnameResolveMethod": "default",
  28. "MySQLHostnameResolveMethod": "@@hostname",
  29. "SkipBinlogServerUnresolveCheck": true,
  30. "ExpiryHostnameResolvesMinutes": 60,
  31. "RejectHostnameResolvePattern": "",
  32. "ReasonableReplicationLagSeconds": 10,
  33. "ProblemIgnoreHostnameFilters": [],
  34. "VerifyReplicationFilters": false,
  35. "ReasonableMaintenanceReplicationLagSeconds": 20,
  36. "CandidateInstanceExpireMinutes": 60,
  37. "AuditLogFile": "",
  38. "AuditToSyslog": false,
  39. "RemoveTextFromHostnameDisplay": ".mydomain.com:3306",
  40. "ReadOnly": false,
  41. "AuthenticationMethod": "",
  42. "HTTPAuthUser": "",
  43. "HTTPAuthPassword": "",
  44. "AuthUserHeader": "",
  45. "PowerAuthUsers": [
  46. "*"
  47. ],
  48. "ClusterNameToAlias": {
  49. "127.0.0.1": "test suite"
  50. },
  51. "SlaveLagQuery": "",
  52. "DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)",
  53. "DetectClusterDomainQuery": "",
  54. "DetectInstanceAliasQuery": "",
  55. "DetectPromotionRuleQuery": "",
  56. "DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com",
  57. "PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com",
  58. "PromotionIgnoreHostnameFilters": [],
  59. "DetectSemiSyncEnforcedQuery": "",
  60. "ServeAgentsHttp": false,
  61. "AgentsServerPort": ":3001",
  62. "AgentsUseSSL": false,
  63. "AgentsUseMutualTLS": false,
  64. "AgentSSLSkipVerify": false,
  65. "AgentSSLPrivateKeyFile": "",
  66. "AgentSSLCertFile": "",
  67. "AgentSSLCAFile": "",
  68. "AgentSSLValidOUs": [],
  69. "UseSSL": false,
  70. "UseMutualTLS": false,
  71. "SSLSkipVerify": false,
  72. "SSLPrivateKeyFile": "",
  73. "SSLCertFile": "",
  74. "SSLCAFile": "",
  75. "SSLValidOUs": [],
  76. "URLPrefix": "",
  77. "StatusEndpoint": "/api/status",
  78. "StatusSimpleHealth": true,
  79. "StatusOUVerify": false,
  80. "AgentPollMinutes": 60,
  81. "UnseenAgentForgetHours": 6,
  82. "StaleSeedFailMinutes": 60,
  83. "SeedAcceptableBytesDiff": 8192,
  84. "PseudoGTIDPattern": "",
  85. "PseudoGTIDPatternIsFixedSubstring": false,
  86. "PseudoGTIDMonotonicHint": "asc:",
  87. "DetectPseudoGTIDQuery": "",
  88. "BinlogEventsChunkSize": 10000,
  89. "SkipBinlogEventsContaining": [],
  90. "ReduceReplicationAnalysisCount": true,
  91. "FailureDetectionPeriodBlockMinutes": 60,
  92. "RecoveryPeriodBlockSeconds": 3600,
  93. "RecoveryIgnoreHostnameFilters": [],
  94. "RecoverMasterClusterFilters": [
  95. "_master_pattern_"
  96. ],
  97. "RecoverIntermediateMasterClusterFilters": [
  98. "_intermediate_master_pattern_"
  99. ],
  100. "OnFailureDetectionProcesses": [
  101. "echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
  102. ],
  103. "PreFailoverProcesses": [
  104. "echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
  105. ],
  106. "PostFailoverProcesses": [
  107. "echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
  108. ],
  109. "PostUnsuccessfulFailoverProcesses": [],
  110. "PostMasterFailoverProcesses": [
  111. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
  112. ],
  113. "PostIntermediateMasterFailoverProcesses": [
  114. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
  115. ],
  116. "CoMasterRecoveryMustPromoteOtherCoMaster": true,
  117. "DetachLostSlavesAfterMasterFailover": true,
  118. "ApplyMySQLPromotionAfterMasterFailover": true,
  119. "PreventCrossDataCenterMasterFailover": false,
  120. "PreventCrossRegionMasterFailover": false,
  121. "MasterFailoverDetachSlaveMasterHost": false,
  122. "MasterFailoverLostInstancesDowntimeMinutes": 0,
  123. "PostponeSlaveRecoveryOnLagMinutes": 0,
  124. "OSCIgnoreHostnameFilters": [],
  125. "GraphiteAddr": "",
  126. "GraphitePath": "",
  127. "GraphiteConvertHostnameDotsToUnderscores": true
  128. }
  1. docker run -d --name orc \
  2. --net orchnet --ip 172.20.0.10 \
  3. -v /home/docker/orc/conf.json:/etc/orchestrator.conf.json \
  4. -p 3000:3000 dzd624175217/orchestrator:latest
  1. for N in 1 2 3
  2. do docker run -d --name=node$N --hostname=node$N --net orchnet --ip "172.20.0.1$N" \
  3. -v $PWD/d$N:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mypass \
  4. mysql/mysql-server:8.0.15 \
  5. --server-id=$N \
  6. --enforce-gtid-consistency='ON' \
  7. --log-slave-updates='ON' \
  8. --gtid-mode='ON' \
  9. --log-bin='mysql-bin-1.log'
  10. done
  1. docker exec -it node1 mysql -uroot -pmypass \
  2. -e "CREATE USER 'repl'@'%' IDENTIFIED WITH mysql_native_password BY 'slavepass';" \
  3. -e "GRANT REPLICATION SLAVE ON *.* TO 'repl'@'%';" \
  4. -e "SHOW MASTER STATUS;"
  1. for N in 2 3
  2. do docker exec -it node$N mysql -uroot -pmypass \
  3. -e "CHANGE MASTER TO MASTER_HOST='172.20.0.11', MASTER_PORT=3306, \
  4. MASTER_USER='repl', MASTER_PASSWORD='slavepass', MASTER_AUTO_POSITION = 1;"
  5. docker exec -it node$N mysql -uroot -pmypass -e "START SLAVE;"
  6. done
  1. docker exec -it node1 mysql -uroot -pmypass \
  2. -e "CREATE USER 'orc_client_user'@'172.20.0.10' IDENTIFIED BY 'orc_client_password';" \
  3. -e "GRANT SUPER, PROCESS, REPLICATION SLAVE, RELOAD ON *.* TO 'orc_client_user'@'172.20.0.10';" \
  4. -e "GRANT SELECT ON mysql.slave_master_info TO 'orc_client_user'@'172.20.0.10';"

image.png

参考

【官方】docker镜像制作
https://github.com/wagnerjfr/orchestrator-mysql-replication-docker
https://segmentfault.com/a/1190000017838535
https://www.cnblogs.com/zhoujinyi/p/10387581.html