-
問題:公司
gitlab地址訪問報(bào)錯(cuò)502,連接所部署服務(wù)器執(zhí)行top命令發(fā)現(xiàn)gitlab相關(guān)服務(wù)其中兩個(gè)進(jìn)程占用cpu一直在90%以上 - 思路:一般地,資源占用過高,可以粗略地優(yōu)化一下,但是效果確實(shí)非常的明顯的。這里,主要是通過資源占用,然后將過高消耗資源的進(jìn)程給禁用掉,并且結(jié)合官方提供的一些默認(rèn)信息來調(diào)配。
- 解決辦法:主要調(diào)整的是限制內(nèi)存的使用,調(diào)整postgresql的緩存以及進(jìn)程,關(guān)閉prometheus監(jiān)控。
1. 編輯配置文件
cd /etc/gitlab
vi gitlab.rb
2. 配置文件中調(diào)整參數(shù)如下:
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. 應(yīng)用更改后的配置、重啟gitlab
gitlab-ctl reconfigure
gitlab-ctl restart
-
核實(shí)是否已解決:通過
top命令查看運(yùn)行中進(jìn)程的占用資源信息,等gitlab啟動(dòng)完成之后cpu占用率就會(huì)下去。
注:運(yùn)行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進(jìn)行g(shù)itlab-ctl reconfigure的時(shí)候,碰到問題:
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'
報(bào)錯(cuò)database_migrations問題涉及數(shù)據(jù)庫。使用gitlab-ctl stop停止gitlab服務(wù),執(zhí)行如下命令后重啟gitlab即可,命令如下:
chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
#重啟gitlab
gitlab-ctl reconfigure
gitlab-ctl restart
2.在啟動(dòng)gitlab的時(shí)候訪問是會(huì)提示502 Whoops, GitLab is taking too much time to respond. 開始以為是服務(wù)出了問題,實(shí)際這是一個(gè)正常的過程,此問題說明gitlab正在啟動(dòng),消耗內(nèi)存中,還沒有啟動(dòng)完成!這時(shí)不要去修改端口,啟動(dòng)等,等待一下即可。
3.項(xiàng)目數(shù)據(jù)備份時(shí)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 兩個(gè)文件包含敏感信息,未被備份到備份文件中,需要手動(dòng)備份。
轉(zhuǎn)載:http://www.mairoot.com/?p=2689
轉(zhuǎn)載:http://www.04007.cn/article/1039.html