Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'doc/update/upgrading_postgresql_using_slony.md')
-rw-r--r--doc/update/upgrading_postgresql_using_slony.md54
1 files changed, 27 insertions, 27 deletions
diff --git a/doc/update/upgrading_postgresql_using_slony.md b/doc/update/upgrading_postgresql_using_slony.md
index cf3a389b149..8189f0cba51 100644
--- a/doc/update/upgrading_postgresql_using_slony.md
+++ b/doc/update/upgrading_postgresql_using_slony.md
@@ -26,7 +26,7 @@ To do so we'll generate a dump of our current database. This dump will only
contain the structure, not any data. To generate this dump run the following
command on your active database server:
-```bash
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dump -h /var/opt/gitlab/postgresql -p 5432 -U gitlab-psql -s -f /tmp/structure.sql gitlabhq_production
```
@@ -39,14 +39,14 @@ Once the structure dump is generated we also need to generate a dump for the
can't be replicated easily by Slony. To generate this dump run the following
command on your active database server:
-```bash
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dump -h /var/opt/gitlab/postgresql/ -p 5432 -U gitlab-psql -a -t schema_migrations -f /tmp/migrations.sql gitlabhq_production
```
Next we'll need to move these files somewhere accessible by the new database
server. The easiest way is to simply download these files to your local system:
-```bash
+```shell
scp your-user@production-database-host:/tmp/*.sql /tmp
```
@@ -63,7 +63,7 @@ install Slony using said package manager.
When compiling Slony from source you *must* use the following commands to do so:
-```bash
+```shell
./configure --prefix=/path/to/installation/directory --with-perltools --with-pgconfigdir=/path/to/directory/containing/pg_config/bin
make
make install
@@ -71,7 +71,7 @@ make install
Omnibus users can use the following commands:
-```bash
+```shell
./configure --prefix=/opt/gitlab/embedded --with-perltools --with-pgconfigdir=/opt/gitlab/embedded/bin
make
make install
@@ -81,7 +81,7 @@ This assumes you have installed GitLab into `/opt/gitlab`.
To test if Slony is installed properly, run the following commands:
-```bash
+```shell
test -f /opt/gitlab/embedded/bin/slonik && echo 'Slony installed' || echo 'Slony not installed'
test -f /opt/gitlab/embedded/bin/slonik_init_cluster && echo 'Slony Perl tools are available' || echo 'Slony Perl tools are not available'
/opt/gitlab/embedded/bin/slonik -v
@@ -91,7 +91,7 @@ This assumes Slony was installed to `/opt/gitlab/embedded`. If Slony was
installed properly the output of these commands will be (the mentioned "slonik"
version may be different):
-```
+```plaintext
Slony installed
Slony Perl tools are available
slonik version 2.2.5
@@ -126,7 +126,7 @@ First we'll need to create some required directories and set the correct
permissions. To do so, run the following commands on both the old and new
database server:
-```bash
+```shell
sudo mkdir -p /var/log/gitlab/slony /var/run/slony1 /var/opt/gitlab/postgresql/slony
sudo chown gitlab-psql:root /var/log/gitlab/slony /var/run/slony1 /var/opt/gitlab/postgresql/slony
```
@@ -184,7 +184,7 @@ use it. The following placeholders should be replaced:
The list of tables to replicate can be generated by running the following
command on your old PostgreSQL database:
-```
+```shell
sudo gitlab-psql gitlabhq_production -c "select concat('\"', schemaname, '.', tablename, '\",') from pg_catalog.pg_tables where schemaname = 'public' and tableowner = 'gitlab' and tablename != 'schema_migrations' order by tablename asc;" -t
```
@@ -216,13 +216,13 @@ sure that the SQL files we generated earlier can be found in the `/tmp`
directory of the new server. Once these files are in place start a `psql`
session on this server:
-```
+```shell
sudo gitlab-psql gitlabhq_production
```
Now run the following commands:
-```
+```plaintext
\i /tmp/structure.sql
\i /tmp/migrations.sql
```
@@ -231,7 +231,7 @@ To verify if the structure is in place close the session, start it again, then
run `\d`. If all went well you should see output along the lines of the
following:
-```
+```plaintext
List of relations
Schema | Name | Type | Owner
--------+---------------------------------------------+----------+-------------
@@ -248,13 +248,13 @@ following:
Now we can initialize the required tables and what not that Slony will use for
its replication process. To do so, run the following on the old database:
-```
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slonik_init_cluster --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf | /opt/gitlab/embedded/bin/slonik
```
If all went well this will produce something along the lines of:
-```
+```plaintext
<stdin>:10: Set up replication nodes
<stdin>:13: Next: configure paths for each node/origin
<stdin>:16: Replication nodes prepared
@@ -264,13 +264,13 @@ If all went well this will produce something along the lines of:
Next we need to start a replication node on every server. To do so, run the
following on the old database:
-```
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slon_start 1 --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf
```
If all went well this will produce output such as:
-```
+```plaintext
Invoke slon for node 1 - /opt/gitlab/embedded/bin/slon -p /var/run/slony1/slony_replication_node1.pid -s 1000 -d2 slony_replication 'host=192.168.0.7 dbname=gitlabhq_production user=slony port=5432 password=hieng8ezohHuCeiqu0leeghai4aeyahp' > /var/log/gitlab/slony/node1/gitlabhq_production-2016-10-06.log 2>&1 &
Slon successfully started for cluster slony_replication, node node1
PID [26740]
@@ -279,7 +279,7 @@ Start the watchdog process as well...
Next we need to run the following command on the _new_ database server:
-```
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slon_start 2 --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf
```
@@ -288,13 +288,13 @@ This will produce similar output if all went well.
Next we need to tell the new database server what it should replicate. This can
be done by running the following command on the _new_ database server:
-```
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slonik_create_set 1 --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf | /opt/gitlab/embedded/bin/slonik
```
This should produce output along the lines of the following:
-```
+```plaintext
<stdin>:11: Subscription set 1 (set1) created
<stdin>:12: Adding tables to the subscription set
<stdin>:16: Add primary keyed table public.abuse_reports
@@ -308,13 +308,13 @@ This should produce output along the lines of the following:
Finally we can start the replication process by running the following on the
_new_ database server:
-```
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slonik_subscribe_set 1 2 --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf | /opt/gitlab/embedded/bin/slonik
```
This should produce the following output:
-```
+```plaintext
<stdin>:6: Subscribed nodes to set 1
```
@@ -324,7 +324,7 @@ not days. Unfortunately Slony itself doesn't really provide a way of knowing
when the two databases are in sync. To get an estimate of the progress you can
use the following shell script:
-```
+```shell
#!/usr/bin/env bash
set -e
@@ -365,7 +365,7 @@ GitLab so it can use the new database, etc.
First, let's stop all of GitLab. Omnibus users can do so by running the
following on their GitLab server(s):
-```
+```shell
sudo gitlab-ctl stop unicorn
sudo gitlab-ctl stop sidekiq
sudo gitlab-ctl stop mailroom
@@ -382,7 +382,7 @@ as this data will be lost.
To stop replication, run the following on both database servers:
-```bash
+```shell
sudo -u gitlab-psql /opt/gitlab/embedded/bin/slon_kill --conf /var/opt/gitlab/postgresql/slony/slon_tools.conf
```
@@ -394,7 +394,7 @@ The above setup does not replicate database sequences, as such these must be
reset manually in the target database. You can use the following script for
this:
-```bash
+```shell
#!/usr/bin/env bash
set -e
@@ -459,7 +459,7 @@ main
Upload this script to the _target_ server and execute it as follows:
-```bash
+```shell
bash path/to/the/script/above.sh
```
@@ -471,7 +471,7 @@ This will correct the ownership of sequences and reset the next value for the
Next we need to remove all Slony related data. To do so, run the following
command on the _target_ server:
-```bash
+```shell
sudo gitlab-psql gitlabhq_production -c "DROP SCHEMA _slony_replication CASCADE;"
```