orchestrator部署:
orchestrator-3.0.11.tar.gz ----服务包
orchestrator-cli-3.0.11-1.x86_64.rpm ----二进制命令
所有主机节点安装mysql5.7数据库
首先实现mysql的主从关系
orchestrator=192.168.41.128
master=192.168.41.129
slave1=192.168.41.130
slave2=192.168.41.131
修改hosts记录
vim /etc/hosts(所有主机添加)
192.168.41.128 orchestrator.example.com
192.168.41.129 master.example.com
192.168.41.130 slave1.example.com
192.168.41.131 slave2.example.com
orchestrator.example.com主机修改
修改mysql5.7初始密码
vim /etc/my.cnf
[mysqld]
skip-grant-tables ----添加一行
shell>mysql
mysql>use mysql
mysql>update user set authentication_string=PASSWORD('123') where user='root';
mysql>exit
重启mysql数据库
vim /etc/my.cnf
[mysqld]
#skip-grant-tables ----注释掉
新修改密码即刻过期,需要重新设置密码
mysql> set PASSWORD='123456';
[root@orchestrator ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 93
Server version: 5.7.22 MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>create database orchestrator; -----创建orchestrator软件使用数据库
mysql> create user orchestrator@'localhost' identified by '123'; -----创建授权用户
mysql> create user orchestrator@'orchestrator.example.com' identified by '123';
mysql> GRANT ALL ON orchestrator.* TO orchestrator@'localhost' ; ----授权
mysql> GRANT ALL ON orchestrator.* TO orchestrator@'orchestrator.example.com';
mysql>exit
安装orchestrator软件
rpm -ivh orchestrator-cli-3.0.11-1.x86_64.rpm ----获取二进制命令
tar xf orchestrator-3.0.11.tar.gz -C /usr/local
[root@orchestrator ~]# cp /usr/local/orchestrator-3.0.11/conf/orchestrator-sample.conf.json /etc/orchestrator.conf.json
[root@orchestrator ~]# vim /etc/orchestrator.conf.json
2 "Debug": true, ----开启测试信息
3 "EnableSyslog": false, ----关闭日志(测试环境之后可以关闭测试信息,开启系统日志)
4 "ListenAddress": ":3000", ----监听地址与端口
5 "MySQLTopologyUser": "orchestrator", ----后台数据库连接用户(在主库数据库中创建)
6 "MySQLTopologyPassword": "123456", ----后台用户密码
13 "MySQLOrchestratorHost": "192.168.41.128", ----软件监听主机地址
14 "MySQLOrchestratorPort": 3306, ----端口
15 "MySQLOrchestratorDatabase": "orchestrator", ----所属库
16 "MySQLOrchestratorUser": "orchestrator", ----登录用户
17 "MySQLOrchestratorPassword": "123", ----密码
master.example.com主机 设置:
vim /etc/my.cnf
[mysqld]
server_id=1
log-bin=binlog
创建同步账号:
[root@master ~]#
[root@master ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 27
Server version: 5.7.22-log MySQL Community Server (GPL)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> create user slave@'192.168.41.%' identified by '123'; ----创建主从同步用户
mysql> GRANT ALL ON *.* TO slave@'192.168.41.130' ;
mysql> create user orchestrator@'192.168.41.128' identified by '123456'; ----创建orchestrator软件授权用户
mysql> grant all on *.* to orchestrator@'192.168.41.128';
导出数据库
mysqldump -uroot -p123456 --all-databases --master-data=2 > /root/mysql_all.sql
scp /root@/mysql_all.sql root@192.168.41.130:/root
slave1.example.com 主机配置
vim /etc/my.cnf
[mysqld]
server_id=2
mysql -uroot -p123456 < /root/mysql_all.sql
mysql -uroot -p123456
mysql>change master to \
>MASTER_HOST='192.168.41.129',
>MASTER_USER='slave',
>MASTER_PASSWORD='123',
>MASTER_LOG_FILE='binlog_00001',
>MASTER_LOG_POS=772;
mysql> start slave;
mysql> show slave status\G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.41.129
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: binlog.000001
Read_Master_Log_Pos: 2461
Relay_Log_File: slave1-relay-bin.000004
Relay_Log_Pos: 317
Relay_Master_Log_File: binlog.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
实现主从同步之后,在orchestrator主机上启动服务,并且发现后台数据库
[root@orchestrator ~]# orchestrator http &
[root@orchestrator ~]# netstat -tnpl |grep :300
tcp6 0 0 :::3000 :::* LISTEN 6084/orchestrator
命令行发现:
orchestrator -c discover -i 192.168.41.129
orchestrator -c discover -i 192.168.41.130
orchestrator -c clusters ----查看集群
或者图形界面发现
Cluster ---> Discover ----> host:port
登录测试:
http://192.168.41.128:3000
[root@orchestrator orchestrator-3.0.11]# orchestrator -c help
Available commands (-c):
Smart relocation:
relocate Relocate a replica beneath another instance
relocate-below Synonym to 'relocate', will be deprecated
relocate-replicas Relocates all or part of the replicas of a given instance under another instance
regroup-replicas Given an instance, pick one of its replicas and make it local master of its siblings
Classic file:pos relocation:
move-up Move a replica one level up the topology
move-up-replicas Moves replicas of the given instance one level up the topology
move-below Moves a replica beneath its sibling. Both replicas must be actively replicating from same master.
move-equivalent Moves a replica beneath another server, based on previously recorded "equivalence coordinates"
repoint Make the given instance replicate from another instance without changing the binglog coordinates. Use with care
repoint-replicas Repoint all replicas of given instance to replicate back from the instance. Use with care
take-siblings Turn all siblings of a replica into its sub-replicas.
take-master Turn an instance into a master of its own master; essentially switch the two.
make-co-master Create a master-master replication. Given instance is a replica which replicates directly from a master.
get-candidate-replica Information command suggesting the most up-to-date replica of a given instance that is good for promotion
Binlog server relocation:
regroup-replicas-bls Regroup Binlog Server replicas of a given instance
GTID relocation:
move-gtid Move a replica beneath another instance.
move-replicas-gtid Moves all replicas of a given instance under another (destination) instance using GTID
regroup-replicas-gtid Given an instance, pick one of its replica and make it local master of its siblings, using GTID.
Pseudo-GTID relocation:
match Matches a replica beneath another (destination) instance using Pseudo-GTID
match-up Transport the replica one level up the hierarchy, making it child of its grandparent, using Pseudo-GTID
rematch Reconnect a replica onto its master, via PSeudo-GTID.
match-replicas Matches all replicas of a given instance under another (destination) instance using Pseudo-GTID
match-up-replicas Matches replicas of the given instance one level up the topology, making them siblings of given instance, using Pseudo-GTID
regroup-replicas-pgtid Given an instance, pick one of its replica and make it local master of its siblings, using Pseudo-GTID.
Replication, general:
enable-gtid If possible, turn on GTID replication
disable-gtid Turn off GTID replication, back to file:pos replication
reset-master-gtid-remove-own-uuid Reset master on instance, remove GTID entries generated by instance
skip-query Skip a single statement on a replica; either when running with GTID or without
stop-slave Issue a STOP SLAVE on an instance
start-slave Issue a START SLAVE on an instance
restart-slave STOP and START SLAVE on an instance
reset-slave Issues a RESET SLAVE command; use with care
detach-replica Stops replication and modifies binlog position into an impossible, yet reversible, value.
reattach-replica Undo a detach-replica operation
detach-replica-master-host Stops replication and modifies Master_Host into an impossible, yet reversible, value.
reattach-replica-master-host Undo a detach-replica-master-host operation
master-pos-wait Wait until replica reaches given replication coordinates (--binlog=file:pos)
enable-semi-sync-master Enable semi-sync replication (master-side)
disable-semi-sync-