目录

Orchestrator总体结构... 

  测试环境信息... 

Orchestrator详细配置... 

  SSH免密配置... 

  /etc/hosts配置... 

  visudo配置... 

  /etc/orchestrator.conf.json

  orch_hook.sh. 

  orch_vip.sh. 

MySQL Server配置... 

测试导换... 

  启动orchestrator. 

  登录Web并发现实例... 

  切换前... 

  切换后... 

  Orchestrator是如何监测Master异常的...

总结... 

参考资料

 

Orchestrator是最近非常流行的MySQL复制管理工具。相关的资料也相当的多,但是总是缺点什么。

那就是步骤不够详细,按照博客的操作,很多都无法成功。说实话,看了N多博客后,我倒腾了一周时间才成功。

特别是Orchestrator后台也使用MySQL存储,这样容易把人绕进去了(分不清参数哪个是Orchestrator用,哪个是连接mysql实例用了)。

所以在这个博客,我将使用Sqlite存储。并把每一步操作都详细列举出来。

Orchestrator总体结构

一图胜千言。上图就是Orchestrator的架构图。

图中:Sqlite/MySQL,是Orchestrator的后端存储数据库(存储监控的mysql复制实例的相关状态信息),可以选择MySQL,也可以选择SQLite。

/etc/orchestrator.conf.json是配置文件,Orchestrator启动时读取。

下面部分是监控的MySQL的实例,本例中,我是搭建的一主,两从。当然,实际上Orchestrator可以监控成百上千个MySQL复制集群。

测试环境信息

orch 192.168.56.130

host01 192.168.56.103

host02 192.168.56.104

host03: 192.168.56.105

Orchestrator详细配置

SSH免密配置

参考如下链接,在这里,我创建的是orch帐号。创建免费登录的作用是shell脚本通过ssh登录Mysql服务器进行VIP切换。

https://www.cnblogs.com/chasetimeyang/p/15064507.html

/etc/hosts配置

同样,用于Shell脚本。

  1. [orch@orch orchestrator]$ cat /etc/hosts
  2. 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
  3. ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
  4. 192.168.56.103 host01
  5. 192.168.56.104 host02
  6. 192.168.56.105 host03
  7. 192.168.56.130 orch

visudo配置

因为我的VIP shell导换脚本内,用到了sudo执行高权限命令。你可以通过如下方法把用户加入sudo权限。

$visudo

orch ALL=(ALL) NOPASSWD: ALL

/etc/orchestrator.conf.json

如下两个参数是连接要监控的MySQL实例的连接用户名和密码
"MySQLTopologyUser": "orchestrator",
"MySQLTopologyPassword": "orc_topology_password",

如下说明是Sqlite作为后端存储数据库
"BackendDB": "sqlite",
"SQLite3DataFile": "/usr/local/orchestrator/orchestrator.sqlite3",

如下参数是实例导换后,多长时间内不允许再次导换。默认是60分钟。
"FailureDetectionPeriodBlockMinutes": 5,

如下参数是指,恢复匹配任何实例。(你也可以配置匹配规则,如此满足规则是会自动导换。不满足的,出现问题时,只能手动导换)
"RecoverMasterClusterFilters": [
"*"
],
"RecoverIntermediateMasterClusterFilters": [
"*"
], 

是否自动导换。
"ApplyMySQLPromotionAfterMasterFailover": true,

