Harbor版本升级到2.6.x详细步骤说明

Harbor版本升级到2.6.x详细步骤说明

1、前提

参考地址

harbor低版本存在漏洞,需要把版本升级到 2.5.x以上
目前我使用的版本为:v1.10.4

由于V1.10.4无法直接升级到 2.6.0,需要先升级到 2.4.0,再升级到 2.6.0

1.1、需要明确的东西

1、当前harbor文件的路径
2、harbor data安装路径

例如:
harbor文件的路径为:/home/harbor/
data的路径为默认的 /data

2、开始操作

2.1 下载安装包

wget https://github.com/goharbor/harbor/releases/download/v2.4.0/harbor-offline-installer-v2.4.0.tgz
wget https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz

2.2 备份防止丢失

备份当前版本的harbor安装文件

# 1、进入1.10.2的安装目录,将1.10.2停止掉
[root@localhost ~]# cd /home/harbor/harbor
docker-compose down
Stopping nginx             ... done
Stopping harbor-jobservice ... done
Stopping harbor-core       ... done
Stopping harbor-portal     ... done
Stopping redis             ... done
...
Removing network harbor_harbor

#2、备份1.10.2的安装包,方便回退
[root@localhost ~]# cd /home/harbor/
[root@localhost harbor]# ls
harbor  harbor-offline-installer-v2.4.0.tgz  harbor-offline-installer-v2.6.0.tgz
[root@localhost harbor]# mkdir /my_backup_dir
[root@localhost harbor]# mv harbor /my_backup_dir/harbor-v1.10.2

#3、备份1.10.2的database,方便回退
[root@localhost ~]# cp -r /data/database /my_backup_dir/

2.3 解压安装 2.4.0版本

[root@localhost harbor]# ls
harbor-offline-installer-v2.4.0.tgz  harbor-offline-installer-v2.6.0.tgz

#1、解压2.4.0的安装包
[root@localhost harbor]# tar zxf harbor-offline-installer-v2.4.0.tgz
#2、加载2.4.0需要的镜像
[root@localhost harbor]# cd harbor
[root@localhost harbor]# docker image load -i harbor.v2.4.0.tar.gz
#3、将旧的harbor.yml放置到/root目录下
[root@localhost harbor]# cp -a /my_backup_dir/harbor-v1.10.2/harbor.yml /root

#4、执行升级操作
[root@localhost harbor]# docker run -it --rm -v /:/hostfs goharbor/prepare:v2.4.0 migrate -i /root/harbor.yml
migrating to version 2.0.0
migrating to version 2.1.0
migrating to version 2.2.0
migrating to version 2.3.0
migrating to version 2.4.0
Written new values to /root/harbor.yml

#5、将旧的harbor.yml拷贝到2.4.0的安装包中,并且运行 ./install
[root@localhost harbor]# cp -a /my_backup_dir/harbor-v1.10.2/harbor.yml ./
[root@localhost harbor]# ls
common.sh  harbor.v2.4.0.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@localhost harbor]# ./install.sh
...
...
[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registryctl   ... done
Creating harbor-portal ... done
Creating redis         ... done
Creating harbor-db     ... done
Creating registry      ... done
Creating harbor-core   ... done
Creating harbor-jobservice ... done
Creating nginx             ... done
✔ ----Harbor has been installed and started successfully.----

登录页面查看,点击关于,显示为:

版本 v2.4.0-d4affc2e

2.4 解压安装 2.6.0版本

# 1、进入2.4.0的安装目录,将2.4.0停止掉
[root@localhost ~]# cd /home/harbor/harbor
[root@localhost harbor]# docker-compose down
Stopping harbor-jobservice ... done
Stopping nginx             ... done
Stopping harbor-core       ... done
Stopping registry          ... done
...
Removing network harbor_harbor

#2、备份2.4.0的安装包
[root@localhost ~]# cd /home/harbor/
[root@localhost harbor]# ls
harbor  harbor-offline-installer-v2.4.0.tgz  harbor-offline-installer-v2.6.0.tgz

[root@localhost harbor]# mv harbor /my_backup_dir/harbor-v2.4.0

#3、解压2.6.0的安装包
[root@localhost harbor]# tar zxf harbor-offline-installer-v2.6.0.tgz
#4、加载2.6.0需要的镜像
[root@localhost harbor]# cd harbor
[root@localhost harbor]# docker image load -i harbor.v2.6.0.tar.gz
#5、执行升级操作
[root@localhost harbor]# docker run -it --rm -v /:/hostfs goharbor/prepare:v2.6.0 migrate -i /root/harbor.yml
migrating to version 2.5.0
migrating to version 2.6.0
Written new values to /root/harbor.yml

#5、将/root/harbor.yml拷贝到2.6.0的安装包中,并且运行 ./install
[root@aiops harbor]# cp -a /root/harbor.yml ./
[root@aiops harbor]# ls
common.sh  harbor.v2.6.0.tar.gz  harbor.yml  harbor.yml.tmpl  install.sh  LICENSE  prepare
[root@aiops harbor]# ./install.sh
...
Creating harbor-portal ... done
Creating redis         ... done
Creating registryctl   ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.---

登录页面查看,点击关于,显示为:

版本 v2.6.0-b035ca7c

你可能感兴趣的:(Deploy运维相关的,Docker,docker)