com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
의 원인은 엄청나게 많지만 그중에 찾기 힘들었던 원인이 였습니다.
워크 밴치는 접속되고 서버에서도 접속이 되는데 spring batch에서 접속이 계속 안되서 원인 파악을 하니 서버 안에 mysql 의 접속 시간이 오래 걸린 원인을 파악후 처리; 다른사람등은 저처럼 오래 끌지 말고 빠르게 접속 해결 해주세요. 디비 접속 시간 문제입니다.
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure
The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server.
my.cnf 파일을 열어서 아래와 같이 mysqld 섹션에 skip-name-resolve 를 지정한후 MySQL 데몬을 restart
my.cnf 파일이 어디에 있는지 찾고
sudo는 루트 권한으로 검색 실행
sudo find / -name "my.cnf"
my.cnf 편집기로 열어서
sudo vi my.cnf
[mysqld] 가 있을텐데 밑에 skip-name-resolve 추가후 저장
[mysqld]
skip-name-resolve
다시 재기동함
service mysql restart
or
service mysql stop
&
service mysql start
엄밀히 말하자면 MySQL측 문제가 아니라고 함.
skip-name-resolve는 외부 클라이언트가 MySQL서버로 connect시에 dns lookup 즉 ip역질의를 skip합니다.
local에서 MySQL서버로 connect시에는 아무런 문제가 없지만. 외부에서 ip로 접속하는 환경의
DNS서버가 느려지거나 공격을 당하면 MySQL 서버도 영향을 받습니다.
아무튼 재기동을 하고 나니 예전처럼 접속 속도 정상화 됨.
오늘도 하나 배웁니다.
'DB > mysql' 카테고리의 다른 글
(Mysql)함수생성 (0) | 2023.04.27 |
---|---|
Partition,Index 조회,추가,삭제 간단 명령어 정리 (0) | 2023.03.27 |
파티셔닝(Partitioning) 추가 및 수정(예시포함) (0) | 2023.03.24 |
파티셔닝(Partitioning)이란? (0) | 2023.03.20 |
[mysql] 인덱스 생성, 삭제, 확인 (0) | 2023.03.15 |