配置外部 Sidekiq 实例
- 版本:Free, Premium, Ultimate
- 产品:GitLab Self-Managed
您可以使用 GitLab 软件包中捆绑的 Sidekiq 来配置外部 Sidekiq 实例。Sidekiq 需要连接到 Redis、PostgreSQL 和 Gitaly 实例。
为 GitLab 实例上的 PostgreSQL、Gitaly 和 Redis 配置 TCP 访问
默认情况下,GitLab 使用 UNIX 套接字,未设置为通过 TCP 通信。要更改此设置:
-
配置打包的 PostgreSQL 服务器以监听 TCP/IP,将 Sidekiq 服务器的 IP 地址添加到
postgresql['md5_auth_cidr_addresses'] -
在您的 GitLab 实例上编辑
/etc/gitlab/gitlab.rb文件,并添加以下内容:## Gitaly gitaly['configuration'] = { # ... # # Make Gitaly accept connections on all network interfaces listen_addr: '0.0.0.0:8075', auth: { ## Set up the Gitaly token as a form of authentication because you are accessing Gitaly over the network ## https://docs.gitlab.com/ee/administration/gitaly/configure_gitaly.html#about-the-gitaly-token token: 'abc123secret', }, } gitlab_rails['gitaly_token'] = 'abc123secret' # Password to Authenticate Redis gitlab_rails['redis_password'] = 'redis-password-goes-here' -
运行
reconfigure:sudo gitlab-ctl reconfigure -
重启
PostgreSQL服务器:sudo gitlab-ctl restart postgresql
设置 Sidekiq 实例
查找您的参考架构并按照 Sidekiq 实例设置说明进行操作。
配置具有共享存储的多个 Sidekiq 节点
如果您运行多个使用共享文件存储(例如 NFS)的 Sidekiq 节点,则必须指定 UID 和 GID 以确保它们在服务器之间匹配。指定 UID 和 GID 可以防止文件系统出现权限问题。此建议与 Geo 设置的建议类似。
要设置多个 Sidekiq 节点:
-
编辑
/etc/gitlab/gitlab.rb:user['uid'] = 9000 user['gid'] = 9000 web_server['uid'] = 9001 web_server['gid'] = 9001 registry['uid'] = 9002 registry['gid'] = 9002 -
重新配置 GitLab:
sudo gitlab-ctl reconfigure
使用外部 Sidekiq 时配置容器镜像库
如果您正在使用容器镜像库,并且它运行在与 Sidekiq 不同的节点上,请按照以下步骤操作。
-
编辑
/etc/gitlab/gitlab.rb,并配置镜像库 URL:gitlab_rails['registry_api_url'] = "https://registry.example.com" -
重新配置 GitLab:
sudo gitlab-ctl reconfigure -
在托管容器镜像库的实例上,将
registry.key文件复制到 Sidekiq 节点。
配置 Sidekiq 指标服务器
如果您想收集 Sidekiq 指标,请启用 Sidekiq 指标服务器。要使指标在 localhost:8082/metrics 上可用:
要配置指标服务器:
-
编辑
/etc/gitlab/gitlab.rb:sidekiq['metrics_enabled'] = true sidekiq['listen_address'] = "localhost" sidekiq['listen_port'] = 8082 # Optionally log all the metrics server logs to log/sidekiq_exporter.log sidekiq['exporter_log_enabled'] = true -
重新配置 GitLab:
sudo gitlab-ctl reconfigure
启用 HTTPS
要通过 HTTPS 而不是 HTTP 提供指标,请在导出器设置中启用 TLS:
-
编辑
/etc/gitlab/gitlab.rb以添加(或查找并取消注释)以下行:sidekiq['exporter_tls_enabled'] = true sidekiq['exporter_tls_cert_path'] = "/path/to/certificate.pem" sidekiq['exporter_tls_key_path'] = "/path/to/private-key.pem" -
保存文件并重新配置 GitLab 以使更改生效。
启用 TLS 后,将使用与前面所述相同的 port 和 address。指标服务器不能同时提供 HTTP 和 HTTPS 服务。
配置健康检查
如果您使用健康检查探针来观察 Sidekiq,请启用 Sidekiq 健康检查服务器。要使健康检查在 localhost:8092 上可用:
-
编辑
/etc/gitlab/gitlab.rb:sidekiq['health_checks_enabled'] = true sidekiq['health_checks_listen_address'] = "localhost" sidekiq['health_checks_listen_port'] = 8092 -
重新配置 GitLab:
sudo gitlab-ctl reconfigure
有关健康检查的更多信息,请参阅 Sidekiq 健康检查页面。
配置 LDAP 以及用户或组同步
如果您使用 LDAP 进行用户和组管理,则必须将 LDAP 配置以及 LDAP 同步工作器添加到您的 Sidekiq 节点。如果 LDAP 配置和 LDAP 同步工作器未应用于您的 Sidekiq 节点,则用户和组将不会自动同步。
有关为 GitLab 配置 LDAP 的更多信息,请参阅:
要为 Sidekiq 启用带有同步工作器的 LDAP:
-
编辑
/etc/gitlab/gitlab.rb:gitlab_rails['ldap_enabled'] = true gitlab_rails['prevent_ldap_sign_in'] = false gitlab_rails['ldap_servers'] = { 'main' => { 'label' => 'LDAP', 'host' => 'ldap.mydomain.com', 'port' => 389, 'uid' => 'sAMAccountName', 'encryption' => 'simple_tls', 'verify_certificates' => true, 'bind_dn' => '_the_full_dn_of_the_user_you_will_bind_with', 'password' => '_the_password_of_the_bind_user', 'tls_options' => { 'ca_file' => '', 'ssl_version' => '', 'ciphers' => '', 'cert' => '', 'key' => '' }, 'timeout' => 10, 'active_directory' => true, 'allow_username_or_email_login' => false, 'block_auto_created_users' => false, 'base' => 'dc=example,dc=com', 'user_filter' => '', 'attributes' => { 'username' => ['uid', 'userid', 'sAMAccountName'], 'email' => ['mail', 'email', 'userPrincipalName'], 'name' => 'cn', 'first_name' => 'givenName', 'last_name' => 'sn' }, 'lowercase_usernames' => false, # Enterprise Edition only # https://docs.gitlab.com/ee/administration/auth/ldap/ldap_synchronization.html 'group_base' => '', 'admin_group' => '', 'external_groups' => [], 'sync_ssh_keys' => false } } gitlab_rails['ldap_sync_worker_cron'] = "0 */12 * * *" -
重新配置 GitLab:
sudo gitlab-ctl reconfigure
为 SAML 组同步配置 SAML 组
如果您使用 SAML 组同步,则必须在所有 Sidekiq 节点上配置 SAML 组。
相关主题
故障排除
请参阅我们的 管理员 Sidekiq 故障排除指南。