MySQL 데이터베이스가 자주 중지되고 다시 시작되지 않습니다.

MySQL 데이터베이스가 자주 중지되고 다시 시작되지 않습니다.

서버: Linode 전용 4G Ubuntu 18.04, Webmin + Virtualmin

때때로 mysql 서버가 중지되고 다시 시작하지 못합니다. 내가 찾을 수 있었던 로그는 다음과 같습니다.

Apr 11 20:54:57 bamboo kernel: [ 2082.915857] [ 7664]   112  7664   406072    46295   745472        3             0 mysqld
Apr 11 20:54:57 bamboo kernel: [ 2082.915859] [ 7701]     0  7701   129687      307   679936     1435             0 apache2
Apr 11 20:54:57 bamboo kernel: [ 2082.915860] [ 7702]     0  7702   129683      253   667648     1487             0 apache2
Apr 11 20:54:57 bamboo kernel: [ 2082.915861] Out of memory: Kill process 7664 (mysqld) score 40 or sacrifice child
Apr 11 20:54:57 bamboo kernel: [ 2082.919284] Killed process 7664 (mysqld) total-vm:1624288kB, anon-rss:185180kB, file-rss:0kB, shmem-rss:0kB
Apr 11 20:54:57 bamboo kernel: [ 2082.941447] oom_reaper: reaped process 7664 (mysqld), now anon-rss:0kB, file-rss:0kB, shmem-rss:0kB
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Failed with result 'signal'.
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Apr 11 20:54:57 bamboo systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
Apr 11 20:54:57 bamboo systemd[1]: Stopped MySQL Community Server.

..........

Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Scheduled restart job, restart counter is at 4.
Apr 11 14:02:53 bamboo systemd[1]: Stopped MySQL Community Server.
Apr 11 14:02:53 bamboo systemd[1]: Starting MySQL Community Server...
Apr 11 14:02:53 bamboo mysqld[4345]: Initialization of mysqld failed: 0
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Control process exited, code=exited status=1
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Failed with result 'exit-code'.
Apr 11 14:02:53 bamboo systemd[1]: Failed to start MySQL Community Server.
Apr 11 14:02:53 bamboo systemd[1]: mysql.service: Service hold-off time over, scheduling restart.

메모리 문제인 것 같습니다. 하지만 저는 이 서버에서 아주 작은 워드프레스 사이트를 호스팅하고 있는데, 메모리를 모두 사용하는 것은 불가능합니다.

서버 그래프: 여기에 이미지 설명을 입력하세요

CPU 사용량이 급증하는 것을 볼 수 있으며 이는 mysql 데이터베이스가 중지된 때입니다.

당시 저는 특별한 일을 하지 않았기 때문에 문제를 재현하고 관찰자가 가능한 원인을 파악하는 것이 꽤 어렵습니다. 이 문제를 조사하려면 로그를 더 자세히 조사해야 할 것 같지만, 이는 완전히 제가 아는 범위를 벗어납니다.

누군가 가능한 원인을 찾는 방법에 대해 밝힐 수 있습니까?

답변1

메모리 부족: 프로세스 종료그리고oom_reaper... 분명히 기억력 문제입니다.

MySQL이 중지되면 다음의 결과는 무엇입니까 free -h?

htop프로세스, RAM, CPU를 실시간으로 모니터링하려면 MySQL을 다시 시작하고 다른 콘솔을 체크인해 보세요 .

MySQL 콘솔에서 INNODB 버퍼 크기를 확인하세요. 실제 사용 가능한 메모리보다 클 수도 있습니다.

show global variables like 'innodb_buffer_pool_size';

SWAP 파티션이 있습니까?

워드프레스 쪽에는 워드프레스 웹사이트가 있고, 워드프레스 웹사이트가 있는데… 플러그인이 있나요? 일부는 데이터베이스 집약적이거나 최적화되지 않을 수 있습니다.

관련 정보