这个是导换后执行的脚本
"PostFailoverProcesses": [
"echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log",
"/home/orch/orch_hook.sh {failureType} {failureClusterAlias} {failedHost} {successorHost} >> /tmp/orch.log"
],

  1.  
  1. [orch@orch ~]$ cat /etc/orchestrator.conf.json
  2. {
  3. "Debug": true,
  4. "EnableSyslog": false,
  5. "ListenAddress": ":3000",
  6. "MySQLTopologyUser": "orchestrator",
  7. "MySQLTopologyPassword": "orc_topology_password",
  8. "MySQLTopologyCredentialsConfigFile": "",
  9. "MySQLTopologySSLPrivateKeyFile": "",
  10. "MySQLTopologySSLCertFile": "",
  11. "MySQLTopologySSLCAFile": "",
  12. "MySQLTopologySSLSkipVerify": true,
  13. "MySQLTopologyUseMutualTLS": false,
  14. "BackendDB": "sqlite",
  15. "SQLite3DataFile": "/usr/local/orchestrator/orchestrator.sqlite3",
  16. "MySQLConnectTimeoutSeconds": 1,
  17. "DefaultInstancePort": 3306,
  18. "DiscoverByShowSlaveHosts": true,
  19. "InstancePollSeconds": 5,
  20. "DiscoveryIgnoreReplicaHostnameFilters": [
  21. "a_host_i_want_to_ignore[.]example[.]com",
  22. ".*[.]ignore_all_hosts_from_this_domain[.]example[.]com",
  23. "a_host_with_extra_port_i_want_to_ignore[.]example[.]com:3307"
  24. ],
  25. "UnseenInstanceForgetHours": 240,
  26. "SnapshotTopologiesIntervalHours": 0,
  27. "InstanceBulkOperationsWaitTimeoutSeconds": 10,
  28. "HostnameResolveMethod": "default",
  29. "MySQLHostnameResolveMethod": "@@hostname",
  30. "SkipBinlogServerUnresolveCheck": true,
  31. "ExpiryHostnameResolvesMinutes": 60,
  32. "RejectHostnameResolvePattern": "",
  33. "ReasonableReplicationLagSeconds": 10,
  34. "ProblemIgnoreHostnameFilters": [],
  35. "VerifyReplicationFilters": false,
  36. "ReasonableMaintenanceReplicationLagSeconds": 20,
  37. "CandidateInstanceExpireMinutes": 1,
  38. "AuditLogFile": "",
  39. "AuditToSyslog": false,
  40. "RemoveTextFromHostnameDisplay": ".mydomain.com:3306",
  41. "ReadOnly": false,
  42. "AuthenticationMethod": "",
  43. "HTTPAuthUser": "",
  44. "HTTPAuthPassword": "",
  45. "AuthUserHeader": "",
  46. "PowerAuthUsers": [
  47. "*"
  48. ],
  49. "ClusterNameToAlias": {
  50. "127.0.0.1": "test suite"
  51. },
  52. "ReplicationLagQuery": "",
  53. "DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)",
  54. "DetectClusterDomainQuery": "",
  55. "DetectInstanceAliasQuery": "",
  56. "DetectPromotionRuleQuery": "",
  57. "DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com",
  58. "PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com",
  59. "PromotionIgnoreHostnameFilters": [],
  60. "DetectSemiSyncEnforcedQuery": "",
  61. "ServeAgentsHttp": false,
  62. "AgentsServerPort": ":3001",
  63. "AgentsUseSSL": false,
  64. "AgentsUseMutualTLS": false,
  65. "AgentSSLSkipVerify": false,
  66. "AgentSSLPrivateKeyFile": "",
  67. "AgentSSLCertFile": "",
  68. "AgentSSLCAFile": "",
  69. "AgentSSLValidOUs": [],
  70. "UseSSL": false,
  71. "UseMutualTLS": false,
  72. "SSLSkipVerify": false,
  73. "SSLPrivateKeyFile": "",
  74. "SSLCertFile": "",
  75. "SSLCAFile": "",
  76. "SSLValidOUs": [],
  77. "URLPrefix": "",
  78. "StatusEndpoint": "/api/status",
  79. "StatusSimpleHealth": true,
  80. "StatusOUVerify": false,
  81. "AgentPollMinutes": 60,
  82. "UnseenAgentForgetHours": 6,
  83. "StaleSeedFailMinutes": 60,
  84. "SeedAcceptableBytesDiff": 8192,
  85. "PseudoGTIDPattern": "",
  86. "PseudoGTIDPatternIsFixedSubstring": false,
  87. "PseudoGTIDMonotonicHint": "asc:",
  88. "DetectPseudoGTIDQuery": "",
  89. "BinlogEventsChunkSize": 10000,
  90. "SkipBinlogEventsContaining": [],
  91. "ReduceReplicationAnalysisCount": true,
  92. "FailureDetectionPeriodBlockMinutes": 5,
  93. "FailMasterPromotionOnLagMinutes": 0,
  94. "RecoveryPeriodBlockSeconds": 3600,
  95. "RecoveryIgnoreHostnameFilters": [],
  96. "RecoverMasterClusterFilters": [
  97. "*"
  98. ],
  99. "RecoverIntermediateMasterClusterFilters": [
  100. "*"
  101. ],
  102. "OnFailureDetectionProcesses": [
  103. "echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
  104. ],
  105. "PreGracefulTakeoverProcesses": [
  106. "echo 'Planned takeover about to take place on {failureCluster}. Master will switch to read_only' >> /tmp/recovery.log"
  107. ],
  108. "PreFailoverProcesses": [
  109. "echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
  110. ],
  111. "PostFailoverProcesses": [
  112. "echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log",
  113. "/home/orch/orch_hook.sh {failureType} {failureClusterAlias} {failedHost} {successorHost} >> /tmp/orch.log"
  114. ],
  115. "PostUnsuccessfulFailoverProcesses": [],
  116. "PostMasterFailoverProcesses": [
  117. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
  118. ],
  119. "PostIntermediateMasterFailoverProcesses": [
  120. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
  121. ],
  122. "PostGracefulTakeoverProcesses": [
  123. "echo 'Planned takeover complete' >> /tmp/recovery.log"
  124. ],
  125. "CoMasterRecoveryMustPromoteOtherCoMaster": true,
  126. "DetachLostSlavesAfterMasterFailover": true,
  127. "ApplyMySQLPromotionAfterMasterFailover": true,
  128. "PreventCrossDataCenterMasterFailover": false,
  129. "PreventCrossRegionMasterFailover": false,
  130. "MasterFailoverDetachReplicaMasterHost": false,
  131. "MasterFailoverLostInstancesDowntimeMinutes": 0,
  132. "PostponeReplicaRecoveryOnLagMinutes": 0,
  133. "OSCIgnoreHostnameFilters": [],
  134. "GraphiteAddr": "",
  135. "GraphitePath": "",
  136. "GraphiteConvertHostnameDotsToUnderscores": true,
  137. "ConsulAddress": "",
  138. "ConsulAclToken": "",
  139. "ConsulKVStoreProvider": "consul"
  140. }

