• orchestrator数据库高可用组件搭建


    一、前言

          说一下为什么使用orchestrator作为数据库的高可用组件而不是MHA,因为mha组件存在组件单点问题,而orchestrator组件可以组建集群,不会出现单点问题

    二、搭建

    搭建mysql gtid主从

    参考:mysql主从搭建(gtid)-CSDN博客

    上面的主从配置是为了 orchestrator数据库高可用组件的使用,其中有几个配置不能出错

    主从配置中的CHANGE MASTER TO MASTER_HOST='rabbitmq02',必须使用主机名,不能使用ip地址,不然在使用orchestrator组件做mysql故障切换时会出问题

    还有就是对于主从同步用户的权限配置也是加多了几项,而不是单纯的配置REPLICATION SLAVE权限

    搭建orchestrator集群

    在github上下载orchestrator的安装包

    地址:Releases · openark/orchestrator · GitHub

     这里使用三台主机构建orchestrator集群,使用raft协议使用高可用,允许一台主机宕机

    ipport
    10.1.60.1183306、3001
    10.1.60.1203306、3001
    10.1.60.1253306、3001

    需要先为每台主机安装mysql服务

    参考:yum安装mysql 5.7_yum安装mysql5.7_Apex Predator的博客-CSDN博客

    创建 orchestrator数据库与用户

    mysql -u root -p

    create database orchestrator;

    create user 'orchestrator'@'%' identified by '11111111';

    grant all on orchestrator.* to 'orchestrator'@'%';

    flush privileges;

    将安装包分别放到三台主机上并解压

    mkdir /opt/orchestrator && cd /opt/orchestrator

    tar -zxvf orchestrator-3.2.5-linux-amd64.tar.gz && ls

    拷贝配置文件(三台主机都需要操作)

    cd usr/local/orchestrator/

    cp orchestrator-sample.conf.json orchestrator.conf.json

    编辑配置文件(三台主机都需要操作)

    vi orchestrator.conf.json

    1. {
    2. "Debug": true,
    3. "EnableSyslog": true,
    4. "ListenAddress": ":3001", #默认是使用3000端口,但是我这边有服务被使用了所以改成3001端口
    5. "MySQLTopologyUser": "orchestrator", #配置被监控的主从数据库的用户
    6. "MySQLTopologyPassword": "11111111", #配置被监控的主从数据库的用户密码
    7. "MySQLTopologyCredentialsConfigFile": "",
    8. "MySQLTopologySSLPrivateKeyFile": "",
    9. "MySQLTopologySSLCertFile": "",
    10. "MySQLTopologySSLCAFile": "",
    11. "MySQLTopologySSLSkipVerify": true,
    12. "MySQLTopologyUseMutualTLS": false,
    13. "MySQLOrchestratorHost": "10.1.60.125", #配置orchestrator组件服务本机地址
    14. "MySQLOrchestratorPort": 3306, #配置orchestrator组件服务数据库端口
    15. "MySQLOrchestratorDatabase": "orchestrator", #配置orchestrator组件数据库
    16. "MySQLOrchestratorUser": "orchestrator", #配置orchestrator数据库用户
    17. "MySQLOrchestratorPassword": "11111111", ##配置orchestrator数据库用户密码
    18. "MySQLOrchestratorCredentialsConfigFile": "",
    19. "MySQLOrchestratorSSLPrivateKeyFile": "",
    20. "MySQLOrchestratorSSLCertFile": "",
    21. "MySQLOrchestratorSSLCAFile": "",
    22. "MySQLOrchestratorSSLSkipVerify": true,
    23. "MySQLOrchestratorUseMutualTLS": false,
    24. "MySQLConnectTimeoutSeconds": 1,
    25. "RaftEnabled": true, #启用raft配置,以下配置默认是没有的,需要手动加上
    26. "RaftDataDir": "/opt/orchestrator", #配置orchestrator安装包地址
    27. "RaftBind": "10.1.60.125", #配置orchestrator组件服务本机地址
    28. "DefaultRaftPort": 10008, #配置raft服务端口
    29. "RaftNodes": [ #配置orchestrator组件集群地址
    30. "10.1.60.118",
    31. "10.1.60.120",
    32. "10.1.60.125"
    33. ],
    34. "DefaultInstancePort": 3306,
    35. "DiscoverByShowSlaveHosts": true,
    36. "InstancePollSeconds": 5,
    37. "DiscoveryIgnoreReplicaHostnameFilters": [
    38. "a_host_i_want_to_ignore[.]example[.]com",
    39. ".*[.]ignore_all_hosts_from_this_domain[.]example[.]com",
    40. "a_host_with_extra_port_i_want_to_ignore[.]example[.]com:3307"
    41. ],
    42. "UnseenInstanceForgetHours": 240,
    43. "SnapshotTopologiesIntervalHours": 0,
    44. "InstanceBulkOperationsWaitTimeoutSeconds": 10,
    45. "HostnameResolveMethod": "None", #此处需要更改为None,默认是default,使用默认的后面通过主机名添加mysql主从的时候会查找不到
    46. "MySQLHostnameResolveMethod": "SELECT concat(@@report_host,':',@@port)", #此处也需要更改为report_host模式
    47. "SkipBinlogServerUnresolveCheck": true,
    48. "ExpiryHostnameResolvesMinutes": 60,
    49. "RejectHostnameResolvePattern": "",
    50. "ReasonableReplicationLagSeconds": 10,
    51. "ProblemIgnoreHostnameFilters": [],
    52. "VerifyReplicationFilters": false,
    53. "ReasonableMaintenanceReplicationLagSeconds": 20,
    54. "CandidateInstanceExpireMinutes": 60,
    55. "AuditLogFile": "",
    56. "AuditToSyslog": false,
    57. "RemoveTextFromHostnameDisplay": ":3306",
    58. "ReadOnly": false,
    59. "AuthenticationMethod": "",
    60. "HTTPAuthUser": "",
    61. "HTTPAuthPassword": "",
    62. "AuthUserHeader": "",
    63. "PowerAuthUsers": [
    64. "*"
    65. ],
    66. "ClusterNameToAlias": {
    67. "127.0.0.1": "test suite"
    68. },
    69. "ReplicationLagQuery": "",
    70. "DetectClusterAliasQuery": "SELECT SUBSTRING_INDEX(@@hostname, '.', 1)",
    71. "DetectClusterDomainQuery": "",
    72. "DetectInstanceAliasQuery": "",
    73. "DetectPromotionRuleQuery": "",
    74. "DataCenterPattern": "[.]([^.]+)[.][^.]+[.]mydomain[.]com",
    75. "PhysicalEnvironmentPattern": "[.]([^.]+[.][^.]+)[.]mydomain[.]com",
    76. "PromotionIgnoreHostnameFilters": [],
    77. "DetectSemiSyncEnforcedQuery": "",
    78. "ServeAgentsHttp": false,
    79. "AgentsServerPort": ":3001", #此处也需要更改orchestrator组件默认的端口号
    80. "AgentsUseSSL": false,
    81. "AgentsUseMutualTLS": false,
    82. "AgentSSLSkipVerify": false,
    83. "AgentSSLPrivateKeyFile": "",
    84. "AgentSSLCertFile": "",
    85. "AgentSSLCAFile": "",
    86. "AgentSSLValidOUs": [],
    87. "UseSSL": false,
    88. "UseMutualTLS": false,
    89. "SSLSkipVerify": false,
    90. "SSLPrivateKeyFile": "",
    91. "SSLCertFile": "",
    92. "SSLCAFile": "",
    93. "SSLValidOUs": [],
    94. "URLPrefix": "",
    95. "StatusEndpoint": "/api/status",
    96. "StatusSimpleHealth": true,
    97. "StatusOUVerify": false,
    98. "AgentPollMinutes": 60,
    99. "UnseenAgentForgetHours": 6,
    100. "StaleSeedFailMinutes": 60,
    101. "SeedAcceptableBytesDiff": 8192,
    102. "PseudoGTIDPattern": "",
    103. "PseudoGTIDPatternIsFixedSubstring": false,
    104. "PseudoGTIDMonotonicHint": "asc:",
    105. "DetectPseudoGTIDQuery": "",
    106. "BinlogEventsChunkSize": 10000,
    107. "SkipBinlogEventsContaining": [],
    108. "ReduceReplicationAnalysisCount": true,
    109. "FailureDetectionPeriodBlockMinutes": 60,
    110. "FailMasterPromotionOnLagMinutes": 0,
    111. "RecoveryPeriodBlockSeconds": 3600,
    112. "RecoveryIgnoreHostnameFilters": [],
    113. "RecoverMasterClusterFilters": ["*"], #需要更改默认配置,改为*,不然主从故障自动切换不会生效
    114. "RecoverIntermediateMasterClusterFilters": ["*"], #需要更改默认配置,改为*,不然主从故障自动切换不会生效
    115. "OnFailureDetectionProcesses": [
    116. "echo 'Detected {failureType} on {failureCluster}. Affected replicas: {countSlaves}' >> /tmp/recovery.log"
    117. ],
    118. "PreGracefulTakeoverProcesses": [
    119. "echo 'Planned takeover about to take place on {failureCluster}. Master will switch to read_only' >> /tmp/recovery.log"
    120. ],
    121. "PreFailoverProcesses": [
    122. "echo 'Will recover from {failureType} on {failureCluster}' >> /tmp/recovery.log"
    123. ],
    124. "PostFailoverProcesses": [
    125. "echo '(for all types) Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
    126. ],
    127. "PostUnsuccessfulFailoverProcesses": [],
    128. "PostMasterFailoverProcesses": [
    129. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Promoted: {successorHost}:{successorPort}' >> /tmp/recovery.log"
    130. ],
    131. "PostIntermediateMasterFailoverProcesses": [
    132. "echo 'Recovered from {failureType} on {failureCluster}. Failed: {failedHost}:{failedPort}; Successor: {successorHost}:{successorPort}' >> /tmp/recovery.log"
    133. ],
    134. "PostGracefulTakeoverProcesses": [
    135. "echo 'Planned takeover complete' >> /tmp/recovery.log"
    136. ],
    137. "CoMasterRecoveryMustPromoteOtherCoMaster": true,
    138. "DetachLostSlavesAfterMasterFailover": true,
    139. "ApplyMySQLPromotionAfterMasterFailover": true,
    140. "PreventCrossDataCenterMasterFailover": false,
    141. "PreventCrossRegionMasterFailover": false,
    142. "MasterFailoverDetachReplicaMasterHost": false,
    143. "MasterFailoverLostInstancesDowntimeMinutes": 0,
    144. "PostponeReplicaRecoveryOnLagMinutes": 0,
    145. "OSCIgnoreHostnameFilters": [],
    146. "GraphiteAddr": "",
    147. "GraphitePath": "",
    148. "GraphiteConvertHostnameDotsToUnderscores": true,
    149. "ConsulAddress": "",
    150. "ConsulAclToken": "",
    151. "ConsulKVStoreProvider": "consul"
    152. }

    启动orchestrator组件服务

    nohup ./orchestrator http &>./orchestrator.log&

    查看orchestrator组件服务是否正常

    netstat -tlpn |grep 3001

    访问 orchestrator组件web

    接下来添加mysql主从,只需添加主从中的任意一台就会自动识别整个主从架构

     

     关于主从故障的测试就不再演示了,可以自行操作,但是原来挂掉的主数据库重新启动后需要手动配置slave服务才能重新在加入主从架构中

  • 相关阅读:
    【C++航海王:追寻罗杰的编程之路】C++的类型转换
    uniapp编译微信小程序富文本rich-text的图片样式不生效原因
    Java项目:SSH企业人力资源管理系统
    分布式ID生成
    远程连接Ubuntu 22.04
    隐马尔可夫模型应用实验
    iOS 17.4 Not Installed
    caxa复制尺寸错乱
    C# byte转bit bit组装成byte
    python项目实战——银行取款机系统(八)
  • 原文地址:https://blog.csdn.net/ApexPredator/article/details/134061830