zoukankan      html  css  js  c++  java
  • centos7 安装gitlab

    官方安装文档:https://about.gitlab.com/installation/#centos-7

    1、添加gitlab软件源

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

    2、安装gitlab,设置访问地址

    sudo EXTERNAL_URL="http://192.168.255.120:90"yum install -y gitlab-ee

    3、登录,默认用户名root,第一次访问,会重定向到密码重置页面

    注意事项:

    1、gitlab本身采用80端口,如安装前服务器有启用80,安装完访问会报错。需更改gitlab的默认端口。

    修改vim /etc/gitlab/gitlab.rb:

    external_url ‘http://localhost:90’

    2、unicorn本身采用8080端口,如安装前服务器有启用8080,安装完访问会报错。需更改unicorn的默认端口。

    修改 /etc/gitlab/gitlab.rb:

    unicorn[‘port’] = 3000

    3、每次修改配置文件,都需要执行sudo gitlab-ctl reconfigure  使之生效。

    4、所以的日志都在:/var/log/gitlab  

    gitlab-ctl tail  #查看所有日志

    gitlab-ctl tail nginx/gitlab_access.log  #查看nginx访问日志

     5、启动停止命令

    gitlab-ctl start|stop|status|restart

     6、查看当前gitlab的版本号

    cat /opt/gitlab/embedded/service/gitlab-rails/VERSION

    7、汉化

    需要下载汉化包,gitlab版本和汉化包版本须一致。

    gitlab版本是8.8.5,那么我就需要下载这个版本的补丁。

    比如我们现在到/usr/local/src,执行如下命令去git clone包:

    git clone https://github.com/larryli/gitlabhq.git

    先停止运行,gitlab-ctl stop,再执行汉化操作

    cp /usr/local/src/gitlabhq/* /opt/gitlab/embedded/service/gitlab-rails/ -rf

    其中有两个提示我们可以忽略:

    cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/log’ with directory `./log’

    cp: cannot overwrite non-directory `/opt/gitlab/embedded/service/gitlab-rails/tmp’ with directory `./tmp’

    好了,汉化完成,重新启动gitlab,汉化完成。

    8.日常备份 恢复 与 迁移

    8.1创建备份

    使用Gitlab一键安装包安装Gitlab非常简单, 同样的备份恢复与迁移也非常简单. 使用一条命令即可创建完整的Gitlab备份:

    gitlab-rake gitlab:backup:create

    8.2修改备份文件默认目录

    也可以通过修改/etc/gitlab/gitlab.rb来修改默认存放备份文件的目录:

    gitlab_rails['backup_path'] = '/data/backups'

    /data/backups修改为你想存放备份的目录即可, 修改完成之后使用gitlab-ctl reconfigure命令重载配置文件即可.

    8.3自动备份

    也可以通过crontab使用备份命令实现自动备份

    crontab -e

    实现每天凌晨2点进行一次自动备份

    0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create

    8.4恢复

    Gitlab的从备份恢复也非常简单:

    # 停止相关数据连接服务

    gitlab-ctl stop unicorn

    gitlab-ctl stop sidekiq

    # 从1393513186编号备份中恢复

    gitlab-rake gitlab:backup:restore BACKUP=1393513186

    # 启动Gitlab

    gitlab-ctl start

    8.5迁移

    迁移如同备份与恢复的步骤一样, 只需要将老服务器/var/opt/gitlab/backups

    目录下的备份文件拷贝到新服务器上的/var/opt/gitlab/backups

    即可(如果你没修改过默认备份目录的话). 但是需要注意的是新服务器上的Gitlab的版本必须与创建备份时的Gitlab版本号相同. 比如新服务器安装的是最新的8.8.5版本的Gitlab, 那么迁移之前, 最好将老服务器的Gitlab 升级为8.8.5在进行备份.

  • 相关阅读:
    @atcoder
    @loj
    @AGC037
    @uoj
    @uoj
    @loj
    @loj
    @loj
    @loj
    @loj
  • 原文地址:https://www.cnblogs.com/fanren224/p/8559294.html
Copyright © 2011-2022 走看看