下面从系统层面、GitLab 自身配置、日常使用三个维度,给你一份在 Ubuntu 上优化 GitLab 的实用清单(适用于自托管 GitLab CE/EE)。
/var/opt/gitlab# 增大文件描述符
ulimit -n 65535
/etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535
/etc/sysctl.conf
vm.swappiness=10
net.core.somaxconn=1024
sysctl -p
配置文件:
/etc/gitlab/gitlab.rb
修改后执行:
gitlab-ctl reconfigure
sidekiq['concurrency'] = 10
puma['worker_processes'] = 2
puma['min_threads'] = 4
puma['max_threads'] = 8
gitlab_rails['lfs_enabled'] = false # 不用 LFS 可关
prometheus['enable'] = false # 不需要监控可关
grafana['enable'] = false
postgresql['shared_buffers'] = "2GB"
postgresql['work_mem'] = "16MB"
postgresql['max_connections'] = 200
gitlab-rake gitlab:cleanup:project_uploads
gitlab-rake gitlab:cleanup:orphan_job_artifact_files
[[runners]]
executor = "docker"
[runners.docker]
tls_verify = false
image = "alpine"
privileged = false
concurrent = 4
cache:
paths:
- node_modules/
0 2 * * * /opt/gitlab/bin/gitlab-backup create
find /var/opt/gitlab/backups -mtime +7 -delete
gitlab-ctl status
htop
df -h
可以告诉我:
我可以给你针对性优化方案。