Centos7下Gitlab迁移数据库mysql过程
发表于:2025-11-08 作者:千家信息网编辑
千家信息网最后更新 2025年11月08日,第1章 系统准备[root@test ~]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)[root@test ~]# una
千家信息网最后更新 2025年11月08日Centos7下Gitlab迁移数据库mysql过程第1章 系统准备
1.1添加阿里云的镜像
第2章 yum安装最新版Gitlab9.1.2
2.1安装依赖软件
2.2添加清华大学镜像
2.3安装gitlab-ce
2.4查看安装gitlab的版本
2.5重新配置并启动Gitlab
第3章 安装mysql5.6.36
3.1添加mysql源
3.2mysql配置
第4章 配置Gitlab连接mysql
4.1修改/etc/gitlab/gitlab.rb
第5章 排错步骤
5.1更换gem源

5.3bundle禁止使用postgresql
5.4 安装mysql2 "0.3.20"
5.5重置检查
5.6客户端测试
第1章 系统准备
[root@test ~]# cat /etc/redhat-releaseCentOS Linux release 7.2.1511 (Core)[root@test ~]# uname -r3.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添加清华大学镜像
vi /etc/yum.repos.d/gitlab-ce.repo[gitlab-ce]name=Gitlab CE Repositorybaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/gpgcheck=0enabled=1
2.3安装gitlab-ce
yum makecacheyum install gitlab-ce
2.4查看安装gitlab的版本
head -1 /opt/gitlab/version-manifest.txtgitlab-ce 9.1.2
2.5重新配置并启动Gitlab
# gitlab-ctl reconfigure会把一些过去的config还原,导致修改的端口以及域名等都没有了gitlab-ctl reconfigure #重启gitlab-cegitlab-ctl restart
第3章 安装mysql5.6.36
3.1添加mysql源
vi /etc/yum.repo.d/mysql.repo[mysql56-community]name=MySQL 5.6 Community Serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=1gpgcheck=0
3.2mysql配置
yum -y install mysql-server mysql-devel #基本配置,新建密码等mysql_secure_installation #登录数据库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) #创建一个gitlab管理用户mysql> CREATE USER 'git'@'localhost' IDENTIFIED BY '123456';Query OK, 0 rows affected (0.00 sec) #创建gitlab数据库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用户对gitlabhq_production数据库所有表的权限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> \qBye #测试新用户是否能连接新的数据库sudo -u git -H mysql -u git -p -Dgitlabhq_productionEnter password:Reading table information for completion of tableand column namesYou 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 32Server 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 itsaffiliates. Other names may be trademarks of theirrespectiveowners. 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'] = falsegitlab_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'按官方文档重新配置gitlabgitlab-ctl reconfigure迁移数据库时出现以下错误

第5章 排错步骤
5.1更换gem源
#查看gem源/opt/gitlab/embedded/bin/gem source*** CURRENT SOURCES *** https://rubygems.org/ #更换开源中国的gem源,否则使用时会出现错误/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/ Gemfilesource 'https://gems.ruby-china.org'
5.2bundle install安装更新
#此命令会尝试更新系统中已存在的gem包
/opt/gitlab/embedded/bin/bundle install
#执行该命令需要切换到Gemfile上一级目录才可以运行
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
5.4 安装mysql2 "0.3.20"
gitlab-rake gitlab:check
#安装mysql2 0.3.20版本/opt/gitlab/embedded/bin/gem install mysql2 -v'0.3.20'出错
查看文件后发现没有安装gcc软件,导致不能编译文件。故需要yum安装gccyum 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.20Parsing documentation for mysql2-0.3.20Installing ri documentation for mysql2-0.3.20Done installing documentation for mysql2 after 1seconds1 gem installed
5.5重置检查
#重新配置gitlab-ctl reconfigure#检查gitlab-rake gitlab:check
5.6客户端测试
[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 masterCounting 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 设置为跟踪来自 origin 的远程分支 master。
成功
参考文档:
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
配置
数据
数据库
用户
文件
镜像
阿里
分支
命令
文档
版本
系统
软件
错误
更新
检查
测试
成功
域名
基本配置
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
郑州志远网络技术有限公司
实用网络技术介绍
网络安全工程师要拿多少证
服务器负载功率计算
严控网络安全风险
网络技术及应用 翻译
数据库应用技术02章
消除网络安全风险措施
上海互升网络技术有限公司
网络安全评估员
在关系数据库中关系就是一张
银河麒麟服务器管理员
南网网络安全新技术
长春联想服务器
玉溪软件开发
数据库实验第二部分百度文库
北京中科智慧网络安全有限公司
中学生与网络安全个人过程
数据库小组设计注意什么好
无法和服务器建立数据连接
诛仙3 服务器
服务器搭建与管理设计步骤
何跃鹰网络安全
滨州网络技术
网络安全和信息化网管员世界
社保卡调用服务器错误
数据库 同时写入数据库
什么叫网络安全体系结构
机场服务器可以自己搭建
全球网络安全监测