Note: Deal with the problem that gitlab occupies too much cpu once

  • Problem: An error was reported when accessing the company’s gitlabaddress 502. After connecting to the deployed server and executing topthe command gitlab, it was found that two processes occupied the CPU above the 90%above level .
  • Idea: Generally, the resource usage is too high and can be roughly optimized, but the effect is indeed very obvious. Here, it is mainly through resource occupation, and then disable the process that consumes too much resources, and deploy it in combination with some default information provided by the official.
  • Solution: The main adjustment is to limit the use of memory, adjust the cache and process of postgresql, and turn off prometheus monitoring.
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
  • Check whether it has been resolved: use topthe command to view the resource occupancy information of the running process, and the cpu occupancy rate will go down after gitlab startup is completed.

Note: gitlab-ctl reconfigureProblems that may be encountered when running the command

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 

Solution:
1. When gitlab is performing gitlab-ctl reconfigure, it encounters a problem:

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' 

The error database_migrations problem involves the database. Use gitlab-ctl stop to stop the gitlab service, execute the following command and restart gitlab, the command is as follows:

chmod 0755 /var/opt/gitlab/postgresql
systemctl restart gitlab-runsvdir
#重启gitlab
gitlab-ctl reconfigure
gitlab-ctl restart

2. When accessing gitlab, it will prompt 502 Whoops, GitLab is taking too much time to respond. At first I thought it was a problem with the service, but actually this is a normal process. This problem shows that gitlab is starting and consuming memory. Not started yet! At this time, do not modify the port, start, etc., just wait for a while.

3. When the project data is backed up, gitlab-rake gitlab:backup:create prompts: 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.
This section indicates that the two files gitlab.rb and gitlab-secrets.json contain sensitive information, which have not been backed up in the backup file and need to be backed up manually.

Reprint: http://www.mairoot.com/?p=2689
Reprint: http://www.04007.cn/article/1039.html

Guess you like

Origin blog.csdn.net/qq_40406380/article/details/122922544