Skip to content
Snippets Groups Projects
Commit c06a7b66 authored by Gabriel Mazetto's avatar Gabriel Mazetto
Browse files

Improve GitLab Geo replicated database support

parent 86527311
No related branches found
No related tags found
1 merge request!270Improve GitLab Geo replicated database support
Pipeline #
Loading
Loading
@@ -53,3 +53,4 @@
/gitaly/
/gitlab-workhorse/config.toml
/gitlab-workhorse/.cache
postgresql-primary
Loading
Loading
@@ -158,18 +158,28 @@ postgresql/data:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql/data
support/bootstrap-rails
 
postgresql-replication/cluster:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql-replica/data
postgresql-replication-primary: postgresql-replication/access postgresql-replication/role postgresql-replication/config
postgresql-replication-secondary: postgresql-replication/data postgresql-replication/access postgresql-replication/backup postgresql-replication/config
postgresql-replication/data:
${postgres_bin_dir}/initdb --locale=C -E utf-8 postgresql/data
postgresql-replication/access:
cat support/pg_hba.conf.add >> postgresql/data/pg_hba.conf
 
postgresql-replication/role:
${postgres_bin_dir}/psql -h ${postgres_dir} -d postgres -c "CREATE ROLE ${postgres_replication_user} WITH REPLICATION LOGIN;"
 
postgresql-replication/backup:
psql -h ${postgres_dir} -d postgres -c "select pg_start_backup('base backup for streaming rep')"
rsync -cva --inplace --exclude="*pg_xlog*" postgresql/data postgresql-replica
psql -h ${postgres_dir} -d postgres -c "select pg_stop_backup(), current_timestamp"
./support/recovery.conf ${postgres_dir} > postgresql-replica/data/recovery.conf
$(eval postgres_primary_dir := $(realpath postgresql-primary))
psql -h ${postgres_primary_dir} -d postgres -c "select pg_start_backup('base backup for streaming rep')"
rsync -cva --inplace --exclude="*pg_xlog*" --exclude="*.pid" ${postgres_primary_dir}/data postgresql
psql -h ${postgres_primary_dir} -d postgres -c "select pg_stop_backup(), current_timestamp"
./support/recovery.conf ${postgres_primary_dir} > postgresql/data/recovery.conf
postgresql-replication/config:
./support/postgres-replication ${postgres_dir}
 
.PHONY: foreman
foreman:
Loading
Loading
Loading
Loading
@@ -3,24 +3,41 @@
For Gitlab Geo, you will need a master/slave database replication defined.
There are a few extra steps to follow:
 
You must start with a clean postgres setup, (jump to next if you are installing
everything from scratch):
In your primary instance (`gdk-ee`) you need to prepare the database for
replication:
 
```
cd gdk-ee
# terminal window 1:
foreman start postgresql
# terminal window 2:
make postgresql-replication-primary
# go back to terminal window 1 stop foreman by hitting "CTRL-C" and execute it again with:
foreman start postgresql
```
You must start with a clean postgres setup on the secondary node:
```
# terminal window 2:
cd ../gdk-geo
rm -rf postgresql
make postgresql
```
 
Initialize a slave database and setup replication:
You need to setup a symbolic link to the `postgresql` folder from the
primary instance (`gdk-ee`):
 
```
# terminal window 1:
make postgresql-replication/cluster
foreman start postgresql
# you must be in `gdk-geo` folder
ln -s ../gdk-ee/postgresql postgresql-primary
```
 
# terminal window 2:
make postgresql-replication/role
make postgresql-replication/backup
Initialize a slave database and setup replication:
 
```
# terminal window 2:
make postgresql-replication-secondary
# go back to terminal window 1 and stop foreman by hitting "CTRL-C"
```
Loading
Loading
@@ -27,7 +27,7 @@ Please read [the prerequisites for all platforms](#prerequisites-for-all-platfor
```
brew tap homebrew/dupes
brew tap homebrew/versions
brew install git redis postgresql libiconv icu4c pkg-config cmake nodejs go openssl node npm
brew install git redis postgresql libiconv icu4c pkg-config cmake nodejs go openssl node npm coreutils
bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
npm install phantomjs-prebuilt@2.1.12 -g
```
Loading
Loading
@@ -37,7 +37,7 @@ npm install phantomjs-prebuilt@2.1.12 -g
We are using PostgreSQL-9.5 in the following example. If you want to use another version, please adjust paths accordingly.
 
```
sudo port install git redis libiconv postgresql95-server icu pkgconfig cmake nodejs4 go openssl npm2
sudo port install git redis libiconv postgresql95-server icu pkgconfig cmake nodejs4 go openssl npm2 coreutils
bundle config build.eventmachine --with-cppflags=-I/opt/local/include/openssl
sudo npm install phantomjs-prebuilt@2.1.12 -g
echo 'export PATH=/opt/local/lib/postgresql95/bin/:$PATH' >> ~/.profile
Loading
Loading
Loading
Loading
@@ -48,8 +48,6 @@ Alternatively, you can clone all components from their official source.
gdk install
```
 
If you are going to work on Gitlab Geo, you will need [PostgreSQL replication](./howto/postgresql_replication.md) setup before the "Post-installation" instructions.
## GitLab Enterprise Edition
 
The recommended way to do development on GitLab Enterprise Edition is
Loading
Loading
@@ -74,6 +72,24 @@ might still be running.
Instructions to generate a developer license can be found in the
onboarding document: https://about.gitlab.com/handbook/developer-onboarding/#gitlab-enterprise-edition-ee
 
## GitLab Geo
GitLab Geo requires two Enterprise Edition instances running most of the time.
You can re-use your previously boostraped `gdk-ee` as your primary node and
we suggest to bootstrap a `gdk-geo` that will act as your secondary node.
We need to configure different ports for the new instances so they can talk to
each other.
```
gdk init gdk-geo
cd gdk-geo
echo 3002 > port
echo 3807 > webpack_port
gdk install gitlab_repo=https://gitlab.com/gitlab-org/gitlab-ee.git
```
You will need [PostgreSQL replication](./howto/postgresql_replication.md) setup before the "Post-installation" instructions.
## Post-installation
 
Start GitLab and all required services:
Loading
Loading
#!/bin/bash
replication_include="include = 'replication.conf'"
postgres_dir=$(realpath $1)
if ! grep -Fxq "$replication_include" $postgres_dir/data/postgresql.conf; then
echo $replication_include >> $postgres_dir/data/postgresql.conf
fi
if [ ! -f "$postgres_dir/data/replication.conf" ]; then
cat <<EOF > $postgres_dir/data/replication.conf
wal_level = hot_standby
max_wal_senders = 10
wal_keep_segments = 10
hot_standby = on
EOF
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment