CentOS 上优化 GitLab 的实用清单
一 硬件与存储基础
二 操作系统与内核参数
* soft nofile 65535* hard nofile 65535net.core.somaxconn = 65535net.ipv4.tcp_max_syn_backlog = 65535net.ipv4.ip_local_port_range = 1024 65535net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_fin_timeout = 30vm.swappiness = 10(减少换页,优先使用物理内存)sysctl -p 使配置生效。三 GitLab 组件与 Rails 配置
unicorn['worker_processes'] = <CPU 核心数的 1–2 倍>(如 4 核设为 4)unicorn['timeout'] = 300sidekiq['concurrency'] = 25(按 CPU/内存与队列压力调优)sidekiq['queues'] = ["default", "gitlab"]gitlab_rails['cache_store'] = :memory_store, { size: 64.megabytes }(减轻数据库压力,视内存酌情增大)gitlab-ctl reconfigure 使配置生效。四 网络 安全 与运维
firewall-cmd --permanent --add-service={http,https,ssh} && firewall-cmd --reloadgitlab_rails['gitlab_shell_ssh_port'] = 2222。external_url 'https://yourdomain.com' 并配置证书路径。gitlab-backup create(默认路径 /var/opt/gitlab/backups),恢复时按官方流程停止相关服务并指定备份时间戳。五 快速检查清单与注意事项
ulimit -n 达到 65535;sysctl 关键项已生效。unicorn['worker_processes']、sidekiq['concurrency']、cache_store 已按负载调整。/etc/gitlab/gitlab.rb 修改后必须执行 gitlab-ctl reconfigure。