配置环境变量
export PATH=$PATH:/usr/local/mysql-shell/bin/:/usr/local/mysql/bin/:/usr/local/mysql-router/bin
source /etc/profile
配置mysqlrouter
[root@mysql_m bin]# ./mysqlrouter --bootstrap mgr@mysql_m:3306 -d myrouter --user=ro
otPlease enter MySQL password for mgr:
# Bootstrapping MySQL Router instance at '/usr/local/mysql-router/bin/myrouter'...
- Creating account(s) (only those that are needed, if any)
- Verifying account (using it to run SQL queries that would be run by Router)
- Storing account in keyring
- Adjusting permissions of generated files
- Creating configuration /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
# MySQL Router configured for the InnoDB Cluster 'mycluster'
After this MySQL Router has been started with the generated configuration
$ ./mysqlrouter -c /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
InnoDB Cluster 'mycluster' can be reached by connecting to:
## MySQL Classic protocol
=================================================================================
[root@mysql_s1 bin]# ./mysqlrouter --bootstrap mgr@mysql_s1:3306 -d myrouter --user=root
Please enter MySQL password for mgr:
# Reconfiguring MySQL Router instance at '/usr/local/mysql-router/bin/myrouter'...
- Fetching password for current account (mysql_router1_a51yps5zlikm) from keyring
- Creating account(s) (only those that are needed, if any)
Fetching Cluster Members
trying to connect to mysql-server at mysql_m:3306
- Creating account(s) (only those that are needed, if any)
- Using existing certificates from the '/usr/local/mysql-router/bin/myrouter/data' directory
- Verifying account (using it to run SQL queries that would be run by Router)
- Storing account in keyring
- Adjusting permissions of generated files
- Creating configuration /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
# MySQL Router configured for the InnoDB Cluster 'mycluster'
After this MySQL Router has been started with the generated configuration
$ ./mysqlrouter -c /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
InnoDB Cluster 'mycluster' can be reached by connecting to:
## MySQL Classic protocol
=======================================================================================
[root@mysql_s2 bin]# ./mysqlrouter --bootstrap mgr@mysql_s2:3306 -d myrouter --user=root
Please enter MySQL password for mgr:
# Bootstrapping MySQL Router instance at '/usr/local/mysql-router/bin/myrouter'...
Fetching Cluster Members
trying to connect to mysql-server at mysql_m:3306
- Creating account(s) (only those that are needed, if any)
- Verifying account (using it to run SQL queries that would be run by Router)
- Storing account in keyring
- Adjusting permissions of generated files
- Creating configuration /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
# MySQL Router configured for the InnoDB Cluster 'mycluster'
After this MySQL Router has been started with the generated configuration
$ ./mysqlrouter -c /usr/local/mysql-router/bin/myrouter/mysqlrouter.conf
InnoDB Cluster 'mycluster' can be reached by connecting to:
## MySQL Classic protocol
启动mysql-route
[root@mysql_m bin]# ls
myrouter mysqlrouter mysqlrouter_keyring mysqlrouter_passwd mysqlrouter_plugin_info
[root@mysql_m bin]# myrouter/start.sh
[root@mysql_m bin]# PID 1637 written to '/usr/local/mysql-router/bin/myrouter/mysqlrouter.pid'
stopping to log to the console. Continuing to log to filelog
====================================
[root@mysql_s1 bin]# myrouter/start.sh
[root@mysql_s1 bin]# PID 1373 written to '/usr/local/mysql-router/bin/myrouter/mysqlrouter.pid'
stopping to log to the console. Continuing to log to filelog
=========================================
[root@mysql_s2 bin]# myrouter/start.sh
[root@mysql_s2 bin]# PID 2556 written to '/usr/local/mysql-router/bin/myrouter/mysqlrouter.pid'
stopping to log to the console. Continuing to log to filelog
查看route进程:
ps -ef|grep myroute
netstat -tunlp|grep (route的pid)
a) 管理节点本机mysql-shell连接:
mysqlsh --uri root@localhost:6446
b) 管理节点本机mysql连接:
mysql -u root -h 127.0.0.1 -P 6446 -p
c) 远程客户机通过route连接mysql
mysql -u root -h manager_ip -P 6446 -p
server_uuid通过发出以下命令, 传递要成为组新主成员的成员的: SELECT group_replication_set_as_primary(member_uuid);