优化gitlab

记:处理一次gitlab占用cpu过高的问题

 

问题: 公司gitlab地址访问报错502,连接所部署服务器执行top命令发现gitlab相关服务其中两个进程占用cpu一直在90%以上
思路: 一般地,资源占用过高,可以粗略地优化一下,但是效果确实非常的明显的。这里,主要是通过资源占用,然后将过高消耗资源的进程给禁用掉,并且结合官方提供的一些默认信息来调配。
解决办法: 主要调整的是限制内存的使用,调整postgresql的缓存以及进程,关闭prometheus监控。
1. 编辑配置文件
cd /etc/gitlab
vi gitlab.rb

2. 配置文件中调整参数如下:
gitlab_rails['time_zone'] = 'Asia/Shanghai'
unicorn['worker_processes'] = 2
unicorn['worker_memory_limit_min'] = "100 * 1 << 20"
unicorn['worker_memory_limit_max'] = "250 * 1 << 20"
sidekiq['concurrency'] = 8
postgresql['shared_buffers'] = "128MB"
postgresql['max_worker_processes'] = 4
prometheus_monitoring['enable'] = false

3. 应用更改后的配置、重启gitlab
gitlab-ctl reconfigure
gitlab-ctl restart

核实是否已解决: 通过top命令查看运行中进程的占用资源信息,等gitlab启动完成之后cpu占用率就会下去。
注:运行gitlab-ctl reconfigure命令可能遇到的问题
There was an error running gitlab-ctl reconfigure:

Multiple failures occurred:
* Mixlib::ShellOut::ShellCommandFailed occurred in chef run: runit_service[gitlab-workhorse] (gitlab::gitlab-workhorse line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: ruby_block[reload_log_service] (/opt/gitlab/embedded/cookbooks/cache/cookbooks/runit/libraries/provider_runit_service.rb line 77) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /opt/gitlab/embedded/bin/sv force-reload /opt/gitlab/service/gitlab-workhorse/log ----
STDOUT: kill: run: /opt/gitlab/service/gitlab-workhorse/log: (pid 2093) 22549915s, got TERM
STDERR:
---- End output of /opt/gitlab/embedded/bin/sv force-reload /opt/gitlab/service/gitlab-workhorse/log ----
Ran /opt/gitlab/embedded/bin/sv force-reload /opt/gitlab/service/gitlab-workhorse/log returned 1
* Mixlib::ShellOut::ShellCommandFailed occurred in delayed notification: execute[clear the gitlab-rails cache] (gitlab::gitlab-rails line 409) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received ''
---- Begin output of /opt/gitlab/bin/gitlab-rake cache:clear ----
STDOUT:
STDERR:
---- End output of /opt/gitlab/bin/gitlab-rake cache:clear ----
Ran /opt/gitlab/bin/gitlab-rake cache:clear returned
解决办法:
1.gitlab进行gitlab-ctl reconfigure的时候,碰到问题:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 55) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
1
报错database_migrations问题涉及数据库。使用gitlab-ctl stop停止gitlab服务,执行如下命令后重启gitlab即可,命令如下:

chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
#重启gitlab
gitlab-ctl reconfigure
gitlab-ctl restart
2.在启动gitlab的时候访问是会提示502 Whoops, GitLab is taking too much time to respond. 开始以为是服务出了问题,实际这是一个正常的过程,此问题说明gitlab正在启动,消耗内存中,还没有启动完成!这时不要去修改端口,启动等,等待一下即可。

3.项目数据备份时gitlab-rake gitlab:backup:create提示:Warning: Your gitlab.rb and gitlab-secrets.json files contain sensitive data and are not included in this backup. You will need these files to restore a backup. Please back them up manually.
此部分表示 gitlab.rb 和 gitlab-secrets.json 两个文件包含敏感信息,未被备份到备份文件中,需要手动备份。

原文链接:https://blog.csdn.net/qq_40406380/article/details/122922544

posted @ 2022-04-26 09:25  不忘初心--学  阅读(1447)  评论(0编辑  收藏  举报