之前升级 GitLab,升级后的 GitLab 占用了很大的内存,再加上不间断运行,导致吃内存越来越多。机器无法分配适当内存给 SVN server 和 Nexus,搜集了很多资料,终于在一篇文章中找到了合理的实践。参考文章

相关文章:

完整的 docker-compose.yml 如下:

version: "3"

services:
  gitlab:
    image: 'gitlab/gitlab-ce:13.12.12-ce.0'
    restart: always
    hostname: 'git.xxx.com'
    container_name: gitlab-xxx
    environment:
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'http://git.xxx.com'
        gitlab_rails['gitlab_shell_ssh_port'] = 9022
        gitlab_rails['time_zone'] = 'Asia/Shanghai'
  
        # 电子邮件相关功能
        gitlab_rails['smtp_enable'] = true
        gitlab_rails['smtp_address'] = "smtp.exmail.qq.com"
        gitlab_rails['smtp_port'] = 465
        gitlab_rails['smtp_user_name'] = "gitlab@xxx.com"
        gitlab_rails['smtp_password'] = "password"
        gitlab_rails['smtp_authentication'] = "login"
        gitlab_rails['smtp_enable_starttls_auto'] = true
        gitlab_rails['smtp_tls'] = true
        gitlab_rails['gitlab_email_from'] = 'gitlab@xxx.com'
  
        # Terraform
        gitlab_rails['terraform_state_enabled'] = false
  
        # 关闭用量统计
        gitlab_rails['usage_ping_enabled'] = false
        gitlab_rails['sentry_enabled'] = false
        grafana['reporting_enabled'] = false
  
        # 关闭容器仓库功能
        gitlab_rails['gitlab_default_projects_features_container_registry'] = false
        gitlab_rails['registry_enabled'] = false
        registry['enable'] = false
        registry_nginx['enable'] = false
  
        # 关闭包仓库
        gitlab_rails['packages_enabled'] = false
        gitlab_rails['dependency_proxy_enabled'] = false
  
        # GitLab KAS
        gitlab_kas['enable'] = false
        gitlab_rails['gitlab_kas_enabled'] = false
  
        # Mattermost
        mattermost['enable'] = false
        mattermost_nginx['enable'] = false
  
        # Kerberos
        gitlab_rails['kerberos_enabled'] = false
        sentinel['enable'] = false
  
        # 关闭 GitLab Pages
        gitlab_pages['enable'] = false
        pages_nginx['enable'] = false
  
        # 禁用 PUMA 集群模式
        puma['worker_processes'] = 0
        puma['min_threads'] = 1
        puma['max_threads'] = 2
  
        # 降低后台守护进程并发数
        sidekiq['max_concurrency'] = 5
  
        gitlab_ci['gitlab_ci_all_broken_builds'] = false
  
        gitlab_ci['gitlab_ci_add_pusher'] = false
  
        # 关闭监控
        prometheus_monitoring['enable'] = false
        alertmanager['enable'] = false
        node_exporter['enable'] = false
        redis_exporter['enable'] = false
        postgres_exporter['enable'] = false
        pgbouncer_exporter['enable'] = false
        gitlab_exporter['enable'] = false
        grafana['enable'] = false
        sidekiq['metrics_enabled'] = false
  
        # 调整数据库配置
        postgresql['shared_buffers'] = "128MB"
        postgresql['max_worker_processes'] = 4
        letsencrypt['enable'] = false
  ports:
    - '9080:80'
    - '9443:443'
    - '9022:22'
  volumes:
    - '/srv/gitlab/config:/etc/gitlab'
    - '/srv/gitlab/logs:/var/log/gitlab'
    - '/srv/gitlab/data:/var/opt/gitlab'

此时,重部署后的 GitLab,项目数为75个,只用来做代码托管,占用内存大约稳定为 1.5G,远远低于此前动不动就五六个 G。


2022-05-29 更新

GitLab 真是内存大户,哪怕启动优化,随着不间断的运行,吃了越来越多的内存😶

内存占用

优化之路,任重而道远~

Last modification:May 29th, 2022 at 03:42 pm
If you think my article is useful to you, please feel free to appreciate