part 1에 이어 Cluster를 생성하고 인스턴스를 추가하겠습니다.
▶ Cluster 생성 (Master)
현재 cluster를 생성한 1번 인스턴스는 seed 인스턴스로 데이터베어스의 초기 상태를 보유한 인스턴스이며, 클러스터에 멤버가 추가되면 다른 인스턴스에 데이터를 복제해주는 역할을 합니다.
[root@jh-my001 ~]# mysqlsh icadmin@192.168.100.40:3306
Please provide the password for 'icadmin@192.168.100.40:3306': *
Save password for 'icadmin@192.168.100.40:3306'? [Y]es/[N]o/Ne[v]er (default No): Y
MySQL Shell 8.0.28
Copyright (c) 2016, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its affiliates.
Other names may be trademarks of their respective owners.
Type '\help' or '\?' for help; '\quit' to exit.
Creating a session to 'icadmin@192.168.100.40:3306'
Fetching schema names for autocompletion... Press ^C to stop.
Your MySQL connection id is 29
Server version: 8.0.29-commercial MySQL Enterprise Server - Commercial
No default schema selected; type \use <schema> to set one.
MySQL 192.168.100.40:3306 ssl JS >
## Cluster 구성을 위해 설정이 정상인지 확인
MySQL localhost JS > dba.checkInstanceConfiguration('icadmin@192.168.100.40:3306')
Validating local MySQL instance listening at port 3306 for use in an InnoDB cluster...
This instance reports its own address as jh-my001:3306
Clients and other cluster members will communicate with it through this address by default. If this is not correct, the report_host MySQL system variable should be changed.
Checking whether existing tables comply with Group Replication requirements...
No incompatible tables detected
Checking instance configuration...
Instance configuration is compatible with InnoDB cluster
The instance 'jh-my001:3306' is valid to be used in an InnoDB cluster.
{
"status": "ok"
}
## cluster 생성
MySQL 192.168.100.40:3306 ssl JS > cluster = dba.createCluster('testcluster')
A new InnoDB cluster will be created on instance '192.168.100.40:3306'.
Validating instance configuration at 192.168.100.40:3306...
This instance reports its own address as 192.168.100.40:3306
Instance configuration is suitable.
NOTE: Group Replication will communicate with other members using '192.168.100.40:33061'. Use the localAddress option to override.
Creating InnoDB cluster 'testcluster' on '192.168.100.40:3306'...
Adding Seed Instance...
Cluster successfully created. Use Cluster.addInstance() to add MySQL instances.
At least 3 instances are needed for the cluster to be able to withstand up to
one server failure.
<Cluster:testcluster>
## cluster 생성 확인
MySQL 192.168.100.40:3306 ssl JS > cluster.status()
{
"clusterName": "testcluster",
"defaultReplicaSet": {
"name": "default",
"primary": "192.168.100.40:3306",
"ssl": "REQUIRED",
"status": "OK_NO_TOLERANCE",
"statusText": "Cluster is NOT tolerant to any failures.",
"topology": {
"192.168.100.40:3306": {
"address": "192.168.100.40:3306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.29"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "192.168.100.40:3306"
}
▶ Innodb Cluster 추가(Master 서버에서 진행)
다른 노드들을 cluster에 추가하며 기존 ONLINE 멤버보다 데이터가 뒤쳐져 있기때문에 seed 인스턴스의 현재 상태까지 동기화를 해주어야합니다.
seed인스턴스에 있는 기존 데이터 양이 큰경우 백업본을 가지고 복구를 하거나 clone을 하는것이 좋습니다.
MySQL 192.168.100.40:3306 ssl JS > dba.getCluster().addInstance('icadmin@192.168.100.41:3306', {ipWhitelist:'192.168.100.0/24'});
WARNING: The ipWhitelist option is deprecated in favor of ipAllowlist. ipAllowlist will be set instead.
NOTE: The target instance '192.168.100.41:3306' has not been pre-provisioned (GTID set is empty). The Shell is unable to decide whether incremental state recovery can correctly provision it.
The safest and most convenient way to provision a new instance is through automatic clone provisioning, which will completely overwrite the state of '192.168.100.41:3306' with a physical snapshot from an existing cluster member. To use this method by default, set the 'recoveryMethod' option to 'clone'.
The incremental state recovery may be safely used if you are sure all updates ever executed in the cluster were done with GTIDs enabled, there are no purged transactions and the new instance contains the same GTID set as the cluster or a subset of it. To use this method by default, set the 'recoveryMethod' option to 'incremental'.
Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone):
--> DB2를 DB1에 join 시키는건데 DB1의 데이터를 DB2에 넣어야되는데 동기화 방식을 어떤걸로 할거냐?
*Clone -> 물리적 COPY 속도 느림
*Incremental recovery ->
*Abort ->
Validating instance configuration at 192.168.100.41:3306...
This instance reports its own address as 192.168.100.41:3306
Instance configuration is suitable.
NOTE: Group Replication will communicate with other members using '192.168.100.41:33061'. Use the localAddress option to override.
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.
Adding instance to the cluster...
Monitoring recovery process of the new cluster member. Press ^C to stop monitoring and let it continue in background.
Clone based state recovery is now in progress.
NOTE: A server restart is expected to happen as part of the clone process. If the
server does not support the RESTART command or does not come back after a
while, you may need to manually start it back.
* Waiting for clone to finish...
NOTE: 192.168.100.41:3306 is being cloned from 192.168.100.40:3306
** Stage DROP DATA: Completed
** Clone Transfer
FILE COPY ############################################################ 100% Completed
PAGE COPY ############################################################ 100% Completed
REDO COPY ############################################################ 100% Completed
NOTE: 192.168.100.41:3306 is shutting down...
* Waiting for server restart... ready
* 192.168.100.41:3306 has restarted, waiting for clone to finish...
** Stage RESTART: Completed
* Clone process has finished: 72.61 MB transferred in about 1 second (~72.61 MB/s)
State recovery already finished for '192.168.100.41:3306'
The instance '192.168.100.41:3306' was successfully added to the cluster.
## 3번 인스턴스 추가
MySQL 192.168.100.40:3306 ssl JS > dba.getCluster().addInstance('icadmin@192.168.100.42:3306', {ipWhitelist:'192.168.100.0/24'});
WARNING: The ipWhitelist option is deprecated in favor of ipAllowlist. ipAllowlist will be set instead.
NOTE: The target instance '192.168.100.42:3306' has not been pre-provisioned (GTID set is empty). The Shell is unable to decide whether incremental state recovery can correctly provision it.
The safest and most convenient way to provision a new instance is through automatic clone provisioning, which will completely overwrite the state of '192.168.100.42:3306' with a physical snapshot from an existing cluster member. To use this method by default, set the 'recoveryMethod' option to 'clone'.
The incremental state recovery may be safely used if you are sure all updates ever executed in the cluster were done with GTIDs enabled, there are no purged transactions and the new instance contains the same GTID set as the cluster or a subset of it. To use this method by default, set the 'recoveryMethod' option to 'incremental'.
Please select a recovery method [C]lone/[I]ncremental recovery/[A]bort (default Clone):
Validating instance configuration at 192.168.100.42:3306...
This instance reports its own address as 192.168.100.42:3306
Instance configuration is suitable.
NOTE: Group Replication will communicate with other members using '192.168.100.42:33061'. Use the localAddress option to override.
A new instance will be added to the InnoDB cluster. Depending on the amount of
data on the cluster this might take from a few seconds to several hours.
Adding instance to the cluster...
Monitoring recovery process of the new cluster member. Press ^C to stop monitoring and let it continue in background.
Clone based state recovery is now in progress.
NOTE: A server restart is expected to happen as part of the clone process. If the
server does not support the RESTART command or does not come back after a
while, you may need to manually start it back.
* Waiting for clone to finish...
NOTE: 192.168.100.42:3306 is being cloned from 192.168.100.40:3306
** Stage DROP DATA: Completed
** Clone Transfer
FILE COPY ############################################################ 100% Completed
PAGE COPY ############################################################ 100% Completed
REDO COPY ############################################################ 100% Completed
NOTE: 192.168.100.42:3306 is shutting down...
* Waiting for server restart... ready
* 192.168.100.42:3306 has restarted, waiting for clone to finish...
** Stage RESTART: Completed
* Clone process has finished: 72.61 MB transferred in about 1 second (~72.61 MB/s)
State recovery already finished for '192.168.100.42:3306'
The instance '192.168.100.42:3306' was successfully added to the cluster.
## 이거 안하면 status로 안보임
MySQL 192.168.100.40:3306 ssl JS > dba.getCluster().rescan()
Rescanning the cluster...
Result of the rescanning operation for the 'testcluster' cluster:
{
"name": "testcluster",
"newTopologyMode": null,
"newlyDiscoveredInstances": [],
"unavailableInstances": [],
"updatedInstances": []
}
## cluster 추가된거 확인
MySQL 192.168.100.40:3306 ssl JS > dba.getCluster().status();
{
"clusterName": "testcluster",
"defaultReplicaSet": {
"name": "default",
"primary": "192.168.100.40:3306",
"ssl": "REQUIRED",
"status": "OK",
"statusText": "Cluster is ONLINE and can tolerate up to ONE failure.",
"topology": {
"192.168.100.40:3306": {
"address": "192.168.100.40:3306",
"memberRole": "PRIMARY",
"mode": "R/W",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.29"
},
"192.168.100.41:3306": {
"address": "192.168.100.41:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.29"
},
"192.168.100.42:3306": {
"address": "192.168.100.42:3306",
"memberRole": "SECONDARY",
"mode": "R/O",
"readReplicas": {},
"replicationLag": null,
"role": "HA",
"status": "ONLINE",
"version": "8.0.29"
}
},
"topologyMode": "Single-Primary"
},
"groupInformationSourceMember": "192.168.100.40:3306"
}
MySQL 192.168.100.40:3306 ssl JS > \sql
Switching to SQL mode... Commands end with ;
MySQL 192.168.100.40:3306 ssl SQL > select * from performance_schema.replication_group_members;
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| CHANNEL_NAME | MEMBER_ID | MEMBER_HOST | MEMBER_PORT | MEMBER_STATE | MEMBER_ROLE | MEMBER_VERSION | MEMBER_COMMUNICATION_STACK |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
| group_replication_applier | 1cd05d2e-cf6a-11ec-af4f-f220cd10bb6e | 192.168.100.40 | 3306 | ONLINE | PRIMARY | 8.0.29 | XCom |
| group_replication_applier | 1f7f3300-cf6a-11ec-bc66-f220cd2386f3 | 192.168.100.41 | 3306 | ONLINE | SECONDARY | 8.0.29 | XCom |
| group_replication_applier | 1fe1bcfd-cf6a-11ec-b5ad-f220cd849d34 | 192.168.100.42 | 3306 | ONLINE | SECONDARY | 8.0.29 | XCom |
+---------------------------+--------------------------------------+----------------+-------------+--------------+-------------+----------------+----------------------------+
3 rows in set (0.0004 sec)
'DataBase > MySQL & MariaDB' 카테고리의 다른 글
[MySQL - InnoDB cluster] part 4 Router설치 (0) | 2022.05.14 |
---|---|
[MySQL - InnoDB cluster] part 3 복구 테스트 (0) | 2022.05.14 |
[MySQL - InnoDB cluster] part 1 Mysql 설치 & shell설치 (2) | 2022.05.14 |
[Mysql - Performance parameter] (0) | 2022.03.24 |
[MariaDB - Sharding] use. Spider Engine (0) | 2022.03.12 |