반응형
MySQL MHA 원복(mha failback)
마스터 서버
- 슬레이브 호스트 목록 확인
mysql -h localhost -uroot -p'mysqlpassword' -e "SHOW SLAVE HOSTS"
$ mysql -h localhost -uroot -p'mysqlpassword' -e "SHOW SLAVE HOSTS"
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------+------+------+-----------+--------------------------------------+
| Server_id | Host | Port | Master_id | Slave_UUID |
+-----------+------+------+-----------+--------------------------------------+
| 3 | | 3306 | 2 | 3ebc580f-f8f7-11ed-adcf-080027704bff |
+-----------+------+------+-----------+--------------------------------------+
- bin-log(File) 파일 및 Position 확인
mysql -h localhost -uroot -p'mysqlpassword' -e "show master status\G" | egrep 'File|Position'
$ mysql -h localhost -uroot -p'mysqlpassword' -e "show master status\G" | egrep 'File|Position'
mysql: [Warning] Using a password on the command line interface can be insecure.
File: mysql-bin.000009
Position: 455
슬레이브 서버
- 슬레이브 복제 설정
mysql -h localhost -uroot -p'mysqlpassword' -e "
CHANGE MASTER TO
MASTER_HOST='192.168.56.102',
MASTER_USER='replication_user',
MASTER_PASSWORD='password',
MASTER_LOG_FILE='mysql-bin.000009',
MASTER_LOG_POS=455;
"
$ mysql -h localhost -uroot -p'mysqlpassword' -e "
> CHANGE MASTER TO
> MASTER_HOST='192.168.56.102',
> MASTER_USER='replication_user',
> MASTER_PASSWORD='password',
> MASTER_LOG_FILE='mysql-bin.000009',
> MASTER_LOG_POS=455;
> "
mysql: [Warning] Using a password on the command line interface can be insecure.
- 슬레이브 서버 다시 시작
mysql -h localhost -uroot -p'mysqlpassword' -e "start slave"
$ mysql -h localhost -uroot -p'mysqlpassword' -e "start slave"
mysql: [Warning] Using a password on the command line interface can be insecure.
- 슬레이브 상태 확인
mysql -hlocalhost -uroot -p'mysqlpassword' -e "show slave status\G" | egrep 'Slave_IO_Running|Slave_SQL_Running|Seconds_Behind_Master'
$ mysql -hlocalhost -uroot -p'mysqlpassword' -e "show slave status\G" | egrep 'Slave_IO_Running|Slave_SQL_Running|Seconds_Behind_Master'
mysql: [Warning] Using a password on the command line interface can be insecure.
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Seconds_Behind_Master: 0
Slave_SQL_Running_State: Slave has read all relay log; waiting for more updates
마스터 서버
- 슬레이브 호스트 확인
mysql -h localhost -uroot -p'mysqlpassword' -e "SHOW SLAVE HOSTS"
$ mysql -h localhost -uroot -p'mysqlpassword' -e "SHOW SLAVE HOSTS"
mysql: [Warning] Using a password on the command line interface can be insecure.
+-----------+------+------+-----------+--------------------------------------+
| Server_id | Host | Port | Master_id | Slave_UUID |
+-----------+------+------+-----------+--------------------------------------+
| 1 | | 3306 | 2 | 3ef5caf4-f619-11ed-96e6-080027704bff |
| 3 | | 3306 | 2 | 3ebc580f-f8f7-11ed-adcf-080027704bff |
+-----------+------+------+-----------+--------------------------------------+
728x90
반응형
'리눅스' 카테고리의 다른 글
MySQL MHA 설치 및 구성하기 (0) | 2023.05.24 |
---|---|
[리눅스] MySQL Replication 구성(MySQL 복제) (0) | 2023.05.23 |
MySQL에서 리플리케이션을 다시 연결하는 방법 (0) | 2023.05.23 |
MySQL에서 신규 데이터베이스를 생성하고 데이터를 추가하고 조회하는 방법 (0) | 2023.05.23 |
[리눅스] MySQL 5.7에서 마스터-슬레이브(Master-Slave) 구성을 설정하는 방법 (0) | 2023.05.23 |