Clean up the mysql to postgres guide
This change refactors the pgloader instructions to have less headings and be more straightforward.
This commit is contained in:
parent
14bbc9362a
commit
7fcd386a6c
1 changed files with 161 additions and 169 deletions
|
@ -1,27 +1,54 @@
|
|||
---
|
||||
last_updated: 2018-02-07
|
||||
last_updated: 2019-03-27
|
||||
---
|
||||
|
||||
# Migrating from MySQL to PostgreSQL
|
||||
|
||||
> **Note:** This guide assumes you have a working GitLab instance with
|
||||
> MySQL and want to migrate to bundled PostgreSQL database.
|
||||
This guide documents how to take a working GitLab instance that uses MySQL and
|
||||
migrate it to a PostgreSQL database.
|
||||
|
||||
## Omnibus installation
|
||||
## Requirements
|
||||
|
||||
### Prerequisites
|
||||
[pgloader](http://pgloader.io) 3.4.1+ is required.
|
||||
|
||||
First, we'll need to enable the bundled PostgreSQL database with up-to-date
|
||||
schema. Next, we'll use [pgloader](http://pgloader.io) to migrate the data
|
||||
from the old MySQL database to the new PostgreSQL one.
|
||||
You can install it directly from your distribution, for example in
|
||||
Debian/Ubuntu:
|
||||
|
||||
Here's what you'll need to have installed:
|
||||
1. Search for the version:
|
||||
|
||||
- pgloader 3.4.1+
|
||||
- Omnibus GitLab
|
||||
- MySQL
|
||||
```bash
|
||||
apt-cache madison pgloader
|
||||
```
|
||||
|
||||
### Enable bundled PostgreSQL database
|
||||
1. If the version is 3.4.1+, install it with:
|
||||
|
||||
```bash
|
||||
sudo apt-get install pgloader
|
||||
```
|
||||
|
||||
If your distribution's version is too old, use PostgreSQL's repository:
|
||||
|
||||
```bash
|
||||
# Add repository
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
# Add key
|
||||
sudo apt-get install wget ca-certificates
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
# Install package
|
||||
sudo apt-get update
|
||||
sudo apt-get install pgloader
|
||||
```
|
||||
|
||||
For other distributions, follow the instructions in PostrgreSQL's
|
||||
[download page](https://www.postgresql.org/download/) to add their repository
|
||||
and then install `pgloader`.
|
||||
|
||||
## Omnibus GitLab installations
|
||||
|
||||
For [Omnibus GitLab packages](https://about.gitlab.com/install/), you'll first
|
||||
need to enable the bundled PostgreSQL:
|
||||
|
||||
1. Stop GitLab:
|
||||
|
||||
|
@ -40,12 +67,8 @@ Here's what you'll need to have installed:
|
|||
and alike. You could just comment all of them out so that we'll just use
|
||||
the defaults.
|
||||
|
||||
1. [Reconfigure GitLab] for the changes to take effect:
|
||||
|
||||
``` bash
|
||||
sudo gitlab-ctl reconfigure
|
||||
```
|
||||
|
||||
1. [Reconfigure GitLab](../administration/restart_gitlab.md#omnibus-gitlab-reconfigure)
|
||||
for the changes to take effect.
|
||||
1. Start Unicorn and PostgreSQL so that we can prepare the schema:
|
||||
|
||||
```bash
|
||||
|
@ -67,12 +90,11 @@ Here's what you'll need to have installed:
|
|||
|
||||
After these steps, you'll have a fresh PostgreSQL database with up-to-date schema.
|
||||
|
||||
### Migrate data from MySQL to PostgreSQL
|
||||
|
||||
Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
||||
Next, we'll use `pgloader` to migrate the data from the old MySQL database to the
|
||||
new PostgreSQL one:
|
||||
|
||||
1. Save the following snippet in a `commands.load` file, and edit with your
|
||||
database `username`, `password` and `host`:
|
||||
MySQL database `username`, `password` and `host`:
|
||||
|
||||
```
|
||||
LOAD DATABASE
|
||||
|
@ -117,8 +139,8 @@ Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
|||
Total import time 1894 1894 0 12.497s
|
||||
```
|
||||
|
||||
If there is no output for more than 30 minutes, it's possible pgloader encountered an error. See
|
||||
the [troubleshooting guide](#Troubleshooting) for more details.
|
||||
If there is no output for more than 30 minutes, it's possible `pgloader` encountered an error. See
|
||||
the [troubleshooting guide](#troubleshooting) for more details.
|
||||
|
||||
1. Start GitLab:
|
||||
|
||||
|
@ -126,64 +148,14 @@ Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
|||
sudo gitlab-ctl start
|
||||
```
|
||||
|
||||
Now, you can verify that everything worked by visiting GitLab.
|
||||
You can now verify that everything works as expected by visiting GitLab.
|
||||
|
||||
### Troubleshooting
|
||||
## Source installations
|
||||
|
||||
#### Permissions
|
||||
For installations from source that use MySQL, you'll first need to
|
||||
[install PostgreSQL and create a database](../install/installation.md#6-database).
|
||||
|
||||
Note that the PostgreSQL user that you use for the above MUST have **superuser** privileges. Otherwise, you may see
|
||||
a similar message to the following:
|
||||
|
||||
```
|
||||
debugger invoked on a CL-POSTGRES-ERROR:INSUFFICIENT-PRIVILEGE in thread
|
||||
#<THREAD "lparallel" RUNNING {10078A3513}>:
|
||||
Database error 42501: permission denied: "RI_ConstraintTrigger_a_20937" is a system trigger
|
||||
QUERY: ALTER TABLE ci_builds DISABLE TRIGGER ALL;
|
||||
2017-08-23T00:36:56.782000Z ERROR Database error 42501: permission denied: "RI_ConstraintTrigger_c_20864" is a system trigger
|
||||
QUERY: ALTER TABLE approver_groups DISABLE TRIGGER ALL;
|
||||
```
|
||||
|
||||
#### Experiencing 500 errors after the migration
|
||||
|
||||
If you experience 500 errors after the migration, try to clear the cache:
|
||||
|
||||
``` bash
|
||||
sudo gitlab-rake cache:clear
|
||||
```
|
||||
|
||||
[reconfigure GitLab]: ../administration/restart_gitlab.md#omnibus-gitlab-reconfigure
|
||||
|
||||
## Source installation
|
||||
|
||||
### Prerequisites
|
||||
|
||||
#### Install PostgreSQL and create database
|
||||
|
||||
See [installation guide](../install/installation.md#6-database).
|
||||
|
||||
#### Install [pgloader](http://pgloader.io) 3.4.1+
|
||||
|
||||
Install directly from your distro:
|
||||
``` bash
|
||||
sudo apt-get install pgloader
|
||||
```
|
||||
|
||||
If this version is too old, use PostgreSQL's repository:
|
||||
``` bash
|
||||
# add repository
|
||||
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
|
||||
|
||||
# add key
|
||||
sudo apt-get install wget ca-certificates
|
||||
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
|
||||
|
||||
# install package
|
||||
sudo apt-get update
|
||||
sudo apt-get install pgloader
|
||||
```
|
||||
|
||||
### Enable bundled PostgreSQL database
|
||||
After the database is created, go on with the following steps:
|
||||
|
||||
1. Stop GitLab:
|
||||
|
||||
|
@ -199,6 +171,7 @@ sudo apt-get install pgloader
|
|||
sudo -u git cp config/database.yml.postgresql config/database.yml
|
||||
sudo -u git -H chmod o-rwx config/database.yml
|
||||
```
|
||||
|
||||
1. Install Gems related to Postgresql
|
||||
|
||||
```bash
|
||||
|
@ -214,9 +187,8 @@ sudo apt-get install pgloader
|
|||
|
||||
After these steps, you'll have a fresh PostgreSQL database with up-to-date schema.
|
||||
|
||||
### Migrate data from MySQL to PostgreSQL
|
||||
|
||||
Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
||||
Next, we'll use `pgloader` to migrate the data from the old MySQL database to the
|
||||
new PostgreSQL one:
|
||||
|
||||
1. Save the following snippet in a `commands.load` file, and edit with your
|
||||
MySQL `username`, `password` and `host`:
|
||||
|
@ -264,8 +236,8 @@ Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
|||
Total import time 1894 1894 0 12.497s
|
||||
```
|
||||
|
||||
If there is no output for more than 30 minutes, it's possible pgloader encountered an error. See
|
||||
the [troubleshooting guide](#Troubleshooting) for more details.
|
||||
If there is no output for more than 30 minutes, it's possible `pgloader` encountered an error. See
|
||||
the [troubleshooting guide](#troubleshooting) for more details.
|
||||
|
||||
1. Start GitLab:
|
||||
|
||||
|
@ -273,14 +245,34 @@ Now, you can use pgloader to migrate the data from MySQL to PostgreSQL:
|
|||
sudo service gitlab start
|
||||
```
|
||||
|
||||
Now, you can verify that everything worked by visiting GitLab.
|
||||
You can now verify that everything works as expected by visiting GitLab.
|
||||
|
||||
### Troubleshooting
|
||||
## Troubleshooting
|
||||
|
||||
#### Experiencing 500 errors after the migration
|
||||
Sometimes, you might encounter some errors during or after the migration.
|
||||
|
||||
### Database error permission denied
|
||||
|
||||
The PostgreSQL user that you use for the migration MUST have **superuser** privileges.
|
||||
Otherwise, you may see a similar message to the following:
|
||||
|
||||
```
|
||||
debugger invoked on a CL-POSTGRES-ERROR:INSUFFICIENT-PRIVILEGE in thread
|
||||
#<THREAD "lparallel" RUNNING {10078A3513}>:
|
||||
Database error 42501: permission denied: "RI_ConstraintTrigger_a_20937" is a system trigger
|
||||
QUERY: ALTER TABLE ci_builds DISABLE TRIGGER ALL;
|
||||
2017-08-23T00:36:56.782000Z ERROR Database error 42501: permission denied: "RI_ConstraintTrigger_c_20864" is a system trigger
|
||||
QUERY: ALTER TABLE approver_groups DISABLE TRIGGER ALL;
|
||||
```
|
||||
|
||||
### Experiencing 500 errors after the migration
|
||||
|
||||
If you experience 500 errors after the migration, try to clear the cache:
|
||||
|
||||
```bash
|
||||
# Omnibus GitLab
|
||||
sudo gitlab-rake cache:clear
|
||||
|
||||
# Installations from source
|
||||
sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue