美文网首页
GitLab手册(备份/恢复/升级/降级/进程/日志)

GitLab手册(备份/恢复/升级/降级/进程/日志)

作者: 不敢预言的预言家 | 来源:发表于2022-07-03 21:58 被阅读0次

    系统版本CentOS release 7.8,4核/8G/150G

    配置文件

    • /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml
    • /etc/gitlab/gitlab.rb

    常用命令

    # 启动
    gitlab-ctl start [xx]
    
    # 停止
    gitlab-ctl stop  [xx]     
    
    # 重启
    gitlab-ctl restart
    
    # 状态
    gitlab-ctl status 
    
    # 重新配置
    gitlab-ctl reconfigure 
    
    # 验证
    gitlab-ctl show-config 
    
    # 检查
    gitlab-rake gitlab:check SANITIZE=true
    
    # 实时日志
    gitlab-ctl tail
    
    # 控制台
    gitlab-rails console
    
    # 当前版本
    cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
    
    # runner命令
    gitlab-runner stop
    

    主要进程

    gitlab-ctl status

    进程 描述
    alertmanager Prometheus模块,告警模块,接收客户端发来的警报,处理后发送给接受者,支持email,webhook等
    gitaly 处理所有git操作
    gitlab-exporter python工具,用于命令行从gitlab导出各种数据集
    gitlab-kas GitLab Kubernetes Agent
    gitlab-workhorse 前端请求->nginx->gitlab-workhorse->puma
    grafana 可视化工具,仅用于监控展示
    logrotate 日志管理工具,分割,删除等等
    nginx nginx
    node-exporter node监控,Prometheus模块
    postgres-exporter postgres监控,Prometheus模块
    postgresql 关系数据库
    prometheus 开源监控解决方案
    puma ruby的web服务器
    redis redis
    redis-exporter redis监控,Prometheus模块
    sidekiq ruby中的消息队列,依赖redis
    unicorn web服务器,12.6之前的版本

    架构图上传失败,请自行度娘 gitlab架构图

    备份

    日志

    日志 描述
    /var/log/gitlab/gitlab-rails/production.log 每次请求的具体信息
    /var/log/gitlab/gitlab-rails/application.log 创建用户,项目等日志
    /var/log/gitlab/gitlab-rails/githost.log 错误请求日志
    /var/log/gitlab/gitlab-rails/sidekiq.log 后台任务日志
    /var/log/gitlab/gitlab-shellgitlab-shell.log 记录执行gitlab命令以及为项目添加ssh权限的日志文件
    /var/log/gitlab/unicorn/unicorn_stdout.log unicorn日志
    /var/log/gitlab/puma/puma_stdout.log puma日志

    恢复

    • https://docs.gitlab.com/ee/raketasks/restore_gitlab.html

    • 停止进程

      gitlab-ctl stop sidekiq
      gitlab-ctl stop puma
      # 低版本没有puma,有unicorn
      gitlab-ctl stop unicorn
      
    • 修改备份文件权限

      chmod 777 1656612331_2022_07_01_10.7.3-ee_gitlab_backup.tar
      
    • 恢复

      gitlab-rake gitlab:backup:restore BACKUP=1656662045_2022_07_01_14.0.12-ee
      
    • 启动所有进程

      gitlab-ctr start xx
      
    • 检查可用

      gitlab-rake gitlab:check SANITIZE=true
      

    降级

    • https://docs.gitlab.com/ee/update/package/downgrade.html
    • 必须有一份完整的旧版本备份文件才可以降级
    • 停止进程
      gitlab-ctl stop sidekiq
      
    • 卸载当前包
      yum remove gitlab-ee
      
    • 安装到要降级的版本
      yum install gitlab-ee-10.7.4 -y 
      
    • 重新配置,以前的配置文件不会删除
      gitlab-ctl reconfigure
      
    • 恢复备份
    • 启动进程并检查

    升级

    • 注意:“/”目录是要比当前使用率大一倍(如已使用50G,“/”最少要100G),备份以及安装rpm会占用空间

    制定升级路线

    升级到14.0.12

    • 升级前先检查当前版本是否正常使用

    • 采用了非停机的方式进行升级

    • 升级到14.0.12

      版本 命令
      10.7.3 current
      10.7.4 yum install gitlab-ee-10.7.4 -y
      10.7.5 yum install gitlab-ee-10.7.5 -y
      10.7.6 yum install gitlab-ee-10.7.6 -y
      10.7.7 yum install gitlab-ee-10.7.7 -y
      10.8.7 yum install gitlab-ee-10.8.7 -
      11.11.8 yum install gitlab-ee-11.11.8 -y
      12.0.12 yum install gitlab-ee-12.0.12 -y
      12.1.17 yum install gitlab-ee-12.1.17 -y
      12.10.14 yum install gitlab-ee-12.10.14 -y
      13.0.14 yum install gitlab-ee-13.0.14 -y
      13.1.11 yum install gitlab-ee-13.1.11 -y
      13.8.8 yum install gitlab-ee-13.8.8 -y
      13.12.15 yum install gitlab-ee-13.12.15 -y
      14.0.12 yum install gitlab-ee-14.0.12 -y
    • 每次升级后检查系统可用

      • gitlab-rake gitlab:check SANITIZE=true
      • web页面服务正常

    升级到14.3.6

    后台迁移任务

    • https://docs.gitlab.com/ee/update/#upgrading-to-later-14y-releases
    • 需要等后台迁移任务全部完成后才可以继续升级
    • 查看后台迁移任务 Menu > Admin,Monitoring> Background Migrations
    • 等没有Queued之后才可以
    • 如果项目很大迁移过程持续时间需要按天计算
    • 如果任务进度一直都是0.00%,检查sidekiq进程是否正常run

    升级ruby

    • https://docs.gitlab.com/ee/update/#upgrading-to-later-14y-releases
    • 需要升级 ruby到2.7.4及以上版本
      mkdir /tmp/ruby && cd /tmp/ruby
      curl --remote-name --location --progress-bar "https://cache.ruby-lang.org/pub/ruby/2.7/ruby-2.7.6.tar.gz"
      echo 'e7203b0cc09442ed2c08936d483f8ac140ec1c72e37bb5c401646b7866cb5d10 ruby-2.7.6.tar.gz' | sha256sum -c - && tar xzf ruby-2.7.6.tar.gz
      cd ruby-2.7.6
      
      ./configure --disable-install-rdoc --enable-shared
      make
      sudo make install
      

    完成以上后继续升级

    • yum install gitlab-ee-14.3.6 -y
    • 升级后仍有后台迁移任务

    升级到最终版本

    • 所有版本升级后都有后台迁移任务,等执行完成后才可以继续升级
    • 14.9.5 yum install gitlab-ee-14.9.5 -y
    • 14.10.5 yum install gitlab-ee-14.10.5 -y
    • 15.0.4 yum install gitlab-ee-15.0.4 -y
    • 15.1.1 yum install gitlab-ee-15.1.1 -y

    配置邮箱

    • https://blog.csdn.net/wizard_rp/article/details/121428907
    • /etc/gitlab/gitlab.rb
      gitlab_rails['smtp_enable'] = true
      gitlab_rails['smtp_address'] = "smtp.qq.com"
      gitlab_rails['smtp_port'] = 465
      gitlab_rails['smtp_user_name'] = "x50@qq.com"
      gitlab_rails['smtp_password'] = "x"
      gitlab_rails['smtp_domain'] = "qq.com"
      gitlab_rails['smtp_authentication'] = "login"
      gitlab_rails['smtp_enable_starttls_auto'] = true
      gitlab_rails['smtp_tls'] = true
      gitlab_rails['gitlab_email_from'] = "x50@qq.com"
      gitlab_rails['gitlab_email_reply_to'] = 'x50#qq.com'
      gitlab_rails['gitlab_email_display_name'] = 'x科技GitLab'
      
    • gitlab-ctl reconfigure
    • gitlab-ctl restart
    • 测试发送
      • gitlab-rails console
      • Notify.test_email("x09@qq.com","GitLab测试","内容").deliver_now

    其它配置

    修改语言

    个人用户 preferences-Preferences-Localization-Language

    外观修改

    • admin-Settings-Appearance
    • 修改favicon,登陆页等

    禁止CI/CD

    • admin-Settings-CI/CD
    • Continuous Integration and Deployment-Default to Auto DevOps pipeline for all projects

    常见问题处理

    500错误,Whoops, GitLab is taking too much time to respond.

    系统还没启动完成,等一会着

    500错误,ActionView::Template::Error (failed to parse loose object: invalid header)

    422错误

    清理浏览器缓存,重新打开浏览器登陆

    相关文章

      网友评论

          本文标题:GitLab手册(备份/恢复/升级/降级/进程/日志)

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