Gitlab PostgreSQL Migration MySQL
1. Packages / Dependencies
|
|
During this installation some files will need to be edited manually. If you are familiar with vim set it as default editor with the commands below. If you are not familiar with vim please skip this and keep using the default editor.
|
|
Install the required packages (needed to compile Ruby and native extensions to Ruby gems):
Make sure you have the right version of Git installed
In order to receive mail notifications, make sure to install a mail server. By default, Debian is shipped with exim4 but this has problems while Ubuntu does not ship with one. The recommended mail server is postfix and you can install it with
|
|
Then select ‘Internet Site’ and press enter to confirm the hostname
2. Ruby
The current supported Ruby versions are 2.1.x and 2.3.x. 2.3.x is preferred, and support for 2.1.x will be dropped in the future.
The use of Ruby version managers such as RVM, rbenv or chruby with GitLab in production, frequently leads to hard to diagnose problems. For example, GitLab Shell is called from OpenSSH, and having a version manager can prevent pushing and pulling over SSH. Version managers are not supported and we strongly advise everyone to follow the instructions below to use a system Ruby.
Remove the old Ruby 1.8 if present:
Download Ruby and compile it:
Install the Bundler Gem:
3. Go
Since GitLab 8.0, Git HTTP requests are handled by gitlab-workhorse (formerly gitlab-git-http-server). This is a small daemon written in Go. To install gitlab-workhorse we need a Go compiler. The instructions below assume you use 64-bit Linux. You can find downloads for other platforms at the Go download page.
|
|
4. Node
Since GitLab 8.17, GitLab requires the use of node >= v4.3.0 to compile javascript assets, and starting in GitLab 9.0,
yarn
>= v0.17.0 is required to manage javascript dependencies. In many distros the versions provided by the official package repositories are out of date, so we’ll need to install through the following commands:
|
|
5. System Users
Create a git user for GitLab:
6. Database
Initial database setup
|
|
You are done installing the database for now and can go back to the rest of the installation. Please proceed to the rest of the installation before running through the utf8mb4 support section
MySQL utf8mb4 support
After installation or upgrade, remember to convert any new tables to utf8mb4
/utf8mb4_general_ci
We are about to do the following:
- Ensure you can enable
utf8mb4
encoding andutf8mb4_general_ci
collation for your GitLab DB, tables and data - Convert your GitLab tables and data from
utf8
/utf8_general_ci
toutf8mb4
/utf8mb4_general_ci
Check for utf8mb4 support
Check for InnoDB File-Per-Table Tablespaces
We need to check, enable and maybe convert your existing GitLab DB tables to the InnoDB File-Per-Table Tablespaces as a prerequise for supporting utfb8mb4 with long indexes
required by recent GitLab databases
|
|
You need MySQL 5.5.3 or later to perform this update
Whatever the results of your checks above, we now need to check if your GitLab database has been created using InnoDB File-Per-Table Tablespaces (i.e. innodb_file_per_table
was set to 1 at initial setup time)
Note: This setting is enabled by default since MySQL 5.6.6.
|
|
- Case 1: a result > 0 for both commands
Congrats, your GitLab database uses the right InnoDB tablespace format.
However, you must still ensure that any future tables created by GitLab will still use the right format:
If
SELECT @@innodb_file_per_table
returned 1 previously, your server is running correctlyIt’s however a requirement to check now that this setting is indeed persisted in your my.cnf file!
If
SELECT @@innodb_file_per_table
returned 0 previously, your server is not running correctly
Enable innodb_file_per_table by running in a MySQL session as root the command
SET GLOBAL innodb_file_per_table=1, innodb_file_format=Barracuda;
and persist the two settings in your my.cnf file
Now, if you have a different result returned by the 2 commands above, it means you have a mix of tables format uses in your GitLab database. This can happen if your MySQL server had different values for innodb_file_per_table
in its life and you updated GitLab at different moments with those inconsistent values. So keep reading.
- Case 2: a result equals to “0” OR not the same result for both commands
Unfortunately, none or only some of your GitLab database tables use the GitLab requirement of InnoDB File-Per-Table Tablespaces
|
|
Now, persist innodb_file_per_table and innodb_file_format in your
my.cnf
file
Ensure at this stage that your GitLab instance is indeed stopped.
Now, let’s convert all the GitLab database tables to the new tablespace format:
|
|
Check for proper InnoDB File Format, Row Format, Large Prefix and tables conversion
We need to check, enable and probably convert your existing GitLab DB tables to use the Barracuda InnoDB file format, the DYNAMIC row format and innodb_large_prefix as a second prerequisite for supporting utfb8mb4 with long indexes
used by recent GitLab databases
|
|
Now, ensure that innodb_file_format and innodb_large_prefix are persisted in your
my.cnf
file
Tables and data conversion to utf8mb4
Now that you have a persistent MySQL setup, you can safely upgrade tables after setup or upgrade time:
Ensure your GitLab database configuration file uses a proper connection encoding and collation:
|
|
MySQL strings limits
After installation or upgrade, remember to run the add_limits_mysql
Rake task
Omnibus GitLab installations
|
|
Installations from source
|
|
The text
type in MySQL has a different size limit than the text
type in PostgreSQL. In MySQL text
columns are limited to ~65kB, whereas in PostgreSQL text
columns are limited up to ~1GB!
The add_limits_mysql
Rake task converts some important text
columns in the GitLab database to longtext
columns, which can persist values of up to 4GB (sometimes less if the value contains multibyte characters)
7. Redis
GitLab requires at least Redis 2.8.
If you are using Debian 8 or Ubuntu 14.04 and up, then you can simply install Redis 2.8 with:
1 sudo apt-get install redis-server
8. GitLab
|
|
Configure It
|
|
Configure GitLab DB Settings
|
|
Install Gems
|
|
Install GitLab Shell
|
|
Install gitlab-workhorse
|
|
Initialize Database and Activate Advanced Features
|
|
You can set the Administrator/root password and e-mail by supplying them in environmental variables,
GITLAB_ROOT_PASSWORD
andGITLAB_ROOT_EMAIL
respectively, as seen below. If you don’t set the password (and it is set to the default one) please wait with exposing GitLab to the public internet until the installation is done and you’ve logged into the server the first time. During the first login you’ll be forced to change the default password.
|
|
Install Init Script
Download the init script (will be /etc/init.d/gitlab):
And if you are installing with a non-default folder or user copy and edit the defaults file:
If you installed GitLab in another directory or as a user other than the default you should change these settings in /etc/default/gitlab
. Do not edit /etc/init.d/gitlab
as it will be changed on upgrade.
Make GitLab start on boot:
Setup Logrotate
|
|
Check Application Status
Check if GitLab and its environment are configured correctly:
Compile Assets
|
|
Start Your GitLab Instance
|
|
9. Nginx
|
|
Site Configuration
|
|
Double-check Application Status
To make sure you didn’t miss anything run a more thorough check with:
Initial Login
|
|
10. Troubleshooting
|
|
- We do not support Ruby 2.4.0 yet. Please stay tuned! 详细介绍
|
|
- Problem is that Ubuntu calls it’s node binary nodejs. Bad move, as this install script is unable to find it.
Fixed that by setting a temporary alias: alias node=nodejs
|
|
|
|
- uncomment
unixsocket /var/run/redis/redis.sock
,unixsocketperm 700
,change700
to777
- bundle install 时会进入rubygems.org找最新的gem目录,而依据官方文档安装之后gemfile.lock里的
nokogiri 1.6.8
已过时,需要修改gemfile.lock里的nokogiri 1.6.8
为最新的nokogiri 1.6.8.1
|
|
|
|
|
|
- sudo: bundle: command not found,sudo gem command not found,sudo: yarn: command not found
系统中都已经安装了ruby,bundle,gem,为何在执行
sudo -u git -H
相关命令的时候,频繁提示command not foundCheck if the PATH has the same values both with and without sudo. Apparently it cannot find bundle just because it is not listed in PATH
http://stackoverflow.com/questions/22456998/why-is-sudo-bundle-command-not-found
http://stackoverflow.com/questions/3914694/bundle-command-not-found
- MySQL,Redis HA
|
|