Centos7下Gitlab迁移数据库mysql过程

第1章 系统准备

[[email protected] ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[[email protected] ~]# 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添加清华大学镜像

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重新配置并启动Gitlab

# gitlab-ctl reconfigure会把一些过去的config还原,导致修改的端口以及域名等都没有了
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  
 
#登录数据库
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> \q
Bye
 
#测试新用户是否能连接新的数据库
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
迁移数据库时出现以下错误

第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/ Gemfile
source ‘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安装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

5.6客户端测试

[[email protected] chen]# touch README.md
[[email protected] chen]# git add README.md
[[email protected] chen]# git commit -m "addREADME"
[master(根提交) bed61ad] addREADME
 1 filechanged, 0 insertions(+), 0 deletions(-)
 create mode100644 README.md
[[email protected] 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 [email protected]: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

时间: 2024-12-09 06:29:07

Centos7下Gitlab迁移数据库mysql过程的相关文章

CentOS7 下源码安装MySQL 8.0.11

CentOS7 下源码安装MySQL 8.0.11 系统环境:CentOS7, 内核:Linux 3.10.0-862.el7.x86_64 如果有旧版本的MySQL,先卸载,用下面命令来查询出系统有哪些相关的MySQL包. rpm -qa | grep mysql 如果上述命令查询出有相关的MySQL包,就卸载 rpm -e 包名 卸载MariaDB包 yum remove mariadb-libs.x86_64 从MySQL官网下载源码包,并将该文件拷贝到系统中. https://dev.m

centos7下启动不了mysql或者mariadb报错

centos7 系统中编译安装mysql或者mariab启动不了服务 报错 错误如下:Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details. 解决方法: 根据提示,分别使用systemctl status mysqld

Centos7下nginx+owncloud+php+mysql搭建个人私有云

Centos7.1 1053最小化安装lnmp通过yum安装,由于Centos7没有mysql的yum源,所以要自己安装mysql的yum源,但是安装上了,在我这yum安装只有几十K的速度,所以干脆去yum源里下载了mysql-server的rpm包,然后通过yum安装的rpm包,省了不少时间,lnmp的搭建这里就不再多说了,记着关闭selinux不然会提示File not found. 一.下载owncloud并解压的网站目录 [[email protected] ~]# axel https

centos7下使用yum安装mysql并创建用户,数据库以及设置远程访问

CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 $ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm 安装这个

centos7下使用yum安装mysql数据库以及设置远程访问

CentOS7的yum源中默认好像是没有mysql的.为了解决这个问题,我们要先下载mysql的repo源. 1. 下载mysql的repo源 $ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 2. 安装mysql-community-release-el7-5.noarch.rpm包 $ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm 安装这个

centos7下搭建Testlink环境详细过程

花了半天的时间终于搭建好了完整的Testlink环境,主要包括Mysql以及PHP的版本.未关闭防火墙.以及安装配置过程中遇到的一些问题.以下是详细的搭建过程. 一.工具准备 以下是我在搭建过程中用到的工具版本: 1.Testlink ----testlink-1.9.17 2.MariaDB---MariaDB 10.3(testlink要求5.6以上的版本才能支持) 3.PHP----PHP 5.6(testlink对PHP的最低版本要求是>=5.5)   4.Linux---Centos

CentOS7下使用源安装MySQL

参考文章:https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/ 由于一些原因,CentOS7的默认yum源中取消了MySQL,取而代之的是MariaDB. yum list mysql Error: No matching Packages to list yum list mariadb Available Packages mariadb.x86_64 *:*.*.* 这时候还想通过yum安装mysql,就得做一些准备 首先到 ht

CentOS7下jenkins迁移和升级以及解决磁盘空间满的问题下

jenkins迁移和升级 查看jenkins安装包以及路径[[email protected] ~]# rpm -ql jenkins/etc/init.d/jenkins/etc/logrotate.d/jenkins/etc/sysconfig/jenkins/usr/lib/jenkins/usr/lib/jenkins/jenkins.war/usr/sbin/rcjenkins/var/cache/jenkins/var/lib/jenkins/var/log/jenkins 首先解决

CentOS7下源码安装MySQL 8.x

会选择使用源码安装MySQL,想必对MySQL及其他的安装方式已经有了一定的了解,这里就不对周边信息进行过多赘述了,直接开始吧. 编译MySQL比较消耗内存,如果机器内存较小,可能会在编译期间出现内存不足的异常.若没有设置swap分区的可以设置swap分区来解决,否则只能扩容内存了: [[email protected] ~]# dd if=/dev/zero of=/swapfile bs=1k count=2048000 [[email protected] ~]# mkswap /swap