Configuring GitLab application (Rails)

Configuring GitLab application (Rails)

本节介绍如何配置 GitLab 应用程序(Rails)组件.

注意:底部附近还有一些其他配置,用于其他 GitLab 应用程序服务器. 在继续安装 GitLab 之前,阅读并理解这些其他步骤非常重要.注意:建议尽可能通过使用Gitaly 的 ,以提高性能.

  1. 如有必要,请使用以下命令安装 NFS 客户端实用程序软件包:

  2. 在指定必要的 NFS 导出. /etc/fstab的确切内容取决于您选择配置 NFS 服务器的方式. 有关示例和各种选项,请参见NFS 文档 .

  3. 创建共享目录. 这些可能会有所不同,具体取决于您的 NFS 安装位置.

    1. mkdir -p /var/opt/gitlab/.ssh /var/opt/gitlab/gitlab-rails/uploads /var/opt/gitlab/gitlab-rails/shared /var/opt/gitlab/gitlab-ci/builds /var/opt/gitlab/git-data
  4. 使用 步骤 1 和 2下载/安装 Omnibus GitLab. 不要完成下载页面上的其他步骤.

  5. 创建/编辑/etc/gitlab/gitlab.rb并使用以下配置. 确保更改external_url以匹配最终的 GitLab 前端 URL. 根据您的 NFS 配置,您可能需要更改某些 GitLab 数据位置. 有关各种情况的/etc/gitlab/gitlab.rb配置值,请参见NFS 文档 . 下面的示例假定您已在默认数据位置中添加了 NFS 挂载. 此外,给出的 UID 和 GID 只是示例,您应该使用首选值进行配置.

在第一台应用程序服务器上,运行:

  1. sudo gitlab-ctl reconfigure

这应该编译配置并初始化数据库. 在下一步之前,不要在其他应用程序服务器上运行此命令.

其他的 GitLab 服务器( 第一个 GitLab 服务器之后配置的服务器)需要一些额外的配置.

  1. 配置共享机密. 这些值可以从/etc/gitlab/gitlab-secrets.json的主要 GitLab 服务器/etc/gitlab/gitlab-secrets.json . 运行上述步骤中的第一次reconfigure 之前,将此文件复制到辅助服务器.

  2. 运行以防止数据库迁移在升级时运行. 只有主 GitLab 应用程序服务器才能处理迁移.

  3. 推荐配置主机密钥. 将主应用程序服务器上/etc/ssh/的内容(私钥和公钥)复制到所有辅助服务器上的/etc/ssh . 这样可以防止访问负载平衡器后面的高可用性群集中的服务器时出现虚假的中间人攻击警报.

  4. 运行sudo gitlab-ctl reconfigure来编译配置.

注意:发生更新并执行数据库迁移后,您将需要重新启动 GitLab 应用程序节点.

如果启用了监视,则必须在所有 GitLab 服务器上将其启用.

  1. Make sure to collect , which are the IP addresses or DNS records of the Consul server nodes, for the next step. Note they are presented as Y.Y.Y.Y consul1.gitlab.example.com Z.Z.Z.Z

  2. 创建/编辑/etc/gitlab/gitlab.rb并添加以下配置:

    1. # Enable service discovery for Prometheus
    2. consul['enable'] = true
    3. consul['monitoring_service_discovery'] = true
    4. # Replace placeholders
    5. # Y.Y.Y.Y consul1.gitlab.example.com Z.Z.Z.Z
    6. # with the addresses of the Consul server nodes
    7. consul['configuration'] = {
    8. retry_join: %w(Y.Y.Y.Y consul1.gitlab.example.com Z.Z.Z.Z),
    9. }
    10. # Set the network addresses that the exporters will listen on
    11. node_exporter['listen_address'] = '0.0.0.0:9100'
    12. gitlab_workhorse['prometheus_listen_addr'] = '0.0.0.0:9229'
    13. sidekiq['listen_address'] = "0.0.0.0"
    14. puma['listen'] = '0.0.0.0'
    15. # Add the monitoring node's IP address to the monitoring list that allows it to
    16. # scrape the NGINX metrics. Replace placeholder `monitoring.gitlab.example.com` with
    17. # the address and/or subnets gathered from the monitoring node(s).
    18. gitlab_rails['monitoring_whitelist'] = ['monitoring.gitlab.example.com', '127.0.0.0/8']
    19. nginx['status']['options']['allow'] = ['monitoring.gitlab.example.com', '127.0.0.0/8']
  3. 运行sudo gitlab-ctl reconfigure来编译配置.

    警告:如果运行 Unicorn,则在gitlab.rb更改unicorn['listen']并运行sudo gitlab-ctl reconfigure后,收到HUP后,Unicorn 可能需要较长的时间才能完成重新加载. 有关更多信息,请参见问题 .

您尚未安装必要的 NFS 客户端实用程序. 请参阅上面的步骤 1.

  • mount: mount point /var/opt/gitlab/... does not exist

NFS 服务器上不存在此特定目录. 确保共享已导出并且存在于 NFS 服务器上,然后尝试重新安装.


可以在不停机的情况下升级 GitLab HA 安装,但是必须仔细协调升级过程,以免发生故障. 有关更多详细信息,请参见 .

  1. Configure the database
  2. Configure NFS