docker-compose部署MySQL高可用工具orchestrator

主要对一个MySQL主从架构部署orchestartor进行高可用验证,orchestrator部署在主从架构的从节点上,当然最好是部署在其他机器上,后端数据库采用的直接是MySQL的从库,所以没有创建orchestrator的后端数据库的流程。

创建yaml文件

mkidr /opt/orche
cd /opt/orche
vim docker-compose.yml
注意网络应该与mysql的节点网络相同

version: '2'

services:
  orchestrator:
    image: openarkcode/orchestrator:latest
    container_name: orchestrator
    ports:
      - "3001:3000"  # Orchestrator Web UI
    volumes:
      - ./orchestrator.conf.json:/etc/orchestrator.conf.json
    environment:
      - MYSQL_TOPOLOGY_USER=orche
      - MYSQL_TOPOLOGY_PASSWORD=Tgqs@123
    networks:
      - mysql_net
    depends_on:
      - mysql-master
      - mysql-slave

networks:
  mysql_net:
   driver: bridge

创建配置文件

vim orchestrator.conf.json

{
  "Debug": true,
  "MySQLTopologyUser": "orche", #登录主从数据库的用户
  "MySQLTopologyPassword": "Tgqs@123",#登录主从数据库的密码
  "AutoMasterRecovery": true,
  "FailMasterPromotionIfSQLThreadNotUpToDate": true,
  "InstancePollSeconds": 10,
  "DiscoveryPollSeconds": 10,
  "UnseenInstanceForgetHours": 240,
  "HostnameResolveMethod": "default", #不设置为none默认都是主机名,选择none不认证主机名
  "MySQLHostnameResolveMethod": "@@hostname",#
  "MySQLOrchestratorHost": "172.16.208.13", #后端数据库的地址
  "MySQLOrchestratorPort": 3306,
  "MySQLOrchestratorDatabase": "orcdb",#后端数据库存放位置
  "MySQLOrchestratorUser": "orche",,#后端数据库用户名
  "MySQLOrchestratorPassword": "Tgqs@123",
  "AuthenticationMethod": "basic",#登录验证开启,关闭设为空置
  "HTTPAuthUser": "admin",#用户名
  "HTTPAuthPassword": "Tgqs@123",#密码
  "FailureDetectionPeriodBlockMinutes": 60,
  "RecoverMasterClusterFilters": ["*"], #自动主从切换
  "RecoverIntermediateMasterClusterFilters": ["*"],
  "ClusterNameToAlias": {
    "127.0.0.1": "test suite"

}

如果想让web界面显示ip地址修改两个参数

“HostnameResolveMethod”: “none”,
“MySQLHostnameResolveMethod”: “”,

进入mysql主节点的容器,从节点不用创建可能报错

create user ‘orche’@‘%’ identified by ‘Tgqs@123’;
GRANT ALL PRIVILEGES ON . TO ‘orche’@‘%’;

进入MySQL的从节点的容器

create database orche;

在从节点的compose文件夹

docker-compose up -d
docker ps
#如果没有启动查看日志情况

进入文本界面

在这里插入图片描述
discover 输入主节点
在这里插入图片描述
在这里插入图片描述
可以直接在这个也没进行开启关闭复制操作,不用再进到容器中
在这里插入图片描述

验证故障转移情况

docker stop mysql-master
#进入mysql从节点

在这里插入图片描述

docker exec -it mysql-slave mysql -uroot -p
#查看是否是个空值
show slave status \G;
#查看是否为主节点

show master status \G;

在这里插入图片描述

#手动将从节点升级为主节点
change master to
master_host=‘172.16.208.12’,
master_user=‘replica’,
master_password=‘Tgqs@123’,
MASTER_LOG_FILE=‘mysql-bin.00001’,#重新查看binlog文件名
MASTER_LOG_POS=157; #重新查看文件位置
show slave status \G;


常见的web界面故障显示

\- DeadMaster 主节点故障
\- DeadMasterAndReplicas 主节点和副本节点故障
\- DeadMasterAndSomeReplicas 主节点和部分副本节点故障
\- DeadMasterWithoutReplicas 主节点没有副本节点
\- UnreachableMasterWithLaggingReplicas 无法访问的主节点且存在滞后的副本节点
\- UnreachableMaster 无法访问的主节点
\- LockedSemiSyncMaster 被锁定的半同步主节点
\- MasterWithTooManySemiSyncReplicas 主节点具有过多的半同步副本
\- AllMasterReplicasNotReplicating 所有主节点副本均未进行复制
\- AllMasterReplicasNotReplicatingOrDead 所有主节点副本未进行复制或停止工作
\- DeadCoMaster 协同主节点故障
\- DeadCoMasterAndSomeReplicas 协同主节点和部分副本节点故障
\- DeadIntermediateMaster 中间主节点故障
\- DeadIntermediateMasterWithSingleReplicaFailingToConnect 中间主节点故障且单个副本无法连接
\- DeadIntermediateMasterWithSingleReplica 中间主节点故障且只有一个副本节点
\- DeadIntermediateMasterAndSomeReplicas 中间主节点和部分副本节点故障
\- DeadIntermediateMasterAndReplicas 中间主节点和副本节点故障
\- AllIntermediateMasterReplicasFailingToConnectOrDead 所有中间主节点副本无法连接或停止工作
\- AllIntermediateMasterReplicasNotReplicating 所有中间主节点副本未进行复制
\- UnreachableIntermediateMasterWithLaggingReplicas 无法访问的中间主节点且存在滞后的副本节点
\- UnreachableIntermediateMaster 无法访问的中间主节点
\- BinlogServerFailingToConnectToMaster Binlog服务器无法连接到主节点
主节点意外使用change master to

到主节点上
stop slave;
reset slave all;
show slave status \G; #为空

change master to
master_host=‘172.16.208.12’,
master_user=‘replica’,
master_password=‘Tgqs@123’,
MASTER_LOG_FILE=‘mysql-bin.000117’,
MASTER_LOG_POS=157 ;
show slave status \G;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值