이전 part 1,2에 이어 관리용으로 Router를 설치하겠습니다.
https://jhdatabase.tistory.com/76
https://jhdatabase.tistory.com/77
InnoDB Router
▶Router 설치
설치 URL : https://downloads.mysql.com/archives/router/
[root@router ~]# wget https://downloads.mysql.com/archives/get/p/41/file/mysql-router-8.0.21-el7-x86_64.tar.gz
[root@router ~]# tar -zxvf mysql-router-8.0.21-el7-x86_64.tar.gz
[root@router ~]# groupadd mysqlrouter
[root@router ~]# useradd -g mysqlrouter mysqlrouter
[root@router ~]# mkdir -p /mysql/local
[root@router ~]# mv mysql-router-8.0.21-el7-x86_64 /mysql/local/router
[root@router ~]# mkdir /myrouter
[root@router ~]# chown -R mysqlrouter.mysqlrouter /mysql/ /myrouter/
[root@router network-scripts]# vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.100.40 jh-my1
192.168.100.41 jh-my2
192.168.100.42 jh-my3
## primary에 붙어야된다. --> cluster admin user로 만든다.
[root@router ~]# /mysql/local/router/bin/mysqlrouter --bootstrap icadmin@192.168.100.40:3306 --directory /myrouter --user=mysqlrouter
Please enter MySQL password for icadmin:
# Bootstrapping MySQL Router instance at '/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 /myrouter/mysqlrouter.conf
# MySQL Router configured for the InnoDB Cluster 'testcluster'
After this MySQL Router has been started with the generated configuration
$ /mysql/local/router/bin/mysqlrouter -c /myrouter/mysqlrouter.conf
the cluster 'testcluster' can be reached by connecting to:
## MySQL Classic protocol
- Read/Write Connections: localhost:6446
- Read/Only Connections: localhost:6447
## MySQL X protocol
- Read/Write Connections: localhost:64460
- Read/Only Connections: localhost:64470
[root@router ~]# cd /myrouter/data
[root@router myrouter]# ll
total 16
drwx------ 2 mysqlrouter mysqlrouter 37 May 10 10:18 data => Router config 파일
drwx------ 2 mysqlrouter mysqlrouter 28 May 10 10:18 log
-rw------- 1 mysqlrouter mysqlrouter 1238 May 10 10:18 mysqlrouter.conf
-rw------- 1 mysqlrouter mysqlrouter 80 May 10 10:18 mysqlrouter.key
drwx------ 2 mysqlrouter mysqlrouter 6 May 10 10:18 run
-rwx------ 1 mysqlrouter mysqlrouter 321 May 10 10:18 start.sh
-rwx------ 1 mysqlrouter mysqlrouter 137 May 10 10:18 stop.sh
## Server의 metaata파일
[root@router data]# vi /myrouter/data/state.json
{
"metadata-cache": {
"group-replication-id": "ad49b607-cf6c-11ec-812c-f220cd10bb6e",
"cluster-metadata-servers": [
"mysql://192.168.100.40:3306",
"mysql://192.168.100.41:3306"
]
},
"version": "1.0.0"Router
}
## Start
[root@router myrouter]# ./start.sh
[root@router myrouter]# PID 4235 written to '/myrouter/mysqlrouter.pid'
logging facility initialized, switching logging to loggers specified in configuration
## DB 서버 session 상태 확인 -> mysql_router1 스레드가 계속 Server의 metadata를 가져옵니다.
mysql> show processlist;
+-----+----------------------------+----------------------+------+---------+-------+----------------------------------------------------------+----------------------------------+
| Id | User | Host | db | Command | Time | State | Info |
+-----+----------------------------+----------------------+------+---------+-------+----------------------------------------------------------+----------------------------------+
| 6 | event_scheduler | localhost | NULL | Daemon | 63539 | Waiting on empty queue | NULL |
| 28 | system user | | NULL | Connect | 63403 | waiting for handler commit | Group replication applier module |
| 30 | system user | | NULL | Query | 52444 | Replica has read all relay log; waiting for more updates | NULL |
| 31 | system user | | NULL | Connect | 63403 | Waiting for an event from Coordinator | NULL |
| 32 | system user | | NULL | Connect | 63403 | Waiting for an event from Coordinator | NULL |
| 33 | system user | | NULL | Connect | 63403 | Waiting for an event from Coordinator | NULL |
| 34 | system user | | NULL | Connect | 63403 | Waiting for an event from Coordinator | NULL |
| 244 | root | localhost | NULL | Query | 0 | init | show processlist |
| 255 | mysql_router1_kn2mcp95o3ar | 192.168.100.53:60182 | NULL | Sleep | 0 | | NULL |
+-----+----------------------------+----------------------+------+---------+-------+----------------------------------------------------------+----------------------------------+
9 rows in set (0.00 sec)
## router로 접속
[root@jh-my001 ~]# mysql -uroot -p -h 192.168.100.53 -P 6447
## Round Robin형식으로 접속 확인
mysql> select @@server_id;
+-------------+
| @@server_id |
+-------------+
| 2 |
+-------------+
1 row in set (0.00 sec)
이상으로 mysql innodb cluster 구성을 마치겠습니다.
'DataBase > MySQL & MariaDB' 카테고리의 다른 글
[MySQL - NCP & OCI 이기종 플랫폼] part 1. Replication (0) | 2022.07.30 |
---|---|
[MariaDB to MySQL 데이터 이관] use. mysqldump (0) | 2022.07.15 |
[MySQL - InnoDB cluster] part 3 복구 테스트 (0) | 2022.05.14 |
[MySQL - InnoDB cluster] part 2 cluster생성/인스턴스 추가 (0) | 2022.05.14 |
[MySQL - InnoDB cluster] part 1 Mysql 설치 & shell설치 (2) | 2022.05.14 |