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;

相关推荐
Dontla43 分钟前
Docker run --add-host参数解析(在容器启动时向/etc/hosts文件中添加自定义的主机名与IP映射)(适用于临时调试或测试)
tcp/ip·docker·容器
西西小飞龙1 小时前
Docker和K8S中pod、services、container的介绍和关系
docker·容器·kubernetes
元气满满的热码式1 小时前
Docker数据卷操作实战
linux·运维·docker·云原生·容器
kngines1 小时前
【实战 ES】实战 Elasticsearch:快速上手与深度实践-1.3.1单节点安装(Docker与手动部署)
大数据·elasticsearch·docker
小王努力学编程7 小时前
【MySQL篇】表的操作
数据库·mysql
汤汤upup7 小时前
面试八股文--数据库基础知识总结(2) MySQL
数据库·mysql·面试
TangKenny7 小时前
information_schema.processlist 表详解
mysql·processlist
m0_7482509310 小时前
mysql数据被误删的恢复方案
数据库·mysql
m0_7482384210 小时前
MySQL Workbench菜单汉化为中文
android·数据库·mysql
一小路一10 小时前
从0-1学习Mysql第五章: 索引与优化
数据库·后端·学习·mysql·面试