一次诡异的gitlab高cpu占用问题解决
缘起
最近发现nas服务器上cpu占用比以前高不少,cpu的温度也到了日常75℃的情况~~
top
看了占用,发现下面的进程一直占用着一个核心的cpu,而服务器上git相关的服务也就是gitlab了,因此排查了一番。
下面的进程cpu占用很高(这里只是示意一下):
30859 git 20 0 1099000 512184 19472 S 88 88 1:25.00 bundle
折腾过程
既然是gitlab的问题,那重新安装一下试试咯,重新remove然后install后,问题依旧。
查看错误日志
从网上找了下如何查看gitlab的错误日志,用下面的命令看到是redis
在不停的崩溃。
sudo gitlab-ctl tail
发现的崩溃情况如下:
2020-09-01_16:11:30.78340 [offset 0] Checking RDB file dump.rdb 2020-09-01_16:11:30.78366 [offset 26] AUX FIELD redis-ver = '5.0.7' 2020-09-01_16:11:30.78638 [offset 40] AUX FIELD redis-bits = '64' 2020-09-01_16:11:30.78690 [offset 52] AUX FIELD ctime = '1598513196' 2020-09-01_16:11:30.78697 [offset 67] AUX FIELD used-mem = '2783200' 2020-09-01_16:11:30.78700 [offset 83] AUX FIELD aof-preamble = '0' 2020-09-01_16:11:30.78703 [offset 85] Selecting DB ID 0 2020-09-01_16:11:30.78706 --- RDB ERROR DETECTED --- 2020-09-01_16:11:30.78710 [offset 73763] Unexpected EOF reading RDB file 2020-09-01_16:11:30.78714 [additional info] While doing: check-sum 2020-09-01_16:11:30.78717 [info] 835 keys read 2020-09-01_16:11:30.78721 [info] 765 expires 2020-09-01_16:11:30.78725 [info] 7 already expired 2020-09-01_16:11:31.79947 31222:C 02 Sep 2020 00:11:31.799 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 2020-09-01_16:11:31.79960 31222:C 02 Sep 2020 00:11:31.799 # Redis version=5.0.7, bits=64, commit=4891612b, modified=0, pid=31222, just started 2020-09-01_16:11:31.79966 31222:C 02 Sep 2020 00:11:31.799 # Configuration loaded 2020-09-01_16:11:31.80172 31222:M 02 Sep 2020 00:11:31.801 * Running mode=standalone, port=0. 2020-09-01_16:11:31.80189 31222:M 02 Sep 2020 00:11:31.801 # Server initialized 2020-09-01_16:11:31.80466 31222:M 02 Sep 2020 00:11:31.804 # Short read or OOM loading DB. Unrecoverable error, aborting now. 2020-09-01_16:11:31.80495 31222:M 02 Sep 2020 00:11:31.804 # Internal error in RDB reading function at rdb.c:2124 -> Unexpected EOF reading RDB file
从错误里我们明确的知道是redis不停的错误重启,导致gitlab一直没起来(这时候登录gitlab是失败的),由于很快的重启,cpu占用也就高了。
解决redis崩溃问题
既然从日志上看是dump.rdb文件存在损坏导致加载异常,我们删除就好啦,因为redis一般是内存数据的一些缓存,删除并不影响的。
从https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/1002,我们知道这个dump.rdb在/var/opt/gitlab/redis/
目录下,直接下面命令删除就好。
sudo rm /var/opt/gitlab/redis/dump.rdb
参考文档
https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/1002
发表评论