Skip to content

Commit da1e101

Browse files
committed
Merge pull request #208 from skarllot/master
Added a guide to run multiple instances
2 parents bc14092 + d22e576 commit da1e101

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

misc/multiple-instances/README.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
```
2+
Distribution : Independent
3+
GitLab version : 6.0 - 6.7
4+
Web Server : apache
5+
Init system : sysvinit
6+
Database : Independent
7+
Contributors : @skarllot
8+
```
9+
10+
## Overview
11+
12+
To run multiple instances into same computer, some changes are needed to GitLab
13+
function properly. Each instance will run completely independent, no resource
14+
sharing or redundancy will be supported.
15+
16+
Before you follow this guide you should know how install GitLab as single
17+
instance. This guide focus only on changes needed to another instances run
18+
properly, not into installation itself.
19+
20+
### Important Notes
21+
22+
These steps was tested into CentOS GNU/Linux, but should run into another
23+
flavours with (almost) no differences.
24+
25+
## 1. System Users
26+
27+
Each instance must run into its own user. There's no way to gitlab-shell known
28+
which instance you are calling.
29+
30+
Then, create a new user to a new GitLab instance.
31+
32+
## 2. GitLab Shell
33+
34+
The following changes are needed to `config.yml`
35+
36+
- **user**: the new user created from previous step.
37+
- **gitlab_url**: instance-unique http(s) address.
38+
- **repos_path**: instance-unique repository directory.
39+
- **auth_file**: must be changed to match SSH user directory from the created user.
40+
- **redis:namespace**: instance-unique Redis namespace.
41+
42+
Example:
43+
44+
```yaml
45+
# GitLab user. git by default
46+
user: user2
47+
48+
# Url to gitlab instance. Used for api calls. Should end with a slash.
49+
gitlab_url: "https://user2.example.com/"
50+
51+
http_settings:
52+
# user: someone
53+
# password: somepass
54+
# ca_file: /etc/ssl/cert.pem
55+
# ca_path: /etc/pki/tls/certs
56+
self_signed_cert: false
57+
58+
# Repositories path
59+
# Give the canonicalized absolute pathname,
60+
# REPOS_PATH MUST NOT CONTAIN ANY SYMLINK!!!
61+
# Check twice that none of the components is a symlink, including "/home".
62+
repos_path: "/home/user2/repositories"
63+
64+
# File used as authorized_keys for gitlab user
65+
auth_file: "/home/user2/.ssh/authorized_keys"
66+
67+
# Redis settings used for pushing commit notices to gitlab
68+
redis:
69+
bin: /usr/bin/redis-cli
70+
host: 127.0.0.1
71+
port: 6379
72+
# socket: /tmp/redis.socket # Only define this if you want to use sockets
73+
namespace: resque:gitlab:user2
74+
75+
(...)
76+
```
77+
78+
## 3. Database
79+
80+
Each GitLab instance should handle its own database schema. It's recommended
81+
that each instance have its own database user.
82+
83+
## 4. GitLab
84+
85+
You must do the following changes to `config/gitlab.yml`
86+
87+
- **gitlab:host**: instance-unique FQDN.
88+
- **gitlab:user**: the user created at first step.
89+
- **satellites:path**: the path where satellites of new user will be created.
90+
- **gitlab_shell:path**: the path where instance's GitLab Shell was installed.
91+
- **gitlab_shell:repos_path**: the path where instance's Git repositories will be stored.
92+
- **gitlab_shell:hooks_path**: the path where GitLab Shell store its hooks.
93+
94+
Next, change the following to `config/unicorn.rb`
95+
96+
- **working_directory**: the path where GitLab was installed.
97+
- **listen[socket]**: change to match instance's GitLab install.
98+
- **listen[TCP]**: instance-unique TCP port.
99+
- **pid**, **stderr_path** and **stdout_path**: change to match instance's GitLab install.
100+
101+
Next, you need to change `config/initializers/4_sidekiq.rb` to use the same
102+
Redis namespace as configured at second step.
103+
104+
Example:
105+
106+
```ruby
107+
# Custom Redis configuration
108+
config_file = Rails.root.join('config', 'resque.yml')
109+
110+
resque_url = if File.exists?(config_file)
111+
YAML.load_file(config_file)[Rails.env]
112+
else
113+
"redis://localhost:6379"
114+
end
115+
116+
Sidekiq.configure_server do |config|
117+
config.redis = {
118+
url: resque_url,
119+
namespace: 'resque:gitlab:user2'
120+
}
121+
end
122+
123+
Sidekiq.configure_client do |config|
124+
config.redis = {
125+
url: resque_url,
126+
namespace: 'resque:gitlab:user2'
127+
}
128+
end
129+
```
130+
131+
### Database
132+
133+
Next, you should ensure that `config/database.yml` is not sharing the same
134+
database from others instances. Then create the database with `gitlab:setup`.
135+
136+
### Init Script
137+
138+
Each instance must have its own init script (eg: `/etc/init.d/gitlab-user2`).
139+
140+
Next, modify the init script as follows
141+
142+
- **USER**: the name of the user created at first step.
143+
- **APP_PATH**: the path where GitLab was installed.
144+
- **ULOCK**: instance-unique path to Unicorn lock file.
145+
- **SLOCK**: instance-unique path to Sidekiq lock file.
146+
147+
### LogRotate
148+
149+
Each instance must have its own logrotate script (eg:
150+
`/etc/logrotate.d/gitlab-user2`).
151+
152+
Next you must modify the paths from logrotate script to match where the logs are
153+
written.
154+
155+
## 5. Web Server
156+
157+
### Apache
158+
159+
Each instance must have its own Apache configuration file (eg:
160+
`gitlab-user2.conf`).
161+
162+
The following changes must be made to configuration file
163+
164+
- **ServerName**: instance-unique FQDN.
165+
- **ProxyPassReverse** and **RewriteRule**: must change to the port where instance's Unicorn is listening.
166+
- **ErrorLog** and **CustomLog**: instance-unique path where the Apache logs will be written.
167+

0 commit comments

Comments
 (0)