zoukankan      html  css  js  c++  java
  • gitlab-ce-omnibus社区版的备份、还原及升级

    gitlab-ce-omnibus社区版的备份和还原,可以使用gitlab自带工具,gitlab-rake来完成,详见下面例子

    将旧gitlab服务器备份,并还原至新gitlab服务器 ,这两台gitlab服务器必须要同版本,才能还原成功

    旧gitlab服务器

    • 更改gitlab备份文件存放位置

    vim /etc/gitlab/gitlab.rb
    
    gitlab_rails['backup_path'] = "/mnt"
    #该地址是配置存放备份的地方,根据实际情况配置,可以指定为已经挂载好的nfs目录,便于边备份边传输至新gitlab服务器。
    
    gitlab-ctl reconfigure
    
    • 备份旧gitlab服务器的数据,密钥文件及ssh文件,停止旧gitlab服务

    gitlab-rake gitlab:backup:create
    #在备份数据巨大,备份路径是网络路径情况下,比较耗时。
    
    cp  /etc/gitlab/gitlab-secrets.json  /mnt/
    cp  /etc/ssh/*key*  /mnt/
    
    
    #gitlab密钥及服务器密钥,在进行gitlab完整迁移和完整还原,是必须要备份的。
    
    
    gitlab-ctl stop
    

    新gitlab服务器

    • 停止与数据库的连接

    gitlab-ctl reconfigure
    gitlab-ctl stop unicorn
    gitlab-ctl stop sidekiq
    # Verify
    gitlab-ctl status
    
    • 恢复数据及配置至新gitlab主服务器

    chown git:git 1564156142_2019_07_26_10.4.3_gitlab_backup.tar
    gitlab-rake gitlab:backup:restore backup=timestamp #timesstamp是指gitlab备份包的文件名前面的一串数字,如1564156142
    # 如报下面的错误就是文件权限问题导致的

    Unpacking backup ... tar: 1564156142_2019_07_26_10.4.3_gitlab_backup.tar: Cannot open: Permission denied
    tar: Error is not recoverable: exiting now

    
    
    cp -f  /mnt/gitlab-secrets.json  /etc/gitlab/
    cp -f /mnt/*key*  /etc/ssh/

     

    # key认证问题

    可能报错:

    报错情况1:(key没有从master复制过来)

    IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
    Someone could be eavesdropping on you right now (man-in-the-middle attack)!
    It is also possible that a host key has just been changed.
    The fingerprint for the ECDSA key sent by the remote host is
    SHA256:9DdK4jo9LPLg7snd/vueT3wI2dy0hb7CVYRRGOTU8TY.
    Please contact your system administrator.
    Add correct host key in /c/Users/cd/.ssh/known_hosts to get rid of this message.
    Offending ECDSA key in /c/Users/cd/.ssh/known_hosts:4
    ECDSA host key for git.tuandai888.com has changed and you have requested strict checking.
    Host key verification failed.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

     

    报错情况2:(从master复制过来的key权限没设置好)

    ssh_exchange_identification: Connection closed by remote host
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

     

    解决方法:

    把master的 /etc/ssh/*key* 文件全部复制到从节点来,并注意权限与master的设置一样,

    scp root@[master_IP]:/etc/ssh/*key* /etc/ssh

    chown root:ssh_keys ssh_host_ecdsa_key ssh_host_ed25519_key ssh_host_rsa_key

     

    • 重启gitlab服务,并验证

    gitlab-ctl restart 
    gitlab-rake  gitlab:check SANITIZE=true
    #检查新gitlab服务器刚刚导入的数据
    
    gitlab-ctl reconfigure
    
    • 验证新gitlab主服务器的用户,代码库,提交记录等等是否完整,测试各项操作

    • 递进升级到目前最新的稳定版本

    列出当前gitlab所有版本
    
     yum list gitlab-ce.x86_64  --showduplicates | sort -r 
     
    #先升级到当前安装主版本的最后一个子版本,再升级到下一个主版本的合适的子版本。
    #升级完一个版本后,确认无报错,数据正常,再升级到下一个版本。
     
    #下面就是从7.x.x升级到10.x.x的升级方法 
     yum install -y gitlab-ce-7.14.3-ce.1.el7 
      
     yum install -y gitlab-ce-8.17.8-ce.0.el7
     
     yum install -y gitlab-ce-9.5.9-ce.0.el7 
     
     yum install -y gitlab-ce-10.3.5-ce.0.el7 
    
    
    gitlab-ctl restart
  • 相关阅读:
    oracle闪回某个时间段的数据
    查询某个表某个字段重复记录急重复数量
    调用腾讯QQ启动
    MongoDB笔记(二):MongoDB下Shell的基本操作
    MongoDB笔记(一):MongoDB介绍及Windows下安装
    freemarker相关
    oracle获取时间毫秒数
    如何简单地理解Python中的if __name__ == '__main__'
    python套接字基本使用
    Mysql表的约束设计和关联关系设计
  • 原文地址:https://www.cnblogs.com/linkenpark/p/8405436.html
Copyright © 2011-2022 走看看