orch_hook.sh

  1. #!/bin/bash
  2. isitdead=$1
  3. #cluster=$2
  4. oldmaster=$3
  5. newmaster=$4
  6.  
  7. ssh=$(which ssh)
  8.  
  9. logfile="/home/orch/orch_hook.log"
  10. interface='enp0s3'
  11. user=orch
  12. #VIP=$($ssh -tt ${user}@${oldmaster} "sudo ip address show dev enp0s3|grep -w 'inet'|tail -n 1|awk '{print \$2}'|awk -F/ '{print \$1}'")
  13. VIP='192.168.56.200'
  14. VIP_TEMP=$($ssh -tt ${user}@${oldmaster} "sudo ip address|sed -nr 's#^.*inet (.*)/32.*#\1#gp'")
  15. #remove '\r' at the end $'192.168.56.200\r'
  16. VIP_TEMP=$(echo $VIP_TEMP|awk -F"\\r" '{print $1}')
  17.  
  18. if [ ${#VIP_TEMP} -gt 0 ]; then
  19. VIP=$VIP_TEMP
  20. fi
  21. echo ${VIP}
  22. echo ${interface}
  23.  
  24. if [[ $isitdead == "DeadMaster" ]]; then
  25. if [ !-z ${!VIP} ] ; then
  26.  
  27. echo $(date)
  28. echo "Revocering from: $isitdead"
  29. echo "New master is: $newmaster"
  30. echo "/home/orch/orch_vip.sh -d 1 -n $newmaster -i ${interface} -I $VIP -u ${user} -o ${oldmaster}"
  31. /home/orch/orch_vip.sh -d 1 -n $newmaster -i ${interface} -I $VIP -u ${user} -o ${oldmaster}
  32. else
  33.  
  34. echo "Cluster does not exist!" | tee $logfile
  35.  
  36. fi
  37. fi

  

orch_vip.sh

  1. #!/bin/bash
  2.  
  3. function usage {
  4. cat << EOF
  5. usage: $0 [-h] [-d master is dead] [-o old master ] [-s ssh options] [-n new master] [-i interface] [-I] [-u SSH user]
  6.  
  7. OPTIONS:
  8. -h Show this message
  9. -o string Old master hostname or IP address
  10. -d int If master is dead should be 1 otherweise it is 0
  11. -s string SSH options
  12. -n string New master hostname or IP address
  13. -i string Interface exmple eth0:1
  14. -I string Virtual IP
  15. -u string SSH user
  16. EOF
  17.  
  18. }
  19.  
  20. while getopts ho:d:s:n:i:I:u: flag; do
  21. case $flag in
  22. o)
  23. orig_master="$OPTARG";
  24. ;;
  25. d)
  26. isitdead="${OPTARG}";
  27. ;;
  28. s)
  29. ssh_options="${OPTARG}";
  30. ;;
  31. n)
  32. new_master="$OPTARG";
  33. ;;
  34. i)
  35. interface="$OPTARG";
  36. ;;
  37. I)
  38. vip="$OPTARG";
  39. ;;
  40. u)
  41. ssh_user="$OPTARG";
  42. ;;
  43. h)
  44. usage;
  45. exit 0;
  46. ;;
  47. *)
  48. usage;
  49. exit 1;
  50. ;;
  51. esac
  52. done
  53.  
  54. if [ $OPTIND -eq 1 ]; then
  55. echo "No options were passed";
  56. usage;
  57. fi
  58.  
  59. shift $(( OPTIND - 1 ));
  60.  
  61. # discover commands from our path
  62. ssh=$(which ssh)
  63. arping=$(which arping)
  64. ip2util=$(which ip)
  65. #ip2util='ip'
  66.  
  67. # command for adding our vip
  68. cmd_vip_add="sudo -n $ip2util address add $vip dev $interface"
  69. # command for deleting our vip
  70. cmd_vip_del="sudo -n $ip2util address del $vip/32 dev $interface"
  71. # command for discovering if our vip is enabled
  72. cmd_vip_chk="sudo -n $ip2util address show dev $interface to ${vip%/*}/32"
  73. # command for sending gratuitous arp to announce ip move
  74. cmd_arp_fix="sudo -n $arping -c 1 -I ${interface} ${vip%/*}"
  75. # command for sending gratuitous arp to announce ip move on current server
  76. #cmd_local_arp_fix="sudo -n $arping -c 1 -I ${interface} ${vip%/*}"
  77. cmd_local_arp_fix="$arping -c 1 -I ${interface} ${vip%/*}"
  78.  
  79. vip_stop() {
  80. rc=0
  81. echo $?
  82.  
  83. echo "$ssh ${ssh_options} -tt ${ssh_user}@${orig_master} \
  84. \"[ -n \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_del} && \
  85. sudo -n ${ip2util} route flush cache || [ -z \"\$(${cmd_vip_chk})\" ]\""
  86.  
  87. # ensure the vip is removed
  88. $ssh ${ssh_options} -tt ${ssh_user}@${orig_master} \
  89. "[ -n \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_del} && \
  90. sudo -n ${ip2util} route flush cache || [ -z \"\$(${cmd_vip_chk})\" ]"
  91. rc=$?
  92. return $rc
  93. }
  94.  
  95. vip_start() {
  96. rc=0
  97.  
  98. # ensure the vip is added
  99. # this command should exit with failure if we are unable to add the vip
  100. # if the vip already exists always exit 0 (whether or not we added it)
  101. echo "$ssh ${ssh_options} -tt ${ssh_user}@${new_master} \
  102. \"[ -z \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_add} && ${cmd_arp_fix} || [ -n \"\$(${cmd_vip_chk})\" ]\""
  103.  
  104. $ssh ${ssh_options} -tt ${ssh_user}@${new_master} \
  105. "[ -z \"\$(${cmd_vip_chk})\" ] && ${cmd_vip_add} && ${cmd_arp_fix} || [ -n \"\$(${cmd_vip_chk})\" ]"
  106. rc=$?
  107. echo "vip started"
  108. #$cmd_local_arp_fix
  109. return $rc
  110. }
  111.  
  112. vip_status() {
  113. $arping -c 1 -I ${interface} ${vip%/*}
  114. echo "$arping -c 1 -I ${interface} ${vip%/*}"
  115. if ping -c 1 -W 1 "$vip"; then
  116. return 0
  117. else
  118. return 1
  119. fi
  120. }
  121.  
  122. if [[ $isitdead == 0 ]]; then
  123. echo "Online failover"
  124. if vip_stop; then
  125. if vip_start; then
  126. echo "$vip is moved to $new_master."
  127. else
  128. echo "Can't add $vip on $new_master!"
  129. exit 1
  130. fi
  131. else
  132. echo $rc
  133. echo "Can't remove the $vip from orig_master!"
  134. exit 1
  135. fi
  136. elif [[ $isitdead == 1 ]]; then
  137. echo "Master is dead, failover"
  138. # make sure the vip is not available
  139. if vip_status; then
  140. if vip_stop; then
  141. echo "$vip is removed from orig_master."
  142. else
  143. echo $rc
  144. echo "Couldn't remove $vip from orig_master."
  145. exit 1
  146. fi
  147. fi
  148.  
  149. if vip_start; then
  150. echo "$vip is moved to $new_master."
  151.  
  152. else
  153. echo "Can't add $vip on $new_master!"
  154. exit 1
  155. fi
  156. else
  157. echo "Wrong argument, the master is dead or live?"
  158.  
  159. fi

  

MySQL Server配置

配置一下Master和不同的Slave的配置文件 (/etc/my.cnf)。所有配置参数可以一样,除了server_id。

需要注意的是每个MySQL的server_id必须不同。

  1. [mysqld]
  2. datadir=/var/lib/mysql
  3. socket=/var/lib/mysql/mysql.sock
  4.  
  5. log-error=/var/lib/mysql/mysqld.log
  6. pid-file=/var/lib/mysql/mysqld.pid
  7.  
  8. sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  9. port = 3306
  10. #GTID:
  11. server_id=135 #服务器id
  12. gtid_mode=on #开启gtid模式
  13. enforce_gtid_consistency=on #强制gtid一致性,开启后对于特定create table不被支持
  14. #binlog
  15. log_bin=binlog
  16. log-slave-updates=1
  17. binlog_format=row #强烈建议,其他格式可能造成数据不一致
  18. #relay log
  19. skip_slave_start=1
  20. max_connect_errors=1000
  21. default_authentication_plugin = 'mysql_native_password'
  22.  
  23. slave_net_timeout = 4

从机连接主机,并开启复制

  1. mysql>change master to master_host='master', master_port=3306, master_user='repl', master_password='Xiaopang*803',
  2.  
  3. master_auto_position=1,MASTER_HEARTBEAT_PERIOD=2,MASTER_CONNECT_RETRY=1, MASTER_RETRY_COUNT=86400;
  4.  
  5. mysql>start slave;

复制启动无误后。在Master上执行如下命令创建orchestrator用户并赋予权限(这就是上面Orachestrator用来连接MySQL复制实例的用户)

  1. CREATE USER 'orchestrator'@'%' IDENTIFIED BY 'orc_topology_password';
  2. GRANT SUPER, PROCESS, REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'orchestrator'@'%';

测试导换

启动orchestrator

[orch@orch orchestrator]$ pwd
/usr/local/orchestrator

[root@orch orchestrator]# ./orchestrator --debug --config=/etc/orchestrator.conf.json http

登录Web并发现实例

我的orchestrator的IP地址是130。

http://192.168.56.130:3000/

发现新的实例是,填上当前的Master的实例IP与端口。

切换前

手动给host03增加一个VIP地址 192.168.56.200

[root@host03 ~]# ip addr add dev enp0s3 192.168.56.200/32

查看一下

[root@host03 ~]# ip addr show dev enp0s3

enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000

link/ether 08:00:27:9a:25:16 brd ff:ff:ff:ff:ff:ff

inet 192.168.56.105/24 brd 192.168.56.255 scope global enp0s3

valid_lft forever preferred_lft forever

inet 192.168.56.200/32 scope global enp0s3

valid_lft forever preferred_lft forever

inet6 fe80::bfdd:5d6a:d4f9:6f95/64 scope link

valid_lft forever preferred_lft forever

inet6 fe80::5a97:c3c9:a9df:466f/64 scope link tentative dadfailed

valid_lft forever preferred_lft forever

切换后

停止host03 MySQL

[root@host03 ~]#service mysqld stop

停止后,过了1分多钟,服务发了导换。新的拓扑结构变为如下

查看VIP是否也发生了切换。如下可以看到新的VIP已经切换到了新的主机host01上。

  1. [root@host01 ~]# ip addr show dev enp0s3
  2.  
  3. 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
  4.  
  5. link/ether 08:00:27:28:0d:72 brd ff:ff:ff:ff:ff:ff
  6.  
  7. inet 192.168.56.103/24 brd 192.168.56.255 scope global enp0s3
  8.  
  9. valid_lft forever preferred_lft forever
  10.  
  11. inet 192.168.56.200/32 scope global enp0s3
  12. valid_lft forever preferred_lft forever
  13.  
  14. inet6 fe80::8428:fc7:68fc:1079/64 scope link
  15.  
  16. valid_lft forever preferred_lft forever
  17.  
  18. inet6 fe80::bfdd:5d6a:d4f9:6f95/64 scope link tentative dadfailed
  19.  
  20. valid_lft forever preferred_lft forever
  21.  
  22. inet6 fe80::5a97:c3c9:a9df:466f/64 scope link tentative dadfailed
  23.  
  24. valid_lft forever preferred_lft forever
  25.  
  26. [root@host03 ~]# ip addr show dev enp0s3
  27.  
  28. 2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
  29.  
  30. link/ether 08:00:27:9a:25:16 brd ff:ff:ff:ff:ff:ff
  31.  
  32. inet 192.168.56.105/24 brd 192.168.56.255 scope global enp0s3
  33.  
  34. valid_lft forever preferred_lft forever
  35.  
  36. inet6 fe80::bfdd:5d6a:d4f9:6f95/64 scope link
  37.  
  38. valid_lft forever preferred_lft forever
  39.  
  40. inet6 fe80::5a97:c3c9:a9df:466f/64 scope link tentative dadfailed
  41.  
  42. valid_lft forever preferred_lft forever

Orchestrator是如何监测Master异常的

Orchestrator不仅仅只依靠Master独立来判断的。实际上它还会联系各个Slave。

当Slave达成共识Master挂掉了时,这时Orchestrator才会发生导换。

如此能够保证更高的可靠性。

Failure detection

orchestrator uses a holistic approach to detect master and intermediate master failures.

In a naive approach, a monitoring tool would probe the master, for example, and alert when it cannot contact or query the master server. Such approach is susceptible to false positives caused by network glitches. The naive approach further mitigates false positives by running n tests spaced by t-long intervals. This reduces, in some cases, the chances of false positives, and then increases the response time in the event of real failure.

orchestrator harnesses the replication topology. It observes not only the server itself, but also its replicas. For example, to diagnose a dead master scenario, orchestrator must both:

  • Fail to contact said master
  • Be able to contact master's replicas, and confirm they, too, cannot see the master.

Instead of triaging the error by time, orchestrator triages by multiple observers, the replication topology servers themselves. In fact, when all of a master's replicas agree that they cannot contact their master, the replication topology is broken de-facto, and a failover is justified.

orchestrator's holistic failure detection approach is known to be very reliable in production.

总结

1)orch_hook脚本是从网上找的。相对于自己的环境改了一些地方。

这个肯定不完善,会存在一些bug。这个实验的另一目的也是验证Orchestrator的hook脚本的工作是否有效。

2)通过自己写脚本的方案,感觉还是容易出问题。其实,在有现成的更好的方案下,尽量不要自己写。

比如说,我觉得采用半同步+keepbyalive实现VIP的方案可能更好。一个Master两个Slave,一个配置为半同步(SlaveSync),其它的从结点配置为异步。

Master和SlaveSync,通过keepbyalive实现VIP切换(Orchestrator  Hook启停keepbyalive服务实现VIP切换)

3)网上说有更佳的办法通过ProxySQL+Orchestartor,下次试一下。

参考资料

列出部分参考资料

https://www.cnblogs.com/zhoujinyi/p/10394389.html

https://www.jianshu.com/p/91833222581a

https://github.com/openark/orchestrator/

MySQL Orchestrator自动导换+VIP切换的更多相关文章

  1. Orchestrator+Proxysql 实现自动导换+应用透明读写分离

    前面一篇博客我介绍了如何通过Orachestrator+脚本实现自动导换. 这一章,我来演示一下如何通过Orchestrator+Proxysql 实现自动导换+应用透明读写分离 总体架构 可选架构1 ...

  2. 设置MySQL服务自动运行

    一般情况下,MySQL安装以后是自动运行的,不知道我这台机器是什么原因,MySQL不能自动运行,每次开机后都要手动运行mysqld.exe,比较麻烦,于是用以下方法将MySQL自动启动: 1. 运行c ...

  3. Eclipse Oxygen 解决 自动导包的问题

    换成了 Eclipse 的Oxygen 版本 , 发现之前好用的自动导包功能不能用了 (Ctrl+Shift+O) 再 网上看资料  上面说 将  In Windows 替换为Editing Java ...

  4. MHA 实现VIP切换用到脚本

    在MHA Manager端配置中,如果实现MHA的vip故障切换需要在配置文件/etc/masterha/app1/app1.cnf 中启用下面三个参数: master_ip_failover_scr ...

  5. 狗扑论坛 自动刷取VIP狗粮

    狗扑论坛 自动刷取VIP狗粮 开始闲狗粮回复太慢就自己想了想去写一个,成功总是给我的哈哈. 自己花了一小时 时间慢慢学就慢慢写的  虽然代码简单 但是已经够自己用了 using System; usi ...

  6. MYSQL数据库自动本地/异地双备份/MYSQL增量备份

    构建高安全电子商务网站之(网站文件及数据库自动本地/异地双备份)架构图 继续介绍Linux服务器文件备份,数据库备份,数据安全存储相关的电子商务系统架构.针对安全性有多种多样的解决方案,其中数据备份是 ...

  7. Android studio之更改快捷键及自动导包

    更改AS中的代码提示快捷键,AS做的也挺智能的,在Keymap中可以选择使用eclipse的快捷键设置,但是虽然设置了,对有些快捷键还是不能使用,那么就需要我们手动去修改了. 在代码提示AS默认的快捷 ...

  8. MySQL的自动提交模式

      默认情况下, MySQL启用自动提交模式(变量autocommit为ON).这意味着, 只要你执行DML操作的语句,MySQL会立即隐式提交事务(Implicit Commit).这个跟SQL S ...

  9. MySQL数据库--思维导图

    MySQL数据库--思维导图

随机推荐

  1. Java IO学习笔记二:DirectByteBuffer与HeapByteBuffer

    作者:Grey 原文地址:Java IO学习笔记二:DirectByteBuffer与HeapByteBuffer ByteBuffer.allocate()与ByteBuffer.allocateD ...

  2. Linux芯片驱动之SPI Controller

    针对一款新的芯片,芯片厂商如何基于Linux编写对应的 SPI controller 驱动? 我们先看看 Linux SPI 的整体框架: 可以看到,最底层是硬件层,对应芯片内部 SPI contro ...

  3. hbase统计表的行数的三种方法

    有些时候需要我们去统计某一个hbase表的行数,由于hbase本身不支持SQL语言,只能通过其他方式实现. 可以通过一下几种方式实现hbase表的行数统计工作: 这里有一张hbase表test:tes ...

  4. 一文带你了解.Net互斥锁

    本文主要讲解.Net基于Threading.Mutex实现互斥锁 基础互斥锁实现 基础概念:和自旋锁一样,操作系统提供的互斥锁内部有一个数值表示锁是否已经被获取,不同的是当获取锁失败的时候,它不会反复 ...

  5. 【SQLite】教程06-SQLite表操作

    创建表: CREATE TABLE 语句用于在任何给定的数据库创建一个新表.命名表.定义列.定义每一列的数据类型 查看表: 详细查看表: 重命名表: 删除表: 创建表并添加7条记录(第七条记录用了第二 ...

  6. 使用VS code编写C++无法实时检测代码的解决办法

    更新:其实微软是有官方文档配置VS code 的C++的.地址是: https://code.visualstudio.com/docs/cpp 更改工作区后就发现不能再使用VS CODE愉快地写C+ ...

  7. 深度解读MRS IoTDB时序数据库的整体架构设计与实现

    [本期推荐]华为云社区6月刊来了,新鲜出炉的Top10技术干货.重磅技术专题分享:还有毕业季闯关大挑战,华为云专家带你做好职业规划. 摘要:本文将会系统地为大家介绍MRS IoTDB的来龙去脉和功能特 ...

  8. .Net EF Core千万级数据实践

    .Net 开发中操作数据库EF一直是我的首选,工作和学习也一直在使用.EF一定程度的提高了开发速度,开发人员专注业务,不用编写sql.方便的同时也产生了一直被人诟病的一个问题性能低下. EF Core ...

  9. VLAN的基础介绍与使用方法

    一.VLAN概述与优势 二.VLAN的种类 三.VLAN的范围 四.VLAN的三种接口模式 五.VLAN的实例操作 一.VLAN概述与优势 VLAN(虚拟局域网)通过为子网提供数据链路连接来抽象出局域 ...

  10. ceph-csi组件源码分析(1)-组件介绍与部署yaml分析

    更多ceph-csi其他源码分析,请查看下面这篇博文:kubernetes ceph-csi分析目录导航 ceph-csi组件源码分析(1)-组件介绍与部署yaml分析 基于tag v3.0.0 ht ...