David
发布于 2014-09-17 / 3 阅读 / 0 评论 / 0 点赞

Ubuntu 解决OpenVZ/Proxmox服務器rsyslog占用100%CPU

安装rsyslog后感觉VPS有点卡,不单单是SSH反应有点慢,就连网页打开也慢,美国线路抽风已经见惯不怪,可是也不至于SSH卡得更短线一样。 赶紧看下CPU占用,嘿嘿,100%占满,没错,元凶就是rsyslog。 按照我找到相关资料写,先是解决方法 打开[su_label type="important"]/etc/rsyslog.conf[/su_label]并找到[su_label type="important"]$ModLoad imklog[/su_label] 把他注释掉,然后重新启动rsyslog。现在CPU使用正常了,不再是100%。 问题虽然解决了,但是同样的配置在Azure的VPS上却一点问题都没有,估计又是搜索关键词用错的节奏。 正所谓“黄天不负有心人”,用好搜索引擎是很重要的。 在一个博客中找到这样子的解释,不过这博客好高端德文版的也有。

Right after a update of Ubuntu Server I faced that rsyslog used 100% CPU and that /var/log/syslog got filled up with following line, which was repeated almost every second:

[rsyslog] imklog: error reading kernel log - shutting down: Bad file descriptor

The problem is, that rsyslog tries to log kernel messages, which is as OpenVZ/Proxmox Container default not possible - to fix this, remove/comment out following line in the file /etc/rsyslog.conf (here already done):

# $ModLoad imklog   # provides kernel logging support

After that, restart rsyslog and the problem should be gone.

这位仁兄的情况跟我基本一样,同样是升级过系统。

说白了,就是OpenVZ和Proxmox架设的VPS并不支持内核日志,然后rsyslog就拼命提示说读取不了kernel日志,CPU最终被消耗殆尽。

感觉有些地方解释的不大清楚,将就点吧。