orchestrator 支持两种方式通过命令行操作
-
通过命令
orchestrator- 需要在服务器上安装 orchestrator,但是可以不作为服务启动。
- 需要配置orchestrator的文件,以便能够连接后端数据库
-
通过命令orchestrator-client
- 需要在服务器上安装orchestrator-client 脚本
- 不需要配置文件,但是需要指定ORCHESTRATOR_API 环境变量
orchestrator命令
./orchestrator -c help 查看帮助
./orchestrator -c find help 查看子命令的帮助
./orchestrator -c find help
find:
Find instances whose hostname matches given regex pattern. Example:
orchestrator -c find -pattern "backup.*us-east"
orchestrator 会按以下路径寻找找寻配置文件
/etc/orchestrator.conf.json,conf/orchestrator.conf.json,orchestrator.conf.json。通常情况下会把配置文件 /etc/orchestrator.conf.json 路径下 。因为该文件中会包含数据库的认证信息,所以配置文件建议控制访问权限。
也可以通过以下方式手动指定配置文件路径
orchestrator -c clusters --config=/path/to/config.file
-c 相当于 command ,并且该选项是必须添加的。
发现实例,Orchestrator 会自动发现该实例的主库 (如果有)或者 从副本(如果有),以获取整个集群的拓扑结构
orchestrator -c discover -i 127.0.0.1:22987
-i 相当于 instance ,并且格式必须是 hostname:port
打印更多执行信息
orchestrator -c discover -i 127.0.0.1:22987 --debug
orchestrator -c discover -i 127.0.0.1:22987 --debug --stack
--debug在所有操作中都很有用。--stack打印(大多数)错误的代码堆栈跟踪,对于开发和测试或提交错误报告很有用。
忘记实例,可以通过上面的discover 重新发现该实例
orchestrator -c forget -i 127.0.0.1:22987
打印某个实例所在集群的拓扑结构
orchestrator -c topology -i 127.0.0.1:22987
修改拓扑结构,将 实例 127.0.0.1:22988 移动到实例 127.0.0.1:22987下
orchestrator -c relocate -i 127.0.0.1:22988 -d 127.0.0.1:22987
修改拓扑结构 ,将10.0.0.2:3306 下的从副本移动到 实例10.0.0.6 下
orchestrator -c relocate-replicas -i 10.0.0.2:3306 -d 10.0.0.6
变更之前
10.0.0.1:3306
+ 10.0.0.2:3306
+ 10.0.0.3:3306
+ 10.0.0.4:3306
+ 10.0.0.5:3306
+ 10.0.0.6:3306
orchestrator -c relocate-replicas -i 10.0.0.2:3306 -d 10.0.0.6
变更之后
10.0.0.1:3306
+ 10.0.0.2:3306
+ 10.0.0.6:3306
+ 10.0.0.3:3306
+ 10.0.0.4:3306
+ 10.0.0.5:3306
多层的复制拓扑结构中 (级联复制),将该实例向上移动一层
orchestrator -c move-up -i 127.0.0.1:22988
多层的复制拓扑结构中 (级联复制),将该实例向下移动议程
orchestrator -c move-below -i 127.0.0.1:22988 -d 127.0.0.1:22990 --debug
设置只读 或 可写
orchestrator -c set-read-only -i 127.0.0.1:22988
orchestrator -c set-writeable -i 127.0.0.1:22988
问题
需要添加参数 --ignore-raft-setup,如果不加该参数报错
2023-09-13 15:50:56 FATAL Orchestrator configured to run raft ("RaftEnabled": true). All access must go through the web API of the active raft node. You may use the orchestrator-client script which has a similar interface to the command line invocation. You may override this with --ignore-raft-setup
使用举例
查看信息
打印所有匹配到的实例
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c find -pattern "ehr-db-mysql-test-s0*"
打印根据名字 ,端口,版本匹配到的实例
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c search -pattern "5.7.28"
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c search -pattern "5306"
打印所有被oc管控的集群
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c clusters
打印所有被orc管控的集群的别名
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c clusters-alias
所有集群的所有可写的主库
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c all-clusters-masters
根据集群中某个实例的名称打印集群拓扑
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c topology -i ehr-db-mysql-test-s03.zjy:5306
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c topology-tabulated -i ehr-db-mysql-test-s03.zjy:5306
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c topology-tags -i ehr-db-mysql-test-s03.zjy:5306
这两种只是格式不同
打印所有的实例
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c all-instances
根据实例返回实例所在的集群别名
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster -i
根据实例返回实例所在的集群别名
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-alias -i ehr-db-mysql-test-s03.zjy:5306
根据实例返回实例所在的集群域名
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-domain -i ehr-db-mysql-test-s03.zjy:5306
根据实例返回实例所在的集群主库
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-master -i ehr-db-mysql-test-s03.zjy:5306
根据实例返回实例所在的集群中所有实例
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-instances -i ehr-db-mysql-test-s03.zjy:5306
返回实例状态
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c instance-status -i ehr-db-mysql-test-s03.zjy:5306
输出集群中的副本列表,可以作为 pt-online-schema-change 操作控制副本
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-osc-replicas -i ehr-db-mysql-test-s03.zjy:5306
输出集群中的副本列表,可以作为 gh-ost 工作服务器
./orchestrator -config orchestrator-sample.conf.json --ignore-raft-setup -c which-cluster-gh-ost-replicas -i ehr-db-mysql-test-s03.zjy:5306