zoukankan      html  css  js  c++  java
  • Gitlab升级记

    一: 验证gitlab备份是否可用

           这里所使用的操作系统环境全部都基于Cetnos7, 防火墙以及selinux全部关闭。

    1. 另外找一台机器,安装与服务器版本相同的gitlab,根据原服务器数据的大小,来决定验证数据服务器磁盘的大小。避免因磁盘空间不足而无法正常恢复数据。

    •   配置yum源
    shell> vi /etc/yum.repos.d/gitlab-ce.repo
    
    [gitlab-ce]
    name=Gitlab CE Repository
    baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
    gpgcheck=0
    enabled=1
    • 安装指定版本
    shell> yum install gitlab-ce-11.2.3
    • 将原服务器的配置文件拷贝至新部署的机器上,然后进行配置; 
     1 #这里是我的 配置文件,这里我们使用了Windows AD来作为LDAP服务器
     2 external_url 'http://gitlab.mofangge.cc'
     3 gitlab_rails['ldap_enabled'] = true
     4  gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
     5    main: # 'main' is the GitLab 'provider ID' of this LDAP server
     6      label: 'LDAP'
     7      host: 'domainserver.mofangge.cc'
     8      port: 389
     9      uid: 'sAMAccountName'
    10      bind_dn: 'cn=gitadmin,cn=Users,dc=mofangge,dc=cc'
    11      password: 'ling4022@163.com'
    12      encryption: 'plain' # "start_tls" or "simple_tls" or "plain"
    13      verify_certificates: true
    14      active_directory: true
    15      allow_username_or_email_login: true
    16      lowercase_usernames: false
    17      block_auto_created_users: false
    18      base: 'OU=mofangge,DC=mofangge,DC=cc'
    19      user_filter: ''
    20      group_base: 'OU=mofangge,DC=mofangge,DC=cc'
    21      sync_ssh_keys: false
    22 EOS
    23 gitlab_rails['manage_backup_path'] = true
    24 gitlab_rails['backup_path'] = "/opt/data/backups"
    25 gitlab_rails['backup_archive_permissions'] = 0644
    26 gitlab_rails['backup_keep_time'] = 604800
    27  git_data_dirs({
    28    "default" => {
    29      "path" => "/opt/data/git-data"
    30     }
    31  })
    32 unicorn['worker_processes'] = 4
    33 sidekiq['concurrency'] = 12
    34 postgresql['shared_buffers'] = "1024MB"
    35 postgresql['max_worker_processes'] = 8
    我的配置文件,仅供参考
    shell> grep -Ev "^$|^[#;]" /etc/gitlab/gitlab.rb
    shell> scp root@youserverip:/etc/gitlab/gitlab.rb /etc/gitlab/ #然后输入密码即可
    shell> gitlab-ctl reconfigure
    shell> gitlab-ctl status
    #然后这里将host 解析写在wineos下的hosts文件中,访问域名进行校验
    192.168.133.12  gitlab.mofangge.cc

    然后进行登录验证,如果能正常访问的话,接下来进行恢复工作

    二: 恢复数据

    将原备份文件拷贝到指定目录下。

    shell> scp root@192.168.200.27:/data/gitlabbackup/1589134406_2020_05_11_11.2.3_gitlab_backup.tar /opt/data/backups/
    #由于我自定义了文件名称,这里还需要重命名
    shell> mv /opt/data/backups/1589134406_2020_05_11_11.2.3_gitlab_backup.tar /opt/data/backups/1589134406_gitlab_backup.tar
    #查看验证
    shell> ls /opt/data/backups/
    #进行恢复
    shell> gitlab-rake gitlab:backup:restore BACKUP=1589134406
    #重启之后进行登录验证
    shell> gitlab-ctl restart

    这里登录之后,查看数据以及配置均为正常。校验数据没有问题之后,进行升级的模拟操作。

    三:进行升级

    gitlab具有版本帝之称,版本更新之快让人望而却步,由于我们想要适用gitlab ci等新功能,所以还是选择进行升级。

    这里我们可以参照官方建议的升级版本顺序进行选择,官方链接地址如:https://docs.gitlab.com/ee/policy/maintenance.html#upgrade-recommendations

    建议安装官方推荐的升级版本路径进行升级,避免踩坑。

    由于我目前的版本是11.2.3,这里我们先升级到11.11.8,然后升级到12.0.12,最后升级到现在的最新版本,12.10.3进行测试。希望能成功。

     这里我在准备虚拟机的阶段已经将所需要的安装包已经下载到本地了。接下来我们进行升级工作。

    [root@c7-node2 ~]# ll
    total 2492824
    -rw-r--r-- 1 root root 664112883 May 11 15:10 gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm  #第一次升级到的版本
    -rw-r--r-- 1 root root 444946400 May 11 15:10 gitlab-ce-11.2.3-ce.0.el7.x86_64.rpm   #现在版本
    -rw-r--r-- 1 root root 647345829 May 11 15:10 gitlab-ce-12.0.12-ce.0.el7.x86_64.rpm  #第二次升级到的版本
    -rw-r--r-- 1 root root 796237830 May 11 15:11 gitlab-ce-12.10.3-ce.0.el7.x86_64.rpm  #需要升级的最终版本
    [root@c7-node2 ~]# yum install gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm
    Loaded plugins: fastestmirror
    Examining gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm: gitlab-ce-11.11.8-ce.0.el7.x86_64
    Marking gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm as an update to gitlab-ce-11.2.3-ce.0.el7.x86_64
    Resolving Dependencies
    --> Running transaction check
    ---> Package gitlab-ce.x86_64 0:11.2.3-ce.0.el7 will be updated
    ---> Package gitlab-ce.x86_64 0:11.11.8-ce.0.el7 will be an update
    --> Finished Dependency Resolution
    
    Dependencies Resolved
    
    ====================================================================================================================================================================================
     Package                             Arch                             Version                                    Repository                                                    Size
    ====================================================================================================================================================================================
    Updating:
     gitlab-ce                           x86_64                           11.11.8-ce.0.el7                           /gitlab-ce-11.11.8-ce.0.el7.x86_64                           1.5 G
    
    Transaction Summary
    ====================================================================================================================================================================================
    Upgrade  1 Package
    
    Total size: 1.5 G
    Is this ok [y/d/N]:

    出现如下提示,则证明升级成功了。

    sudo gitlab-ctl restart postgresql
    
    gitlab Reconfigured!
    Restarting previously running GitLab services
    ok: run: alertmanager: (pid 20783) 1s
    ok: run: gitaly: (pid 20597) 5s
    ok: run: gitlab-monitor: (pid 20658) 4s
    ok: run: gitlab-workhorse: (pid 20627) 5s
    ok: run: logrotate: (pid 20806) 1s
    ok: run: nginx: (pid 20812) 0s
    ok: run: node-exporter: (pid 20647) 5s
    ok: run: postgres-exporter: (pid 20796) 1s
    ok: run: postgresql: (pid 1146) 6862s
    ok: run: prometheus: (pid 20676) 3s
    ok: run: redis: (pid 20325) 52s
    ok: run: redis-exporter: (pid 20666) 4s
    ok: run: sidekiq: (pid 20823) 1s
    ok: run: unicorn: (pid 20830) 0s
    
         _______ __  __          __
        / ____(_) /_/ /   ____ _/ /_
       / / __/ / __/ /   / __ `/ __ 
      / /_/ / / /_/ /___/ /_/ / /_/ /
      \____/_/\__/_____/\__,_/_.___/
      
    
    Upgrade complete! If your GitLab server is misbehaving try running
      sudo gitlab-ctl restart
    before anything else.
    If you need to roll back to the previous version you can use the database
    backup made during the upgrade (scroll up for the filename).
    
      Verifying  : gitlab-ce-11.11.8-ce.0.el7.x86_64                                                                                                                                1/2 
      Verifying  : gitlab-ce-11.2.3-ce.0.el7.x86_64                                                                                                                                 2/2 
    
    Updated:
      gitlab-ce.x86_64 0:11.11.8-ce.0.el7                                                                                                                                               
    
    Complete!

    然后进行登录校验,这里我依然使用LDAP账户进行登录,因为我之前没有standard账户,root下是没有数据的。

    然后继续进行升级,这次升级到10.0.12版本,因为11.11.8是11的最后一个版本。也是升级的必须步骤。

    [root@c7-node2 ~]# yum install gitlab-ce-12.0.12-ce.0.el7.x86_64.rpm -y
    #这里出现的结果跟上次一样,就证明升级成功
    Upgrade complete! If your GitLab server is misbehaving try running
      sudo gitlab-ctl restart
    before anything else.
    If you need to roll back to the previous version you can use the database
    backup made during the upgrade (scroll up for the filename).
    
      Verifying  : gitlab-ce-12.0.12-ce.0.el7.x86_64                                                                                                                                1/2 
      Verifying  : gitlab-ce-11.11.8-ce.0.el7.x86_64                                                                                                                                2/2 
    
    Updated:
      gitlab-ce.x86_64 0:12.0.12-ce.0.el7                                                                                                                                               
    
    Complete!

    然后请继续进行登录和数据校验。有任何一个过程出问题,就需要考虑回滚。 数据最重要。

    接下来,我将升级到最新版本,12.10.3。

    [root@c7-node2 ~]# yum install gitlab-ce-12.10.3-ce.0.el7.x86_64.rpm -y
    Loaded plugins: fastestmirror
    Examining gitlab-ce-12.10.3-ce.0.el7.x86_64.rpm: gitlab-ce-12.10.3-ce.0.el7.x86_64
    Marking gitlab-ce-12.10.3-ce.0.el7.x86_64.rpm as an update to gitlab-ce-12.0.12-ce.0.el7.x86_64
    Resolving Dependencies
    --> Running transaction check
    ---> Package gitlab-ce.x86_64 0:12.0.12-ce.0.el7 will be updated
    ---> Package gitlab-ce.x86_64 0:12.10.3-ce.0.el7 will be an update
    --> Finished Dependency Resolution

    出现如下界面,则证明升级成功,最后也可以通过gitlab-ctl status进行验证。

    Upgrade complete! If your GitLab server is misbehaving try running
      sudo gitlab-ctl restart
    before anything else.
    If you need to roll back to the previous version you can use the database
    backup made during the upgrade (scroll up for the filename).
    
      Verifying  : gitlab-ce-12.10.3-ce.0.el7.x86_64                                                                                                                                1/2 
      Verifying  : gitlab-ce-12.0.12-ce.0.el7.x86_64                                                                                                                                2/2 
    
    Updated:
      gitlab-ce.x86_64 0:12.10.3-ce.0.el7                                                                                                                                               
    
    Complete!
    [root@c7-node2 ~]# gitlab-ctl status
    run: alertmanager: (pid 17180) 13s; run: log: (pid 1707) 2186s
    run: gitaly: (pid 16392) 62s; run: log: (pid 10965) 1559s
    run: gitlab-exporter: (pid 17194) 13s; run: log: (pid 16224) 81s
    run: gitlab-workhorse: (pid 17196) 12s; run: log: (pid 11313) 1525s
    run: grafana: (pid 17209) 12s; run: log: (pid 11359) 1500s
    run: logrotate: (pid 17221) 11s; run: log: (pid 1699) 2186s
    run: nginx: (pid 17228) 11s; run: log: (pid 1703) 2186s
    run: node-exporter: (pid 17237) 11s; run: log: (pid 1697) 2186s
    run: postgres-exporter: (pid 17242) 10s; run: log: (pid 1705) 2186s
    run: postgresql: (pid 15614) 162s; run: log: (pid 1676) 2186s
    run: prometheus: (pid 17250) 10s; run: log: (pid 1709) 2186s
    run: redis: (pid 15956) 152s; run: log: (pid 1670) 2186s
    run: redis-exporter: (pid 17264) 9s; run: log: (pid 1693) 2186s
    run: sidekiq: (pid 17270) 9s; run: log: (pid 11303) 1526s
    run: unicorn: (pid 12625) 1299s; run: log: (pid 1688) 2186s

    最后给大家来一张升级成功的图片,以示鼓励。加油~~

    接下来大家可以在服务器端进行升级操作,如果服务器是虚拟机的话,建议先做快照,以便出问题时进行恢复,一定要做备份,数据最重要。

  • 相关阅读:
    模拟算法(八)
    迭代算法(七)
    试探法是一种委婉的做法(六)
    贪心算法并不贪婪(五)
    各个击破的分治算法(四)
    充分利用自己的递归算法(三)
    一起学Spring之Web基础篇
    C# 利用AForge进行摄像头信息采集
    一起学Spring之注解和Schema方式实现AOP
    一起学Spring之AOP
  • 原文地址:https://www.cnblogs.com/skymyyang/p/12870533.html
Copyright © 2011-2022 走看看