优化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
__EOF__

本文链接:https://www.cnblogs.com/xy51/p/16193421.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角【推荐】一下。您的鼓励是博主的最大动力!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了