• CentOS环境下GitLab安装、备份、恢复、升级指南


    环境准备

    虚拟机安装的CentOS是7.9.2009

    文件名:CentOS-7-x86_64-Minimal-2009.iso

    MD5:a4711c4fa6a1fb32bd555fae8d885b12

    IP地址:192.168.50.101

    配置:2c4t、4G内存、50G磁盘

    配置虚拟机的固定IP,根据虚拟机镜像文件不同ifcfg-ens33文件可能为其他名字

    # vi /etc/sysconfig/network-scripts/ifcfg-ens33
    
    BOOTPROTO=static #默认为dhcp,修改为static
    ONBOOT=yes # 默认为no,修改为yes
    
    # 新增如下配置,根据自己的网络环境调整
    IPADDR=192.168.50.101
    GATEWAY=192.168.50.1
    DNS1=192.168.50.1
    

    执行 service network restart 重启网络,之后就可以ssh连上虚拟机了

    软件包下载

    下载地址:https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/

    我下载的是:

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-11.8.0-ee.0.el7.x86_64.rpm

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-11.11.8-ee.0.el7.x86_64.rpm

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-12.0.12-ee.0.el7.x86_64.rpm

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-12.10.9-ee.0.el7.x86_64.rpm

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-13.0.14-ee.0.el7.x86_64.rpm

    https://mirror.tuna.tsinghua.edu.cn/gitlab-ee/yum/el7/gitlab-ee-13.9.2-ee.0.el7.x86_64.rpm

    按照官方的说法,gitlab允许小版本直接升级,大版本需要阶段升级。

    跨版本升级示例:11.8.x -> 11.11.x -> 12.0.x -> 12.10.x -> 13.0.x -> 13.9.x

    我将先安装11.8.0,然后测试备份恢复,最后升级到13.9.2,如需安装其他版本直接参考11.8.0的安装示例即可

    我的升级路线:11.8.0 -> 11.11.8 -> 12.0.12 -> 12.10.9 -> 13.0.14 -> 13.9.2

    安装

    依赖安装

    在CentOS 7(RedHat/Oracle/Science Linux 7)上,用以下命令在系统防火墙中打开HTTP和SSH访问 。

    yum install -y curl policycoreutils-python openssh-server perl
    systemctl enable sshd
    systemctl start sshd
    firewall-cmd --permanent --add-service=http
    firewall-cmd --permanent --add-service=https
    systemctl reload firewalld
    

    接下来,安装Postfix以发送通知邮件。如果您想使用其他解决方案发送电子邮件,请跳过此步骤,在安装GitLab后配置外部SMTP服务器。

    yum install postfix
    systemctl enable postfix
    systemctl start postfix
    

    软件包安装

    EXTERNAL_URL="http://192.168.50.101" rpm -ivh gitlab-ee-11.8.0-ee.0.el7.x86_64.rpm
    

    出现如下提示:

    gitlab Reconfigured!
    
           *.                  *.
          ***                 ***
         *****               *****
        .******             *******
        ********            ********
       ,,,,,,,,,***********,,,,,,,,,
      ,,,,,,,,,,,*********,,,,,,,,,,,
      .,,,,,,,,,,,*******,,,,,,,,,,,,
          ,,,,,,,,,*****,,,,,,,,,.
             ,,,,,,,****,,,,,,
                .,,,***,,,,
                    ,*,.
    
    
    
         _______ __  __          __
        / ____(_) /_/ /   ____ _/ /_
       / / __/ / __/ /   / __ `/ __ 
      / /_/ / / /_/ /___/ /_/ / /_/ /
      \____/_/\__/_____/\__,_/_.___/
    
    
    Thank you for installing GitLab!
    GitLab should be available at http://192.168.50.101
    
    For a comprehensive list of configuration options please see the Omnibus GitLab readme
    https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
    

    浏览器访问 http://192.168.50.101 ,首次访问会提示修改root账号的密码,修改密码后新建一个账号,新建并推送一个项目进行验证

    备份

    GitLab 12.2及之后的版本

    gitlab-backup create
    

    GitLab 12.1及之前的版本

    gitlab-rake gitlab:backup:create
    

    默认会在 /var/opt/gitlab/backups/ 目录创建备份文件,文件名为时间戳、日期、版本号组成,如:1614949974_2021_03_05_11.8.0-ee_gitlab_backup.tar

    恢复

    停止连接到数据库的进程。让GitLab的其余部分保持运行:

    gitlab-ctl stop unicorn
    gitlab-ctl stop puma
    gitlab-ctl stop sidekiq
    # 验证
    gitlab-ctl status
    

    接下来,还原备份,指定要还原的备份的时间戳

    GitLab 12.2及之后的版本:

    gitlab-backup restore BACKUP=1614949974_2021_03_05_11.8.0-ee
    

    GitLab 12.1及之前的版本

    gitlab-rake gitlab:backup:restore BACKUP=1614949974_2021_03_05_11.8.0-ee
    

    恢复的过程中出现两次交互界面,敲入yes回车即可

    重新加载配置并重启GitLab

    gitlab-ctl reconfigure
    gitlab-ctl restart
    

    升级

    关闭部分gitlab服务

    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    gitlab-ctl stop nginx
    

    rpm包升级

    rpm -Uvh gitlab-ee-11.11.8-ee.0.el7.x86_64.rpm
    

    重新加载配置并重启GitLab

    gitlab-ctl restart
    

    执行完上面的命令后使用root账号登陆 http://192.168.50.101/admin 查看版本是否成功升级为11.11.8,成功后再依次执行下面的命令并再次检查

    升级到12.0.12:

    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    gitlab-ctl stop nginx
    rpm -Uvh gitlab-ee-12.0.12-ee.0.el7.x86_64.rpm
    gitlab-ctl restart
    

    升级到12.10.9:

    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    gitlab-ctl stop nginx
    rpm -Uvh gitlab-ee-12.10.9-ee.0.el7.x86_64.rpm
    gitlab-ctl restart
    

    升级到13.0.14:

    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    gitlab-ctl stop nginx
    rpm -Uvh gitlab-ee-13.0.14-ee.0.el7.x86_64.rpm
    gitlab-ctl restart
    

    升级到13.9.2:

    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    gitlab-ctl stop nginx
    rpm -Uvh gitlab-ee-13.9.2-ee.0.el7.x86_64.rpm
    gitlab-ctl restart
    

    运维

    常用命令

    gitlab-ctl start					# 启动全部服务
    gitlab-ctl restart					# 重启全部服务
    gitlab-ctl stop						# 停止全部服务
    gitlab-ctl reconfigure				# 使配置文件生效(一般修改完主配置文件/etc/gitlab/gitlab.rb,需要执行此命令)
    gitlab-ctl show-config				# 验证配置文件
    gitlab-ctl uninstall				# 删除gitlab(保留数据)
    gitlab-ctl cleanse					# 删除所有数据,从新开始
    gitlab-ctl tail <service name>		# 查看服务的日志
    

    常用组件

    nginx:静态Web服务器

    gitlab-shell:用于处理Git命令和修改authorized keys列表,我们的gitlab是以Git做为最层的,你操作实际上最后就是调用gitlab-shell命令进行处理。

    gitlab-workhorse:轻量级的反向代理服务器

    logrotate:日志文件管理工具

    postgresql:数据库

    redis:缓存数据库

    sidekiq:用于在后台执行队列任务(异步执行)

    unicorn:GitLab Rails应用是托管在这个服务器上面的

    基础目录

    /var/opt/gitlab/git-data/repositories:库默认存储目录

    /opt/gitlab:应用代码和相应的依赖程序

    /var/opt/gitlab:gitlab-ctl reconfigure命令编译后的应用数据和配置文件,不需要人为修改配置

    /etc/gitlab:配置文件目录

    /var/log/gitlab:此目录下存放了gitlab各个组件产生的日志

    /var/opt/gitlab/backups/:备份文件生成的目录

    参考链接

    GitLab安装:https://about.gitlab.com/install/#centos-7

    GitLab备份:https://docs.gitlab.com/ee/raketasks/backup_restore.html#back-up-gitlab

    GitLab的使用:https://www.cnblogs.com/zdqc/p/9666994.html

    Gitlab跨版本升级:https://www.cnblogs.com/Med1tator/p/13141827.html

  • 相关阅读:
    GUI线程安全详解(二)
    如何用BlazeDS前后台数据交互
    定制Flex菜单图标
    Web App第三方组件PKDashcode&Sencha
    如何用BlazeDS更改图片
    GUI线程安全详解(一)
    Flex Spark皮肤定制
    GUI线程安全详解(三)
    (C# 基础) Array ( Copy, Clone, Clear etc.)
    System.ArgumentException: Destination array was not long enough.
  • 原文地址:https://www.cnblogs.com/nihaorz/p/14490005.html
Copyright © 2020-2023  润新知