Configuring Sidekiq

原文:https://docs.gitlab.com/ee/administration/high_availability/sidekiq.html

Configuring Sidekiq

本节讨论如何配置外部 Sidekiq 实例.

Sidekiq 需要连接到 Redis,PostgreSQL 和 Gitaly 实例. 要配置 Sidekiq 节点:

  1. SSH 到 Sidekiq 服务器.

  2. 从 GitLab 下载页面使用步骤 1 和 2 下载/安装所需的 Omnibus GitLab 软件包. 不要完成下载页面上的任何其他步骤.

  3. 使用编辑器打开/etc/gitlab/gitlab.rb .

  4. 生成 Sidekiq 配置:

    1. sidekiq['listen_address'] = "10.10.1.48"
    2. ## Optional: Enable extra Sidekiq processes
    3. sidekiq_cluster['enable'] = true
    4. sidekiq_cluster['enable'] = true
    5. "elastic_indexer"
    6. ]
  5. 设置 Sidekiq 与 Redis 的连接:

    1. ## Must be the same in every sentinel node
    2. redis['master_name'] = 'gitlab-redis'
    3. ## The same password for Redis authentication you set up for the master node.
    4. redis['master_password'] = 'YOUR_PASSOWORD'
    5. ## A list of sentinels with `host` and `port`
    6. gitlab_rails['redis_sentinels'] = [
    7. {'host' => '10.10.1.34', 'port' => 26379},
    8. {'host' => '10.10.1.35', 'port' => 26379},
    9. {'host' => '10.10.1.36', 'port' => 26379},
    10. ]
  6. 设置 Sidekiq 与 Gitaly 的连接:

    1. git_data_dirs({
    2. 'default' => { 'gitaly_address' => 'tcp://gitaly:8075' },
    3. })
    4. gitlab_rails['gitaly_token'] = 'YOUR_TOKEN'
  7. 设置 Sidekiq 与 PostgreSQL 的连接:

    1. gitlab_rails['db_host'] = '10.10.1.30'
    2. gitlab_rails['db_password'] = 'YOUR_PASSOWORD'
    3. gitlab_rails['db_port'] = '5432'
    4. gitlab_rails['db_adapter'] = 'postgresql'
    5. gitlab_rails['db_encoding'] = 'unicode'
    6. gitlab_rails['auto_migrate'] = false

    请记住将 Sidekiq 节点添加到 PostgreSQL 的受信任地址中:

    1. postgresql['trust_auth_cidr_addresses'] = %w(127.0.0.1/32 10.10.1.30/32 10.10.1.31/32 10.10.1.32/32 10.10.1.33/32 10.10.1.38/32)
  8. 禁用其他服务:

    1. nginx['enable'] = false
    2. grafana['enable'] = false
    3. prometheus['enable'] = false
    4. gitlab_rails['auto_migrate'] = false
    5. alertmanager['enable'] = false
    6. gitaly['enable'] = false
    7. gitlab_monitor['enable'] = false
    8. gitlab_workhorse['enable'] = false
    9. nginx['enable'] = false
    10. postgres_exporter['enable'] = false
    11. postgresql['enable'] = false
    12. redis['enable'] = false
    13. redis_exporter['enable'] = false
    14. puma['enable'] = false
    15. gitlab_exporter['enable'] = false
  9. Run gitlab-ctl reconfigure.

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

Example configuration

这是结尾的/etc/gitlab/gitlab.rb样子:

  1. ########################################
  2. ##### Services Disabled ###
  3. ########################################
  4. nginx['enable'] = false
  5. grafana['enable'] = false
  6. prometheus['enable'] = false
  7. gitlab_rails['auto_migrate'] = false
  8. alertmanager['enable'] = false
  9. gitaly['enable'] = false
  10. gitlab_monitor['enable'] = false
  11. gitlab_workhorse['enable'] = false
  12. nginx['enable'] = false
  13. postgres_exporter['enable'] = false
  14. postgresql['enable'] = false
  15. redis['enable'] = false
  16. redis_exporter['enable'] = false
  17. puma['enable'] = false
  18. gitlab_exporter['enable'] = false
  19. ########################################
  20. #### Redis ###
  21. ########################################
  22. ## Must be the same in every sentinel node
  23. redis['master_name'] = 'gitlab-redis'
  24. ## The same password for Redis authentication you set up for the master node.
  25. redis['master_password'] = 'YOUR_PASSOWORD'
  26. ## A list of sentinels with `host` and `port`
  27. gitlab_rails['redis_sentinels'] = [
  28. {'host' => '10.10.1.34', 'port' => 26379},
  29. {'host' => '10.10.1.35', 'port' => 26379},
  30. {'host' => '10.10.1.36', 'port' => 26379},
  31. ]
  32. #######################################
  33. ### Gitaly ###
  34. #######################################
  35. git_data_dirs({
  36. 'default' => { 'gitaly_address' => 'tcp://gitaly:8075' },
  37. })
  38. gitlab_rails['gitaly_token'] = 'YOUR_TOKEN'
  39. #######################################
  40. ### Postgres ###
  41. #######################################
  42. gitlab_rails['db_host'] = '10.10.1.30'
  43. gitlab_rails['db_password'] = 'YOUR_PASSOWORD'
  44. gitlab_rails['db_port'] = '5432'
  45. gitlab_rails['db_adapter'] = 'postgresql'
  46. gitlab_rails['db_encoding'] = 'unicode'
  47. gitlab_rails['auto_migrate'] = false
  48. #######################################
  49. ### Sidekiq configuration ###
  50. #######################################
  51. sidekiq['listen_address'] = "10.10.1.48"
  52. #######################################
  53. ### Monitoring configuration ###
  54. #######################################
  55. consul['enable'] = true
  56. consul['monitoring_service_discovery'] = true
  57. consul['configuration'] = {
  58. bind_addr: '10.10.1.48',
  59. retry_join: %w(10.10.1.34 10.10.1.35 10.10.1.36)
  60. }
  61. # Set the network addresses that the exporters will listen on
  62. node_exporter['listen_address'] = '10.10.1.48:9100'
  63. # Rails Status for prometheus
  64. gitlab_rails['monitoring_whitelist'] = ['10.10.1.42', '127.0.0.1']

Further reading

相关的 Sidekiq 配置:

  1. Extra Sidekiq processes
  2. Using the GitLab-Sidekiq chart