zoukankan      html  css  js  c++  java
  • gitlab8.8.5迁移记录

    一、需求背景
    1. 目前Gitlab部署在199服务器,199服务器为Centos系统,目前作用为部署Gitlab,不方便维护,浪费资源;
    2. 计划迁移至246服务器上的虚拟机中,统一管理;
    3. 目前246服务器部署有Nexus3、SonarQube、FTP、开发/测试环境虚拟机、ELK虚拟机、PHP测试虚拟机等
     
    二、迁移方案
    1. 在246服务器搭建249虚拟机,安装与199服务器同版本的Gitlab
    2. 备份199服务器上的gitlab
    3. 在249虚拟机恢复199服务器的gitlab备份
    4. 停用199服务器
    5. 将249虚拟机的IP修改为199
     
    三、方案验证记录
    1. 搭建249虚拟机,使用Centos7.7版本,进行最小安装
    2. 安装Gitlab8.8.5版本,与199服务器上的Gitlab版本一致
    # rpm -ivh gitlab-ce-8.8.5-ce.1.el7.x86_64.rpm
    #修改访问地址 # vi /etc/gitlab/gitlab.rb external_url 'http://192.168.1.249'
    #更新配置(配置变更时使用)
    # gitlab-ctl reconfigure
    3. 备份199服务器上的Gitlab到本地
    #备份,会在/var/opt/gitlab/backups目录下生成备份文件,例如:1595571207_gitlab_backup.tar 
    #gitlab-rake gitlab:backup:create
    #备份配置文件 /etc/gitlab/gitlab-secrets.json
    #密钥信息,访问旧项目需要 /etc/gitlab/gitlab.rb
    #配置文件须备份 /var/opt/gitlab/nginx/conf
    #nginx配置文件,使用默认nginx则不需要 /etc/postfix/main.cf
    #postfix 邮件配置备份
    4. 恢复备份到249服务器
    #上传gitlab-secrets.json覆盖249服务器上的/etc/gitlab/gitlab-secrets.json文件 
    #上传备份文件到249服务器上的/var/opt/gitlab/backups目录
    #恢复备份(恢复1595571207_gitlab_backup.tar
    # gitlab-rake gitlab:backup:restore BACKUP=1595571207
    #更新配置 # gitlab-ctl reconfigure
    5. 验证
    访问http://192.168.1.249,使用199服务器上的Gitlab用户登录 使用yqkj-common-base验证是否可正常clone,push 验证通过,可查看到项目历史,修改后成功push
     
    0
     
    6. 升级Gitlab(未执行)
    #升级到13.7.4版本 
    #生成249虚拟机快照(方便失败时恢复) 
    #关闭gitlab服务 # gitlab-ctl stop         
    #备份 
    # gitlab-rake gitlab:backup:create         
    #安装,安装时选择升级 
    # rpm -ivh gitlab-ce-13.7.4-ce.0.el7.x86_64.rpm 
    #安装的过程中可能会出现报错 
    #Error executing action `run` on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data/repositories]' 
    #解决方法为
     # chmod 2770 /var/opt/gitlab/git-data/repositories 
    #安装成功后重新加载配置并启动 
    # gitlab-ctl reconfigure
     # gitlab-ctl restart
    四、汉化(汉化包无13.X版本,暂时不进行汉化)
    说明:
     gitlab中文社区版的项目,v7-v8.8是由Larry Li发起的“GitLab 中文社区版项目”(https://gitlab.com/larryli/gitlab), 
    从 v8.9 之后,@xhang 开始继续该汉化项目(https://gitlab.com/xhang/gitlab)。 
     4.1 停止gitlab服务 gitlab-ctl stop  
    4.2 切换到gitlab汉化包所在的目录(即步骤二获取的汉化版gitlab)  cd /root/gitlab  
    4.3 比较汉化标签和原标签,导出 patch 用的 diff 文件到/root下  git diff v10.0.2 v10.0.2-zh > ../10.0.2-zh.diff  
    4.4 回到/root目录 cd  
    4.5 将10.0.2-zh.diff作为补丁更新到gitlab中  yum install patch -y patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < 10.0.2-zh.diff #不停回车 
     4.6 启动gitlab gitlab-ctl start  4.7 重新配置gitlab  gitlab-ctl reconfigure
    五、Gitlab常用命令
    #查看gitlab的版本 
    # head -1 /opt/gitlab/version-manifest.txt 
    #更新配置 
    # gitlab-ctl reconfigure 
    #查看状态 
    # gitlab-ctl status 
    #重启 
    # gitlab-ctl restart 
    #关闭 
    # gitlab-ctl stop 
    #启动 
    # gitlab-ctl start 
    #监控 
    # gitlab-ctl tail 
    #监控unicorn日志
     # gitlab-ctl tail unicorn 
    #备份 
    # gitlab-rake gitlab:backup:create 
    #恢复备份(恢复1595571207_gitlab_backup.tar) 
    # gitlab-rake gitlab:backup:restore BACKUP=1595571207
     
    六、补充说明
    # 过程中使用到的命令
    scp  root@192.168.1.199:/etc/postfix/main.cf  root@192.168.1.249:/opt/gitlab/main.cf
    scp  root@192.168.1.199:/etc/gitlab/gitlab.rb   root@192.168.1.249:/etc/gitlab/gitlab.rb 
    scp  root@192.168.1.199:/etc/gitlab/gitlab-secrets.json  root@192.168.1.249:/etc/gitlab/gitlab-secrets.json
    scp  root@192.168.1.199:/var/opt/gitlab/backups/1613609741_gitlab_backup.tar  root@192.168.1.249:/var/opt/gitlab/backups/1613609741_gitlab_backup.tar
    scp  root@192.168.1.199:/var/opt/gitlab/nginx/conf  root@192.168.1.249:/var/opt/gitlab/nginx/conf
    
    /etc/gitlab/gitlab-secrets.json  #密钥信息,访问旧项目需要
    /etc/gitlab/gitlab.rb            #配置文件须备份
    /var/opt/gitlab/nginx/conf       #nginx配置文件,使用默认nginx则不需要
    /etc/postfix/main.cf           #postfix 邮件配置备份
    
    #恢复备份
    # gitlab-rake gitlab:backup:restore BACKUP=1613609741
    #更新配置
    # gitlab-ctl reconfigure
  • 相关阅读:
    prometheus 文档
    go
    nginx
    python使用xlrd读取合并单元格
    python使用xlrd模块读取Excel
    创建Excel文件:ModuleNotFoundError: No module named 'openpyxl'
    openpyxl模块安装时报错: You are using pip version 19.2.3, however version 20.0.2 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    Python定义字典函数报错TypeError: takes 0 positional arguments but 1 was given
    Mysql--information_scherma(虚拟库)
    day07--MySQL索引
  • 原文地址:https://www.cnblogs.com/weijs/p/14421790.html
Copyright © 2011-2022 走看看