GitLab配置说明
配置文件作用及目录
# vi /etc/gitlab/gitlab.rbgitlab配置文件# vi /var/opt/gitlab/gitlab-rails/etc/unicorn.rbunicorn配置文件# vi /var/opt/gitlab/gitlab-rails/etc/gitlab.ymlgitlab-ctl reconfigure 命令会覆盖这个文件# vi /var/opt/gitlab/nginx/conf/gitlab-http.conf自带nginx位置# vi /usr/local/nginx/conf/nginx.conf自己安装的nginx路径
不适用自带的nginx,使用自己安装的nginx配置方式
- gitlab.rb 文件配置 修改
```cmd ………. external_url ‘http://阿里云外网ip:9091’ gitlab_rails[‘trusted_proxies’] = [‘127.0.0.1’]
………. unicorn[‘listen’] = ‘127.0.0.1’ unicorn[‘port’] = 9092
………. gitlab_workhorse[‘listen_network’] = “tcp” gitlab_workhorse[‘listen_addr’] = “127.0.0.1:9099”
………. unicorn[‘worker_timeout’] = 60 unicorn[‘worker_processes’] = 2
………. nginx[‘enable’] = false
………. unicorn[‘worker_memory_limit_min’] = “200 * 1 « 20” unicorn[‘worker_memory_limit_max’] = “300 * 1 « 20”
………. sidekiq[‘concurrency’] = 15
………. postgresql[‘max_worker_processes’] = 4
2. unicorn.rb 文件查看,与 gitlab.rb 中配置的端口号相同
```cmd
# What ports/sockets to listen on, and what options for them.
listen "127.0.0.1:9092", :tcp_nopush => true
listen "/var/opt/gitlab/gitlab-rails/sockets/gitlab.socket", :backlog => 1024
-
nginx.conf 配置
```cmd server { listen 9091; server_name 阿里云外网ip; server_tokens off; ## 不显示nginx版本location / { proxy_pass http://gitlab-workhorse; } }
upstream gitlab-workhorse { server 127.0.0.1:9099; }
4. 重载
```cmd
$ gitlab-ctl reconfigure
$ gitlab-ctl restart
$ /usr/local/nginx/sbin/nginx -s reload
GitLab占用内存过大解决办法
- 修改
unicorn['worker_processes'] = 2减少进程数,这个最小是2,设置为1会挂掉unicorn['worker_timeout'] = 60 ###! Minimum worker_processes is 2 at this moment ###! See https://gitlab.com/gitlab-org/gitlab-ce/issues/18771 # unicorn['worker_processes'] = 2 - 减少内存
```cmdOnly change these settings if you understand well what they mean
###! Docs: https://docs.gitlab.com/ee/administration/operations/unicorn.html#unicorn-worker-killer ###! https://github.com/kzk/unicorn-worker-killer
unicorn[‘worker_memory_limit_min’] = “1024 * 1 « 20”
unicorn[‘worker_memory_limit_max’] = “1280 * 1 « 20”
unicorn[‘worker_memory_limit_min’] = “100 * 1 « 20” unicorn[‘worker_memory_limit_max’] = “200 * 1 « 20”
3. 减少sidekip并发数,默认是25
```cmd
sidekiq['concurrency'] = 10
- 减少数据库缓存和数据库并发数 ```cmd 数据库缓存修改 ##! recommend value is 1/4 of total RAM, up to 14GB. postgresql[‘shared_buffers’] = “256MB”
数据库并发数修改 postgresql[‘max_worker_processes’] = 4 ```