暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Orchestrator部署

原创 zhou 2024-03-26
514

Orchestrator部署

orc元数据使用的数据库 + raft + orc软件

192.168.0.216
192.168.0.217
192.168.0.218

被监控mysql

192.168.0.211
192.168.0.212
192.168.0.213

下载

https://github.com/github/orchestrator/releases

具体选择v3.2.6

#服务包wget 
wget https://github.com/openark/orchestrator/releases/download/v3.2.6/orchestrator-3.2.6-1.x86_64.rpm
#二进制命令wget
wget https://github.com/openark/orchestrator/releases/download/v3.2.6/orchestrator-cli-3.2.6-1.x86_64.rpm 
#命令行工具
wget https://github.com/openark/orchestrator/releases/download/v3.2.6/orchestrator-client-3.2.6-1.x86_64.rpm

文件校验

检测是否下载完毕,vm网络环境不好,第一次安装的时候报错居然是没下载完整
sha256sum orchestrator-client-3.2.6-1.x86_64.rpm
sha256sum orchestrator-3.2.6-1.x86_64.rpm
sha256sum orchestrator-cli-3.2.6-1.x86_64.rpm

安装

rpm -ivh orchestrator-3.2.6-1.x86_64.rpm
rpm -ivh orchestrator-client-3.2.6-1.x86_64.rpm
rpm -ivh orchestrator-cli-3.2.6-1.x86_64.rpm

sqlite存储元数据

注:配置文件如下添加即可

vi /usr/local/orchestrator/orchestrator.conf.json
   "BackendDB": "sqlite",
  "SQLite3DataFile": "/usr/local/orchestrator/orchestrator.sqlite3",

mysql存储元数据(本次暂时不用,VM安装用sqllite)

CREATE DATABASE IF NOT EXISTS orchestrator;
CREATE USER 'orch_manager'@'%' IDENTIFIED BY '123456';
GRANT ALL ON orchestrator.* TO 'orch_manager'@'%';
GRANT SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'orch_manager'@'%';

被监控的mysql上执行

set sql_log_bin=0;
-- drop user 'orc_client_user'@'%' ;
CREATE USER 'orc_client_user'@'%' IDENTIFIED with mysql_native_password by 'orc_client_password';
GRANT SUPER, PROCESS, REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'orc_client_user'@'%';
set sql_log_bin=1;

为避免V8.0登录验证报错,使用mysql_native_password 方式验证

CREATE USER 'orc_client_user'@'%' IDENTIFIED BY 'orc_client_passwor';
GRANT SUPER, PROCESS, REPLICATION SLAVE, REPLICATION CLIENT, RELOAD ON *.* TO 'orc_client_user'@'%';

CREATE DATABASE meta;
GRANT SELECT ON meta.* TO 'orc_client_user'@'%';
### 配置启动

cd /usr/local/orchestrator/
#mysql  cp orchestrator-sample.conf.json orchestrator.conf.json
#sqllite  cp orchestrator-sample-sqlite.conf.json orchestrator.conf.json

编辑

#vi /usr/local/orchestrator/orchestrator.conf.json

RaftBind MySQLOrchestratorHost 修改成各自节点的值

MySQLTopologyUser 修改实际用户

#mysql配置
  "MySQLTopologyUser": "orc_client_user",
  "MySQLTopologyPassword": "orc_client_password",
   #后端mysql
  "MySQLOrchestratorHost": "192.168.0.216",
  "MySQLOrchestratorPort": 3306,
  "MySQLOrchestratorDatabase": "orchestrator",
  "MySQLOrchestratorUser": "orchestrator",
  "MySQLOrchestratorPassword": "mysql",
   "RaftEnabled": true,
  "RaftDataDir": "/data/orchestrator",
  "RaftBind": "192.168.0.216",
  "DefaultRaftPort": 10008,
  "RaftNodes": [
    "192.168.0.216",
    "192.168.0.217",
    "192.168.0.218"
  ],

以下2项需要设置为"*",否则不会发生启动切换;另 /data/orchestrator 让orc自动创建

"RecoverMasterClusterFilters": [
    "*"
  ],
  "RecoverIntermediateMasterClusterFilters": [
    "*"
  ],

用户密码登录

"HTTPAuthUser": "admin",
"HTTPAuthPassword": "Jsxfws@12",

启动:

cd /usr/local/orchestrator
./orchestrator -config ./orchestrator.conf.json http >> ./orchestrator.log 2>&1 &

查看状态

http://192.168.0.218:3000/web/status

日常操作

注意:

gtid模式下,change master 需设置Auto_Position=1

set global slave_net_timeout=8; 约8~10秒感知主库异常
change master MASTER_CONNECT_RETRY=1 主库1秒无数据变更,备库会尝试重连主库

web discover


20240325180056image.png

orchestrator-client
# 列出集群,集群别名
orchestrator-client -c api -path clusters 
orchestrator-client -c clusters-alias      
显示别名为vm-test1的集群的master
# 列出别名为"node02"的集群
orchestrator-client -c which-cluster-master -alias node02
#显示别名为node02的集群下所有的实例
orchestrator-client -c which-cluster-instances -alias node02

web方式遇到报错无反馈,使用命令行方式discovery:

orchestrator-client -c discover -i 192.168.0.211:3306

注:orc会通过dns lookup ip会受影响 (如在VM中设置dns1=114.114.114.114)

故障检测

自动故障切换

在主库上执行shutdown模拟主库故障

shutdown;


20240326014329image.png
注:主库宕机,自动Failover到node02

优雅的主从切换
# orchestrator-client -c graceful-master-takeover -i node01:3306
#master由node02 切换到 node01
#orchestrator-client -c graceful-master-takeover --alias node02 -d node01:3306 

手动强制切换

#orchestrator-client -c force-master-failover --alias node01 -i node02:3306


20240326202648image.png
原主被分离,可以手动处理后再加入

参考:

https://github.com/openark/orchestrator/blob/master/docs/install.md

https://github.com/openark/orchestrator/blob/master/docs/raft-vs-sync-repl.md

https://github.com/github/orchestrator/blob/master/docs/configuration-raft.md

https://github.com/openark/orchestrator/blob/master/docs/high-availability.md

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论