437.md 5.6 KB
Newer Older
Lab机器人's avatar
readme  
Lab机器人 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188
# Configuring Sidekiq

> 原文:[https://docs.gitlab.com/ee/administration/high_availability/sidekiq.html](https://docs.gitlab.com/ee/administration/high_availability/sidekiq.html)

*   [Example configuration](#example-configuration)
*   [Further reading](#further-reading)

# Configuring Sidekiq[](#configuring-sidekiq "Permalink")

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

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

1.  SSH 到 Sidekiq 服务器.

2.  从 GitLab 下载页面使用步骤 1 和 2 [下载/安装](https://about.gitlab.com/install/)所需的 Omnibus GitLab 软件包. **不要完成下载页面上的任何其他步骤.**

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

4.  生成 Sidekiq 配置:

    ```
    sidekiq['listen_address'] = "10.10.1.48"

    ## Optional: Enable extra Sidekiq processes
    sidekiq_cluster['enable'] = true
    sidekiq_cluster['enable'] = true
      "elastic_indexer"
    ] 
    ```

5.  设置 Sidekiq 与 Redis 的连接:

    ```
    ## Must be the same in every sentinel node
    redis['master_name'] = 'gitlab-redis'

    ## The same password for Redis authentication you set up for the master node.
    redis['master_password'] = 'YOUR_PASSOWORD'

    ## A list of sentinels with `host` and `port`
    gitlab_rails['redis_sentinels'] = [
        {'host' => '10.10.1.34', 'port' => 26379},
        {'host' => '10.10.1.35', 'port' => 26379},
        {'host' => '10.10.1.36', 'port' => 26379},
      ] 
    ```

6.  设置 Sidekiq 与 Gitaly 的连接:

    ```
    git_data_dirs({
      'default' => { 'gitaly_address' => 'tcp://gitaly:8075' },
    })
    gitlab_rails['gitaly_token'] = 'YOUR_TOKEN' 
    ```

7.  设置 Sidekiq 与 PostgreSQL 的连接:

    ```
    gitlab_rails['db_host'] = '10.10.1.30'
    gitlab_rails['db_password'] = 'YOUR_PASSOWORD'
    gitlab_rails['db_port'] = '5432'
    gitlab_rails['db_adapter'] = 'postgresql'
    gitlab_rails['db_encoding'] = 'unicode'
    gitlab_rails['auto_migrate'] = false 
    ```

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

    ```
    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.  禁用其他服务:

    ```
    nginx['enable'] = false
    grafana['enable'] = false
    prometheus['enable'] = false
    gitlab_rails['auto_migrate'] = false
    alertmanager['enable'] = false
    gitaly['enable'] = false
    gitlab_monitor['enable'] = false
    gitlab_workhorse['enable'] = false
    nginx['enable'] = false
    postgres_exporter['enable'] = false
    postgresql['enable'] = false
    redis['enable'] = false
    redis_exporter['enable'] = false
    puma['enable'] = false
    gitlab_exporter['enable'] = false 
    ```

9.  Run `gitlab-ctl reconfigure`.

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

## Example configuration[](#example-configuration "Permalink")

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

```
########################################
#####        Services Disabled       ###
########################################

nginx['enable'] = false
grafana['enable'] = false
prometheus['enable'] = false
gitlab_rails['auto_migrate'] = false
alertmanager['enable'] = false
gitaly['enable'] = false
gitlab_monitor['enable'] = false
gitlab_workhorse['enable'] = false
nginx['enable'] = false
postgres_exporter['enable'] = false
postgresql['enable'] = false
redis['enable'] = false
redis_exporter['enable'] = false
puma['enable'] = false
gitlab_exporter['enable'] = false

########################################
####              Redis              ###
########################################

## Must be the same in every sentinel node
redis['master_name'] = 'gitlab-redis'

## The same password for Redis authentication you set up for the master node.
redis['master_password'] = 'YOUR_PASSOWORD'

## A list of sentinels with `host` and `port`
gitlab_rails['redis_sentinels'] = [
    {'host' => '10.10.1.34', 'port' => 26379},
    {'host' => '10.10.1.35', 'port' => 26379},
    {'host' => '10.10.1.36', 'port' => 26379},
  ]

#######################################
###              Gitaly             ###
#######################################

git_data_dirs({
  'default' => { 'gitaly_address' => 'tcp://gitaly:8075' },
})
gitlab_rails['gitaly_token'] = 'YOUR_TOKEN'

#######################################
###            Postgres             ###
#######################################
gitlab_rails['db_host'] = '10.10.1.30'
gitlab_rails['db_password'] = 'YOUR_PASSOWORD'
gitlab_rails['db_port'] = '5432'
gitlab_rails['db_adapter'] = 'postgresql'
gitlab_rails['db_encoding'] = 'unicode'
gitlab_rails['auto_migrate'] = false

#######################################
###      Sidekiq configuration      ###
#######################################
sidekiq['listen_address'] = "10.10.1.48"

#######################################
###     Monitoring configuration    ###
#######################################
consul['enable'] = true
consul['monitoring_service_discovery'] =  true

consul['configuration'] = {
  bind_addr: '10.10.1.48',
  retry_join: %w(10.10.1.34 10.10.1.35 10.10.1.36)
}

# Set the network addresses that the exporters will listen on
node_exporter['listen_address'] = '10.10.1.48:9100'

# Rails Status for prometheus
gitlab_rails['monitoring_whitelist'] = ['10.10.1.42', '127.0.0.1'] 
```

## Further reading[](#further-reading "Permalink")

相关的 Sidekiq 配置:

1.  [Extra Sidekiq processes](../operations/extra_sidekiq_processes.html)
2.  [Using the GitLab-Sidekiq chart](https://docs.gitlab.com/charts/charts/gitlab/sidekiq/)