MySQL8 복제 설정시 발생하는 오류에대한 환경설정
복사가 아니라 복제설정을 할때 오류가 났었던 부분에 대한것입니다.
하나는 서버ID 설정을 하지 않은것이고 다른 하나는 인증과 관련된 부분 입니다.
# 복제DB 허용할것과 하지 않을것
replicate_do_db = replDB
replicate-ignore-db = information_schema
replicate-ignore-db = performance_schema
replicate-ignore-db = mysql
replicate-ignore-db = sys
replicate-ignore-db = test
# 일부 오류는 무시하고 처리 한다.
slave-skip-errors = 1146,1051,1396,1008,1007,1032
# IP기반으로만 사용하기
skip-name-resolve
# Master
server-id = 1
# 슬레이브
server-id = 200
위 설정이 제대로 되지 않으면 아래와 같은것을 볼수 있을 것이다.
반드시 서버를 구분할 수 있는 id를 줘야 합니다.
Last_IO_Errno: 13117
Last_IO_Error: Fatal error: The slave I/O thread stops because master and slave have equal MySQL server ids; these ids must be different for replication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
systemctl restart mysqld 하지 말고 확실하게 stop 처리한다음.
netstat -antp 로 포트 없어졌는지 확인한 다음.
systemctl start mysqld 하는 것을 권장 한다.
---------------------------------------------------------------------------------------------------
stop slave를 한다음 아래 명령이 들어가야 한다.
CHANGE MASTER TO
MASTER_HOST='서버IP',
MASTER_USER='root',
MASTER_PASSWORD='비번',
MASTER_PORT=53306,
MASTER_AUTO_POSITION = 0,
MASTER_LOG_FILE='binlog.000002',
MASTER_LOG_POS=1,
MASTER_CONNECT_RETRY=3;
Last_IO_Errno: 2061
Last_IO_Error: error connecting to master 'root@1.2.3.4:3306' - retry-time: 1 retries: 2 message: Authentication plugin 'caching_sha2_password' reported error: Authentication requires secure connection.
https://hoing.io/archives/18540
1) 위 오류는 비밀번호 체계를 이전 처럼 환경설정을 해 주거나.
https://velog.io/@sixhustle/mysql-replication
IDENFITIFED WITH mysql_native_password
2) 아래 처럼 옵션을 추가해 주면 된다.
GET_SOURCE_PUBLIC_KEY=1,
기존의 CHANGE MASTER TO 이 명령도 사용이 가능하나. 8.0.23 부터는 아래로 변경 되었다고 한다.
CHANGE REPLICATION SOURCE TO