CentOS7-搭建GitLab服务器

首先准备一台CentOS7 操作系统:

我的版本是:

[root@gitlab ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)

 

首先配置yum源

我的CentOS-Base.repo 用的是阿里云的yum源。

sudo mv CentOS-Base.repo CentOS-Base.repo.bak

sudo wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

yum clean all

yum make cache

然后创建一个gitlab的yum源gitlab-ce.repo:

[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

接下来安装依赖的包

yum make cache

yum -y install curl policycoreutils-python openssh-server openssh-clients

然后再安装

yum install -y gitlab-ce

安装好后,修改配置文件:

vim /etc/gitlab/gitlab.rb

external_url='http://gitlab.server.com' 修改成 自己的IP或者域名。

修改配置文件之后,需要重新再配置文件生效下,初始化下。(过程没有报错即可证明成功)

gitlab-ctl reconfigure

 启动gitlab服务:

 

停止gitlab服务:

gitlab-ctl stop

重启服务:

gitlab-ctl restart

状态:

gitlab-ctl status

监控:

gitlab-ctl  tailunicorn #监控unicorn日志

gitlab-ctl tail

访问gitlab:

http://ip

 更改gitlab中用户的密码:

Gitlab数据迁移操作步骤:

旧服务器(192.168.1.159)
[root@localhost gitlab]# gitlab-ctl stop unicorn
[root@localhost gitlab]# gitlab-ctl stop sidekiq
[root@localhost gitlab]# gitlab-rake gitlab:backup:create
[root@localhost gitlab]#
新服务器(192.168.1.48)
[root@newgitlab backups]# gitlab-ctl stop unicron
[root@newgitlab backups]# gitlab-ctl stop sidekiq
[root@newgitlab backups]# scp -r root@192.168.1.159:/var/opt/gitlab/backups/*_gitlab_backup.tar /var/opt/gitlab/backups/
[root@newgitlab backups]# chmod 777 /var/opt/gitlab/backups/*_gitlab_backup.tar
[root@newgitlab backups]# cd /var/opt/gitlab/backups/
[root@newgitlab backups]# gitlab-rake gitlab:backup:restore BACKUP=1514807340
[root@newgitlab backups]# gitlab-ctl restart

 

posted @ 2019-02-22 15:30  柳湖居士  阅读(149)  评论(0)    收藏  举报