环境
OS:Centos 7
mysql(5.7)主从:
192.168.1.100 hmaster 主
192.168.1.102 hslavea 从
192.168.1.103 hslaveb 从

192.168.1.104 orchestrator元数据使用的数据库

 

前提条件:部署好被管控的mysql主从

1.下载安装介质
下载地址:https://github.com/openark/orchestrator/releases,选择相应的版本
orchestrator-client-3.1.4-1.x86_64.rpm
orchestrator-3.1.4-1.x86_64.rpm

下面两个安装包需要自行下载
oniguruma-6.8.2-2.el7.x86_64.rpm
jq-1.6-2.el7.x86_64.rpm

 

2.安装在每个mysql服务器上都进行安装
rpm -ivh orchestrator-client-3.1.4-1.x86_64.rpm
rpm -ivh orchestrator-3.1.4-1.x86_64.rpm
rpm -ivh oniguruma-6.8.2-2.el7.x86_64.rpm
rpm -ivh jq-1.6-2.el7.x86_64.rpm

 

3.设置hostname
每台机器设置相应的hostname
hostnamectl set-hostname hmaster ##192.168.1.100
hostnamectl set-hostname hslavea ##192.168.1.102
hostnamectl set-hostname hslaveb ##192.168.1.103
hostnamectl set-hostname orcmgr ##192.168.1.104

 

4.设置hostname
每台机器设置hosts文件
vi /etc/hosts文件添加如下项目
192.168.1.100 hmaster
192.168.1.102 hslavea
192.168.1.103 hslaveb
192.168.1.104 orcmgr

 

5.orchestrator元数据使用的数据库安装
192.168.1.104上操作
安装mysql数据库步骤省略,然后需要创建元数据库和用户

[mysql@localhost bin]$ /opt/mysql57/bin/mysql -h localhost -uroot -p -S /opt/mysql57/mysql.sock
mysql>create database orchestrator;
mysql>create user 'orchestrator'@'%' identified by 'mysql';
mysql>grant all on orchestrator.* to 'orchestrator'@'%';

 

6.在主库上创建用户
192.168.1.100上操作

GRANT SELECT, RELOAD, PROCESS, SUPER, REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'orchestrator'@'%' identified by 'mysql';

创建后会自动同步到另外2个从库

 

7.编辑配置文件
在192.168.1.100上操作,然后拷贝到另外2个节点
拷贝一个模板的过来进行修改

[root@localhost orchestrator]# cd /usr/local/orchestrator/
[root@localhost orchestrator]# cp orchestrator-sample.conf.json orchestrator.conf.json
{
  "Debug": true,
  "EnableSyslog": false,
  "ListenAddress": ":3000",
  "MySQLTopologyUser": "orchestrator",
  "MySQLTopologyPassword": "mysql",
  "MySQLTopologyCredentialsConfigFile": "",
  "MySQLTopologySSLPrivateKeyFile": "",
  "MySQLTopologySSLCertFile": "",
  "MySQLTopologySSLCAFile": "",
  "MySQLTopologySSLSkipVerify": true,
  "MySQLTopologyUseMutualTLS": false,
  "MySQLOrchestratorHost": "192.168.1.104",
  "MySQLOrchestratorPort": 3306,
  "MySQLOrchestratorDatabase": "orchestrator",
  "MySQLOrchestratorUser": "orchestrator",
  "MySQLOrchestratorPassword": "mysql",
  "MySQLOrchestratorCredentialsConfigFile": "",
  "MySQLOrchestratorSSLPrivateKeyFile": "",
  "MySQLOrchestratorSSLCertFile": "",
  "MySQLOrchestratorSSLCAFile": "",
  "MySQLOrchestratorSSLSkipVerify": true,
  "MySQLOrchestratorUseMutualTLS": false,
  "MySQLConnectTimeoutSeconds": 1,
  "RaftEnabled": true,
  "RaftDataDir": "/data/orchestrator",
  "RaftBind": "192.168.1.100",
  "DefaultRaftPort": 10008,
  "RaftNodes": [
    "192.168.1.100",
    "192.168.1.102",
    "192.168.1.103"
  ],

 

模板默认是没有raft配置项的,需要自行加入

  "RaftEnabled": true,
  "RaftDataDir": "/data/orchestrator",
  "RaftBind": "192.168.1.100",
  "DefaultRaftPort": 10008,
  "RaftNodes": [
    "192.168.1.100",
    "192.168.1.102",
    "192.168.1.103"
  ],

 

需要创建目录(每个数据库节点都需要执行)
mkdir -p /data/orchestrator

 

8.拷贝配置文件到另外2个节点
scp /usr/local/orchestrator/orchestrator.conf.json root@192.168.1.102:/usr/local/orchestrator/
scp /usr/local/orchestrator/orchestrator.conf.json root@192.168.1.103:/usr/local/orchestrator/

拷贝过来修改的地方:
“RaftBind”: “192.168.1.100” 这里分别修改更各自节点的ip

 

9.启动
每台机器都需要执行,也可以使用nohup后台执行
cd /usr/local/orchestrator
./orchestrator –config=./orchestrator.conf.json http

 

10.web访问
每个数据库节点都可以访问
http://192.168.1.100:3000
http://192.168.1.102:3000
http://192.168.1.103:3000

 

1.主从切换
orchestrator-client -c graceful-master-takeover -a hslavea:3306 -d hmaster:3306
新主库为:hmaster,但是hslavea不会自动成为新主库的从,需要手工指定后重启动

mysql> CHANGE MASTER TO MASTER_HOST='hmaster', 
              MASTER_PORT=3306,
              MASTER_USER='repl', 
              MASTER_PASSWORD='mysql', 
              MASTER_AUTO_POSITION=1,
              MASTER_CONNECT_RETRY=1, 
              MASTER_RETRY_COUNT=86400, 
              MASTER_HEARTBEAT_PERIOD=2;

mysql> start slave;

 

2.查看拓扑情况
[root@hmaster orchestrator]# orchestrator-client -c topology -i hmaster:3306
hmaster:3306 [0s,ok,5.7.29-log,rw,ROW,>>,GTID]
+ hslavea:3306 [0s,ok,5.7.29-log,ro,ROW,>>,GTID]
+ hslaveb:3306 [0s,ok,5.7.29-log,rw,ROW,>>,GTID]

 

— The End–

 

原文地址:http://www.cnblogs.com/hxlasky/p/16858590.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性