반응형
Caused by: java.sql.SQLException: Too many connections
해당 오류는 mysql에 연결된 클라이언트의 수가 일정수치 이상인 경우 나타난다.
확인방법
# mysql 접속
> mysql -u 계정 -p
> 비밀번호입력
# 현재 최대 동시 접속 가능 커넥션 수 확인
> show variables like 'max_connections';
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| max_connections | 151 |
+-----------------------+-------+
3 rows in set (0.174 sec)
# 현재 커넥션 관련 정보 확인
> show status like '%CONNECT%';
+-----------------------------------------------+-------+
| Variable_name | Value |
+-----------------------------------------------+-------+
| Aborted_connects | 563 |
| Aborted_connects_preauth | 0 |
| Connection_errors_accept | 0 |
| Connection_errors_internal | 563 |
| Connection_errors_max_connections | 563 |
| Connection_errors_peer_address | 0 |
| Connection_errors_select | 0 |
| Connection_errors_tcpwrap | 0 |
| Connections | 998 |
| Max_used_connections | 152 |
| Performance_schema_session_connect_attrs_lost | 0 |
| Slave_connections | 0 |
| Slaves_connected | 0 |
| Ssl_client_connects | 0 |
| Ssl_connect_renegotiates | 0 |
| Ssl_finished_connects | 0 |
| Threads_connected | 145 |
| wsrep_connected | OFF |
+-----------------------------------------------+-------+
# Max_used_connections은 최대로 동시에 접속한 수를 의미한다.
# 그러나 맨 처음에 조회한 정보를 보면 최대 동시접속 가능 수는 max_connections=151로 되어있음
# 500으로 늘려봤다.
> set global max_connections=500;
# (타임아웃도 늘림)
> set wait_timeout=60;
# 재시작
> systemctl restart mysql
# 연결수 변경 확인
> show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 500 |
+-----------------+-------+
해당 처리 후 해당오류가 사라졌음을 확인했다.
참고
- max_connections - 최대 동시 접속 가능 수 기본값=100
- wait_timeout - 종료전까지 요청이 없이 기다리는 시간
- Aborted_connects : MySQL 서버에 접속이 실패된 수
- Max_used_connections : 최대로 동시에 접속한 수
- Threads_connected : 현재 연결된 Thread 수
반응형