2020-10-24 23:57:45 +05:30
---
2022-07-23 23:45:48 +05:30
stage: Systems
2021-02-22 17:27:13 +05:30
group: Distribution
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2020-10-24 23:57:45 +05:30
---
2022-04-04 11:22:00 +05:30
# Configure an external Sidekiq instance **(FREE SELF)**
2020-10-24 23:57:45 +05:30
2022-08-13 15:12:31 +05:30
You can configure an external Sidekiq instance by using the Sidekiq that's bundled in the GitLab package. Sidekiq requires connection to the Redis,
2022-04-04 11:22:00 +05:30
PostgreSQL, and Gitaly instances.
2020-10-24 23:57:45 +05:30
2022-08-13 15:12:31 +05:30
## Configure TCP access for PostgreSQL, Gitaly, and Redis
2022-04-04 11:22:00 +05:30
2022-08-13 15:12:31 +05:30
By default, GitLab uses UNIX sockets and is not set up to communicate via TCP. To change this:
1. Edit the `/etc/gitlab/gitlab.rb` file on your GitLab instance, and add the following:
```ruby
## PostgreSQL
# Replace POSTGRESQL_PASSWORD_HASH with a generated md5 value
postgresql['sql_user_password'] = 'POSTGRESQL_PASSWORD_HASH'
postgresql['listen_address'] = '0.0.0.0'
postgresql['port'] = 5432
# Add the Sidekiq nodes to PostgreSQL's trusted addresses.
# In the following example, 10.10.1.30/32 is the private IP
# of the Sidekiq server.
postgresql['md5_auth_cidr_addresses'] = %w(127.0.0.1/32 10.10.1.30/32)
postgresql['trust_auth_cidr_addresses'] = %w(127.0.0.1/32 10.10.1.30/32)
## Gitaly
# Make Gitaly accept connections on all network interfaces
gitaly['listen_addr'] = "0.0.0.0:8075"
## Set up the Gitaly token as a form of authentication since you are accessing Gitaly over the network
## https://docs.gitlab.com/ee/administration/gitaly/configure_gitaly.html#about-the-gitaly-token
gitaly['auth_token'] = 'abc123secret'
praefect['auth_token'] = 'abc123secret'
gitlab_rails['gitaly_token'] = 'abc123secret'
## Redis configuration
redis['bind'] = '0.0.0.0'
redis['port'] = 6379
# Password to Authenticate Redis
redis['password'] = 'redis-password-goes-here'
gitlab_rails['redis_password'] = 'redis-password-goes-here'
gitlab_rails['auto_migrate'] = false
```
1. Run `reconfigure` :
```shell
sudo gitlab-ctl reconfigure
```
1. Restart the `PostgreSQL` server:
```shell
sudo gitlab-ctl restart postgresql
```
1. After the restart, set `auto_migrate` to `true` or comment to use the default settings:
```ruby
gitlab_rails['auto_migrate'] = true
```
1. Run `reconfigure` again:
```shell
sudo gitlab-ctl reconfigure
```
## Set up Sidekiq instance
2020-10-24 23:57:45 +05:30
1. SSH into the Sidekiq server.
2022-08-13 15:12:31 +05:30
1. Confirm that you can access the PostgreSQL, Gitaly, and Redis ports:
```shell
telnet < GitLab host > 5432 # PostgreSQL
telnet < GitLab host > 8075 # Gitaly
telnet < GitLab host > 6379 # Redis
```
2022-04-04 11:22:00 +05:30
1. [Download and install ](https://about.gitlab.com/install/ ) the Omnibus GitLab package
using steps 1 and 2. **Do not complete any other steps.**
2022-08-13 15:12:31 +05:30
1. Copy the `/etc/gitlab/gitlab.rb` file from the GitLab instance and add the following settings. Make sure
to replace them with your values:
2020-10-24 23:57:45 +05:30
2022-07-16 23:28:13 +05:30
<!--
Updates to example must be made at:
- https://gitlab.com/gitlab-org/gitlab/blob/master/doc/administration/sidekiq.md
- all reference architecture pages
-->
2022-04-04 11:22:00 +05:30
2022-07-16 23:28:13 +05:30
```ruby
2022-04-04 11:22:00 +05:30
########################################
##### Services Disabled ###
########################################
#
# When running GitLab on just one server, you have a single `gitlab.rb`
# to enable all services you want to run.
# When running GitLab on N servers, you have N `gitlab.rb` files.
# Enable only the services you want to run on each
# specific server, while disabling all others.
#
gitaly['enable'] = false
postgresql['enable'] = false
redis['enable'] = false
2022-07-16 23:28:13 +05:30
nginx['enable'] = false
2022-04-04 11:22:00 +05:30
puma['enable'] = false
2022-07-16 23:28:13 +05:30
gitlab_workhorse['enable'] = false
prometheus['enable'] = false
alertmanager['enable'] = false
grafana['enable'] = false
2022-04-04 11:22:00 +05:30
gitlab_exporter['enable'] = false
2022-07-16 23:28:13 +05:30
gitlab_kas['enable'] = false
2022-04-04 11:22:00 +05:30
2022-07-16 23:28:13 +05:30
##
## To maintain uniformity of links across nodes, the
## `external_url` on the Sidekiq server should point to the external URL that users
## use to access GitLab. This can be either:
##
## - The `external_url` set on your application server.
## - The URL of a external load balancer, which routes traffic to the GitLab application server.
##
external_url 'https://gitlab.example.com'
2022-04-04 11:22:00 +05:30
2022-08-13 15:12:31 +05:30
# Configure the gitlab-shell API callback URL. Without this, `git push` will
# fail. This can be your 'front door' GitLab URL or an internal load
# balancer.
gitlab_rails['internal_api_url'] = 'GITLAB_URL'
gitlab_shell['secret_token'] = 'SHELL_TOKEN'
2022-04-04 11:22:00 +05:30
########################################
#### Redis ###
########################################
2020-10-24 23:57:45 +05:30
2022-08-13 15:12:31 +05:30
## Must be the same in every sentinel node.
redis['master_name'] = 'gitlab-redis' # Required if you have setup redis cluster
2020-10-24 23:57:45 +05:30
## The same password for Redis authentication you set up for the master node.
2022-04-04 11:22:00 +05:30
redis['master_password'] = '< redis_master_password > '
2020-10-24 23:57:45 +05:30
2022-08-13 15:12:31 +05:30
### If redis is running on the main Gitlab instance and you have opened the TCP port as above add the following
gitlab_rails['redis_host'] = '< gitlab_host > '
gitlab_rails['redis_port'] = 6379
2022-04-04 11:22:00 +05:30
#######################################
### Gitaly ###
#######################################
2020-10-24 23:57:45 +05:30
2022-04-04 11:22:00 +05:30
## Replace < gitaly_token > with the one you set up, see
## https://docs.gitlab.com/ee/administration/gitaly/configure_gitaly.html#about-the-gitaly-token
2020-10-24 23:57:45 +05:30
git_data_dirs({
2022-07-16 23:28:13 +05:30
"default" => {
2022-08-13 15:12:31 +05:30
"gitaly_address" => "tcp://< gitlab_host > :8075",
"gitaly_token" => "< gitaly_token > "
2022-07-16 23:28:13 +05:30
}
2020-10-24 23:57:45 +05:30
})
2022-04-04 11:22:00 +05:30
#######################################
### Postgres ###
#######################################
2020-10-24 23:57:45 +05:30
2022-04-04 11:22:00 +05:30
# Replace < database_host > and < database_password >
gitlab_rails['db_host'] = '< database_host > '
2020-10-24 23:57:45 +05:30
gitlab_rails['db_port'] = '5432'
2022-07-16 23:28:13 +05:30
gitlab_rails['db_password'] = '< database_password > '
## Prevent database migrations from running on upgrade automatically
gitlab_rails['auto_migrate'] = false
#######################################
### Sidekiq configuration ###
#######################################
sidekiq['enable'] = true
sidekiq['listen_address'] = "0.0.0.0"
## Set number of Sidekiq queue processes to the same number as available CPUs
sidekiq['queue_groups'] = ['*'] * 4
## Set number of Sidekiq threads per queue process to the recommend number of 10
sidekiq['max_concurrency'] = 10
2020-10-24 23:57:45 +05:30
```
2022-08-13 15:12:31 +05:30
1. Copy the `/etc/gitlab/gitlab-secrets.json` file from the GitLab instance and replace the file in the Sidekiq instance.
2022-04-04 11:22:00 +05:30
1. Reconfigure GitLab:
2020-10-24 23:57:45 +05:30
2022-04-04 11:22:00 +05:30
```shell
sudo gitlab-ctl reconfigure
2020-10-24 23:57:45 +05:30
```
2022-08-13 15:12:31 +05:30
1. Restart the Sidekiq instance after completing the process and finishing the database migrations.
2022-04-04 11:22:00 +05:30
## Configure multiple Sidekiq nodes with shared storage
If you run multiple Sidekiq nodes with a shared file storage, such as NFS, you must
specify the UIDs and GIDs to ensure they match between servers. Specifying the UIDs
and GIDs prevents permissions issues in the file system. This advice is similar to the
[advice for Geo setups ](geo/replication/multiple_servers.md#step-4-configure-the-frontend-application-nodes-on-the-geo-secondary-site ).
To set up multiple Sidekiq nodes:
1. Edit `/etc/gitlab/gitlab.rb` :
2021-12-11 22:18:48 +05:30
```ruby
user['uid'] = 9000
user['gid'] = 9000
web_server['uid'] = 9001
web_server['gid'] = 9001
registry['uid'] = 9002
registry['gid'] = 9002
```
2022-04-04 11:22:00 +05:30
1. Reconfigure GitLab:
2020-10-24 23:57:45 +05:30
2022-04-04 11:22:00 +05:30
```shell
sudo gitlab-ctl reconfigure
2020-10-24 23:57:45 +05:30
```
2022-04-04 11:22:00 +05:30
## Configure the Container Registry when using an external Sidekiq
If you're using the Container Registry and it's running on a different
node than Sidekiq, follow the steps below.
1. Edit `/etc/gitlab/gitlab.rb` , and configure the registry URL:
2021-10-27 15:23:28 +05:30
```ruby
registry_external_url 'https://registry.example.com'
gitlab_rails['registry_api_url'] = "https://registry.example.com"
```
2022-04-04 11:22:00 +05:30
1. Reconfigure GitLab:
2021-11-18 22:05:49 +05:30
2022-04-04 11:22:00 +05:30
```shell
sudo gitlab-ctl reconfigure
2021-11-18 22:05:49 +05:30
```
2022-04-04 11:22:00 +05:30
1. In the instance where Container Registry is hosted, copy the `registry.key`
file to the Sidekiq node.
## Configure the Sidekiq metrics server
If you want to collect Sidekiq metrics, enable the Sidekiq metrics server.
To make metrics available from `localhost:8082/metrics` :
To configure the metrics server:
1. Edit `/etc/gitlab/gitlab.rb` :
2022-03-02 08:16:31 +05:30
```ruby
sidekiq['metrics_enabled'] = true
sidekiq['listen_address'] = "localhost"
sidekiq['listen_port'] = "8082"
2022-04-04 11:22:00 +05:30
2022-03-02 08:16:31 +05:30
# Optionally log all the metrics server logs to log/sidekiq_exporter.log
sidekiq['exporter_log_enabled'] = true
```
2022-04-04 11:22:00 +05:30
1. Reconfigure GitLab:
```shell
sudo gitlab-ctl reconfigure
```
2022-08-13 15:12:31 +05:30
### Enable HTTPS
> [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/364771) in GitLab 15.2.
To serve metrics via HTTPS instead of HTTP, enable TLS in the exporter settings:
1. Edit `/etc/gitlab/gitlab.rb` to add (or find and uncomment) the following lines:
```ruby
sidekiq['exporter_tls_enabled'] = true
sidekiq['exporter_tls_cert_path'] = "/path/to/certificate.pem"
sidekiq['exporter_tls_key_path'] = "/path/to/private-key.pem"
```
1. Save the file and [reconfigure GitLab ](restart_gitlab.md#omnibus-gitlab-reconfigure )
for the changes to take effect.
When TLS is enabled, the same `port` and `address` are used as described above.
The metrics server cannot serve both HTTP and HTTPS at the same time.
2022-04-04 11:22:00 +05:30
## Configure health checks
2022-07-16 23:28:13 +05:30
If you use health check probes to observe Sidekiq, enable the Sidekiq health check server.
To make health checks available from `localhost:8092` :
2022-04-04 11:22:00 +05:30
1. Edit `/etc/gitlab/gitlab.rb` :
2022-03-02 08:16:31 +05:30
2022-08-13 15:12:31 +05:30
```ruby
2022-04-04 11:22:00 +05:30
sidekiq['health_checks_enabled'] = true
sidekiq['health_checks_listen_address'] = "localhost"
sidekiq['health_checks_listen_port'] = "8092"
2022-03-02 08:16:31 +05:30
```
2022-04-04 11:22:00 +05:30
1. Reconfigure GitLab:
```shell
sudo gitlab-ctl reconfigure
```
2022-07-16 23:28:13 +05:30
For more information about health checks, see the [Sidekiq health check page ](sidekiq_health_check.md ).
2022-05-07 20:08:51 +05:30
## Configure LDAP and user or group synchronization
If you use LDAP for user and group management, you must add the LDAP configuration to your Sidekiq node as well as the LDAP
synchronization worker. If the LDAP configuration and LDAP synchronization worker are not applied to your Sidekiq node,
users and groups are not automatically synchronized.
For more information about configuring LDAP for GitLab, see:
- [GitLab LDAP configuration documentation ](auth/ldap/index.md#configure-ldap )
- [LDAP synchronization documentation ](auth/ldap/ldap_synchronization.md#adjust-ldap-user-sync-schedule )
To enable LDAP with the synchronization worker for Sidekiq:
1. Edit `/etc/gitlab/gitlab.rb` :
```ruby
gitlab_rails['ldap_enabled'] = true
gitlab_rails['prevent_ldap_sign_in'] = false
gitlab_rails['ldap_servers'] = {
'main' => {
'label' => 'LDAP',
2022-07-23 23:45:48 +05:30
'host' => 'ldap.mydomain.com',
2022-05-07 20:08:51 +05:30
'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
}
2022-07-23 23:45:48 +05:30
}
2022-05-07 20:08:51 +05:30
gitlab_rails['ldap_sync_worker_cron'] = "0 */12 * * * "
```
1. Reconfigure GitLab:
```shell
sudo gitlab-ctl reconfigure
```
2022-04-04 11:22:00 +05:30
## Related topics
- [Extra Sidekiq processes ](operations/extra_sidekiq_processes.md )
- [Extra Sidekiq routing ](operations/extra_sidekiq_routing.md )
- [Using the GitLab-Sidekiq chart ](https://docs.gitlab.com/charts/charts/gitlab/sidekiq/ )
- [Sidekiq health checks ](sidekiq_health_check.md )