2-17

记一次CPU负载过高的修复过程

记一次CPU负载过高的修复过程

  • 自2.12日起服务器常常在几个小时后突然发生CPU负载过高(可以顶到100%),此时不论使用什么方式均不能登录服务器(SSH,WordPress均不行)重启后服务器恢复正常:img
  • 使用类似指令:
1
journalctl --since="xxx"|grep xxx

寻找问题发现每次CPU负载升高时存在如下类似记录:

1
2
Starting Daily apt upgrade and clean activities...
Starting Snap Daemon...

又发现类似如下记录:

1
snapd.service: Consumed 41.549s CPU time.

怀疑snapd(应用包管理软件)消耗资源,故关闭snapd:

1
2
3
systemctl disable snapd.service
systemctl disable snapd.socket
systemctl disable snapd.seeded.service
  • 2.16凌晨1:36再次发生问题,且记录中仍存在apt更新,故关闭apt每日更新:将etc/apt/apt.conf.d/20auto-upgrades中设置项均改为0
1
2
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";

关闭服务:

1
2
systemctl disable unattended-upgrades.service
systemctl stop unattended-upgrades.service
  • 经检查,直到本文写作之时,服务器CPU保持在2%使用以下,甚至内存也从80%消耗降低至56%

使用sshfs挂载,优化文件上传方式

1
apt-get install sshfs

2-17
http://xsyangtuo.top/2-17.html
作者
XSYangtuo
发布于
2024年2月17日
许可协议