Configure Gitlab to use an external database

Source: Internet
Author: User
Tags create database

Vim/opt/gitlab/embedded/service/gitlab-rails/.bundle/config
Change bundle_without: "Development:test:mysql" revision to
Bundle_without: "Development:test:postgres"

Yum-y Install Ruby-devel
Cd/opt/gitlab/embedded/bin
./gem Install MYSQL2

1. Create a database
#创建数据库
Create DATABASE Gitlab DEFAULT CHARACTER SET UTF8 COLLATE utf8_general_ci;

#添加权限
GRANT all privileges to gitlab.*to ' gitlab ' @ '% ' identified by ' Gitlab ' with GRANT OPTION;

#刷新权限
Flush privileges;

2, configure GITLAB.RB, add MySQL
Vim/etc/gitlab/gitlab.rb

#修改数据库配置
gitlab_rails[' db_adapter '] = "MYSQL2"
gitlab_rails[' db_encoding '] = "UTF8"
gitlab_rails[' db_database '] = "Gitlab"
gitlab_rails[' db_username '] = "Gitlab"
gitlab_rails[' db_password '] = "Gitlab"
gitlab_rails[' db_host '] = "127.0.0.1"
gitlab_rails[' db_port '] = 3306
postgresql[' Enable '] = False

3. Configuring Gitlab Dependencies
3.1 Remove Postgres Dependency
#缺少 MYSQL2, use Ruby's Gem tool to download one, and before you download it, you'll need to configure Ruby and bundle
#编辑config
Vim/opt/gitlab/embedded/service/gitlab-rails/.bundle/config
Replace the original MySQL with Postgres, we don't need the postgers package.
Write a picture description here

3.2 Installing MySQL Dependencies
Installation dependent, you need to specify the version, you can install the version after installation, Gitlab-rake Gitlab:check to view the installation.

Gitlab almost all of the commands are in this directory

cd/opt/gitlab/embedded/bin/

# #安装mysql
./gem Install MYSQL2

Yum-y Install Ruby-devel
Mkdir-p/opt/gitlab/embedded/lib/ruby/include/
cp/usr/include/ruby/ruby.h/opt/gitlab/embedded/lib/ruby/include/

#删除mysql
./gem Uninstall MYSQL2

#安装指定版本
./gem install mysql2-v "0.3.20"

#查看版本
./gem List | grep MySQL

4. Check the configuration
This check is to ensure that our configuration is absolutely correct. Otherwise, you will die very badly. This place will have a lot of wrong, can see my common problems, perhaps there is the same.

#查看配置是否ok, if the database is OK, you can directly execute Gitlab-rake gitlab:setup to create a table of the database.
Gitlab-rake Gitlab:check

5. Initialize Gitlab
Executes the Gitlab-rake gitlab:setup command to initialize the Gitlab.

#初始化gitlab
Gitlab-rake Gitlab:setup

After we have executed the Gitlab-rake Gitlab:setup, we will be prompted that the previous data information will be lost. Of course we do not set to Yes, back to play AH.

Once successful, a root user is created

6. Restart Service
# # # # # # #后面几个gitlab-ctl Common commands, this configuration is not available
#配置服务
Gitlab-ctl reconfigure;

#重启服务
Gitlab-ctl Restart;

#查看启动情况
Gitlab-ctl Tail

7. View database Information
Can see the database, a lot more tables, and then the service started normally

#可以看到好多表已经自动创建了.
Show tables;

Service starts normally

Problems
1, warehouse storage directory Permissions
The solution is to provide the warehouse with a GT user's privileges sudo chown-r git:git/var/opt/gitlab/git-data/repositories

Default ... no
User ID for git:995. GROUPD ID for git:993
Try Fixing it:
sudo chown-r git:git/var/opt/gitlab/git-data/repositories
For more information see:
Doc/install/installation.md in section "GitLab Shell"
Please fix the error above and rerun the checks.

2, Gitlab no mysql2 dependence
Specified ' MYSQL2 ' for database adapter, but the gem was not loaded. Add to gem ‘mysql2‘ your gemfile (and ensure it version is in the minimum required by ActiveRecord). Excluded from capture due t o Environment or Should_capture callback
1
Workaround, install dependencies

#到bin目录下, execute the GEM's command
Cd/opt/gitlab/embedded/bin

#安装指定版本的mysql驱动
Gem install mysql2-v "0.3.20"

3, Gitlab can not find the problem of the table
If the driver installation succeeds, execute Gitlab-rake gitlab:check, if the table does not exist, you can execute the following code to create the table.

Gitlab-rake Gitlab:setup

4, Gitlab-shell self-check failed
The automatic check failed, causing the problem because the server was not found, and the solution was to point to its own server in the local hosts.
Solution,/etc/hosts add 127.0.0.1 localhost, I'll test the function first.

Vim/etc/hosts

#添加
127.0.0.1 localhost

Configure Gitlab to use an external database

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.