Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)建站堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的道里網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!

第1章 系統(tǒng)準(zhǔn)備

[root@test ~]# cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) [root@test ~]# uname -r 3.10.0-327.el7.x86_64

1.1添加阿里云的鏡像

cd /etc/yum.repos.d#備份原鏡像mv CentOS-Base.repo CentOS-Base.repo.backup     #添加阿里云Base源 wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo   #添加阿里云epel源 wget https://mirrors.aliyun.com/repo/epel-7.repo#清除緩存 yum clean all && yum makecache

第2章 yum安裝最新版Gitlab9.1.2

2.1安裝依賴軟件

yum install curl policycoreutils openssh-serveropenssh-clients

2.2添加清華大學(xué)鏡像

vi /etc/yum.repos.d/gitlab-ce.repo [gitlab-ce] name=Gitlab CE Repository baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/ gpgcheck=0 enabled=1

2.3安裝gitlab-ce

yum makecache yum install gitlab-ce

2.4查看安裝gitlab的版本

head -1 /opt/gitlab/version-manifest.txt gitlab-ce 9.1.2

2.5重新配置并啟動(dòng)Gitlab

# gitlab-ctl reconfigure會(huì)把一些過去的config還原,導(dǎo)致修改的端口以及域名等都沒有了 gitlab-ctl reconfigure   #重啟gitlab-ce gitlab-ctl restart

第3章 安裝mysql5.6.36

3.1添加mysql源

vi /etc/yum.repo.d/mysql.repo [mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=1 gpgcheck=0

3.2mysql配置

yum -y install mysql-server mysql-devel   #基本配置,新建密碼等 mysql_secure_installation     #登錄數(shù)據(jù)庫 mysql -uroot -p$password     #查看用戶情況 mysql> select user,host from mysql.user; +------+-----------+ | user | host     | +------+-----------+ | root | 127.0.0.1 | | root | ::1      | | root | localhost | | root | test     | +------+-----------+ 4 rows in set (0.03 sec)   #創(chuàng)建一個(gè)gitlab管理用戶 mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '123456'; Query OK, 0 rows affected (0.00 sec)   #創(chuàng)建gitlab數(shù)據(jù)庫 mysql> CREATE DATABASE IF NOT EXISTS`gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_general_ci`; Query OK, 1 row affected (0.00 sec)   #授予git用戶對(duì)gitlabhq_production數(shù)據(jù)庫所有表的權(quán)限 mysql> GRANT SELECT, INSERT, UPDATE, DELETE,CREATE, CREATE TEMPORARY TABLES, DROP, INDEX, ALTER, LOCK TABLES, REFERENCES ON`gitlabhq_production`.* TO 'git'@'localhost'; Query OK, 0 rows affected (0.00 sec)   #使修改用戶生效 mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) mysql> \q Bye   #測(cè)試新用戶是否能連接新的數(shù)據(jù)庫 sudo -u git -H mysql -u git -p -Dgitlabhq_production Enter password: Reading table information for completion of tableand column names You can turn off this feature to get a quickerstartup with -A   Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 32 Server version: 5.6.36 MySQL Community Server (GPL)   Copyright (c) 2000, 2017, Oracle and/or itsaffiliates. All rights reserved.   Oracle is a registered trademark of OracleCorporation and/or its affiliates. Other names may be trademarks of theirrespective owners.   Type 'help;' or '\h' for help. Type '\c' to clearthe current input statement.   mysql>

第4章 配置Gitlab連接mysql

4.1修改/etc/gitlab/gitlab.rb

postgresql['enable'] = false gitlab_rails['db_adapter'] = 'mysql2' gitlab_rails['db_encoding'] = 'utf8' gitlab_rails['db_host'] = '127.0.0.1' gitlab_rails['db_port'] = '3306' gitlab_rails['db_username'] = 'git' gitlab_rails['db_password'] = '123456' 按官方文檔重新配置gitlab gitlab-ctl reconfigure 遷移數(shù)據(jù)庫時(shí)出現(xiàn)以下錯(cuò)誤

Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

第5章 排錯(cuò)步驟

5.1更換gem源

#查看gem源 /opt/gitlab/embedded/bin/gem source *** CURRENT SOURCES ***   https://rubygems.org/   #更換開源中國的gem源,否則使用時(shí)會(huì)出現(xiàn)錯(cuò)誤 /opt/gitlab/embedded/bin/gem sources --addhttps://gems.ruby-china.org/ --remove https://rubygems.org/   #查看更好后的gem源 /opt/gitlab/embedded/bin/gem sources *** CURRENT SOURCES ***   https://gems.ruby-china.org/   #更改配置Gemfile文件的gem源 vi /opt/gitlab/embedded/service/gitlab-rails/ Gemfile source 'https://gems.ruby-china.org'

5.2bundle install安裝更新

#此命令會(huì)嘗試更新系統(tǒng)中已存在的gem包
/opt/gitlab/embedded/bin/bundle install

Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程
#執(zhí)行該命令需要切換到Gemfile上一級(jí)目錄才可以運(yùn)行
cd /opt/gitlab/embedded/service/gitlab-rails/
/opt/gitlab/embedded/bin/bundle install

5.3bundle禁止使用postgresql

vi/opt/gitlab/embedded/service/gitlab-rails/.bundle/config

Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

5.4 安裝mysql2 “0.3.20”

gitlab-rake gitlab:check

Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

#安裝mysql2 0.3.20版本 /opt/gitlab/embedded/bin/gem install mysql2 -v'0.3.20' 出錯(cuò)

Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

查看文件后發(fā)現(xiàn)沒有安裝gcc軟件,導(dǎo)致不能編譯文件。 故需要yum安裝gcc yum install gcc –y   /opt/gitlab/embedded/bin/gem install mysql2 -v'0.3.20' Building native extensions.  This could take a while... Successfully installed mysql2-0.3.20 Parsing documentation for mysql2-0.3.20 Installing ri documentation for mysql2-0.3.20 Done installing documentation for mysql2 after 1seconds 1 gem installed

5.5重置檢查

#重新配置 gitlab-ctl reconfigure #檢查 gitlab-rake gitlab:check

 Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

5.6客戶端測(cè)試

[root@test chen]# touch README.md [root@test chen]# git add README.md [root@test chen]# git commit -m "addREADME" [master(根提交) bed61ad] addREADME  1 filechanged, 0 insertions(+), 0 deletions(-)  create mode100644 README.md [root@test chen]# git push -u origin master Counting objects: 3, done. Writing objects: 100% (3/3), 216 bytes | 0 bytes/s,done. Total 3 (delta 0), reused 0 (delta 0) To git@10.0.0.10:root/chen.git  * [newbranch]      master -> master 分支 master 設(shè)置為跟蹤來自 origin 的遠(yuǎn)程分支 master。

 Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程

成功

參考文檔:

https://docs.gitlab.com/ce/install/database_mysql.html

https://docs.gitlab.com/omnibus/settings/database.html#seed-the-database-fresh-installs-only

http://shaonian.blog.51cto.com/2975261/1894664

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前標(biāo)題:Centos7下Gitlab遷移數(shù)據(jù)庫mysql過程-創(chuàng)新互聯(lián)
標(biāo)題路徑:http://muchs.cn/article18/csppgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站內(nèi)鏈、網(wǎng)站設(shè)計(jì)公司、定制開發(fā)、企業(yè)網(wǎng)站制作App設(shè)計(jì)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)站建設(shè)