美文网首页
CentOS7之Gitlab服务

CentOS7之Gitlab服务

作者: DimonHo | 来源:发表于2018-03-31 03:18 被阅读389次

环境说明

系统OS:CentOS7
IP: 192.168.1.2


配置过程

yum安装--官方推荐

  1. 安装 curl,policycoreutils-python,openssh-server服务
    # yum install curl policycoreutils-python openssh-server -y

  2. 启动sshd服务,并激活开机启动
    # systemctl enable sshd
    # systemctl start sshd

  3. 防火墙允许http服务通过
    # firewall-cmd --permanent --add-service=http
    # systemctl reload firewalld

  4. 安装Postfix发送通知邮件
    # yum install postfix -y

  5. 启动postfix服务,并激活开机启动
    # systemctl enable postfix
    # systemctl start postfix

  6. 获取GitLab-ee(企业版·免费试用)Gitlab-ce(社区版·免费)软件包yum源

# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | bash`

# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | bash

tips: curl命令执行完成后,会在/etc/yum.repos.d目录下生成 gitlab_gitlab-ee.repo
gitlab_gitlab-ce.repo文件。

tips: 关于gitlab-ee和gitlab-ce,二者是基于同样的核心代码进行开发,只是gitlab-ee功能更强大,但需要付费使用,有30天试用期。但试用期过后如果不付费,它就跟gitlab-ce功能是完全一样的,只是需要付费的功能无法再继续使用而已,所以这两个版本可以随意选择安装,但如果将来有付费的打算,直接安装gitlab-ee版本是个有远见的选择。当然,即使不付费,gitlab-ee使用上和gitlab-ce没有任何区别,所以接下来的操作我们就以安装gitlab-ee为例进行。

  1. 修改gitlab_gitlab-ee.repo文件的repo_gpgcheck属性为0,以及baseurl属性为清华大学的开源镜像站地址:
    https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7
[gitlab_gitlab-ee]
name=gitlab_gitlab-ee
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7
repo_gpgcheck=0
gpgcheck=1
enabled=1
gpgkey=https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey
       https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey/gitlab-gitlab-ee-3D645A26AB9FBD22.pub.gpg
sslverify=1
sslcacert=/etc/pki/tls/certs/ca-bundle.crt
metadata_expire=300

修改完成后再刷新yum源:
# yum clean all
# yum yum makecache

tips: https://mirrors.tuna.tsinghua.edu.cn是国内清华大学开源镜像站,避免yum install可能会因为网络原因导致失败

  1. 安装gitlab-ee(最新版本)
    # EXTERNAL_URL="http://192.168.1.2" yum install -y gitlab-ee

tips: 默认安装最新版本,如果需要安装指定的版本,可以到清华大学开源镜像站下载指定版本的rpm包。通过rmp -ivh gitlab-ee-10.6.2-ee.0.el7.x86_64.rpm 进行安装,注意同样需要先安装yum install policycoreutils-python,openssh-server postfix -y 服务。

当看到下面这个图案的时候,就表示安装成功了


安装成功
  1. 启动gitlab服务
    # gitlab-ctl start

gitlab默认端口为80,访问 http://192.168.1.2访问gitlab,第一次访问会要你重置root用户的密码。

修改root用户密码

tips: 启动过程有点慢,访问的时候可能出现502超时请求,稍等一会就好了。


gitlab备份和恢复(仓库迁移)

  1. 备份
    # gitlab-rake gitlab:backup:create

tips: 备份文件默认存放目录:/var/opt/gitlab/backups/,备份文件以 时间戳_gitlab_backup.tar 命名:1521636693_2018_03_31_10.4.2_gitlab_backup.tar

  1. 恢复(把备份文件copy到新gitlab服务器的/var/opt/gitlab/backups/目录下)
    # gitlab-rake gitlab:backup:restore BACKUP=1521636693_2018_03_31_10.4.2

tips: 恢复命令:gitlab-rake gitlab:backup:restore BACKUP=备份文件时间戳,恢复的时候如果版本不一致,可能报错

相关文章

网友评论

      本文标题:CentOS7之Gitlab服务

      本文链接:https://www.haomeiwen.com/subject/clgwcftx.html