官方项目地址:https://github.com/goharbor/harbor
文档地址:https://goharbor.io/docs/latest/install-config/
本次安装的harbor版本是v2.11.0
在发布页下载离线安装包v2.11.0(也可以下载在线安装包,根据自己实际需求选择,建议使用离线安装包,因为通常来说部署速度更快)
安装前需要满足以下官方给出的条件
硬件
下表列出了部署 Harbor 的最低和推荐硬件配置。
资源 | 最低限度 | 受到推崇的 |
---|---|---|
中央处理器 | 2 CPU | 4 CPU |
内存 | 4GB | 8 GB |
磁盘 | 40 GB | 160 GB |
软件
下表列出了目标主机上必须安装的软件版本。
软件 | 版本 | 描述 |
---|---|---|
Docker 引擎 | 版本 20.10.10-ce+ 或更高版本 | 有关安装说明,请参阅 Docker Engine 文档 |
Docker 组成 | docker-compose(v1.18.0+)或 docker compose v2(docker-compose-plugin) | 有关安装说明,请参阅 Docker Compose 文档 |
OpenSSL | 最新内容优先 | 用于生成Harbor的证书和密钥 |
网络端口
Harbor 要求目标主机上打开以下端口。
港口 | 协议 | 描述 |
---|---|---|
443 | HTTPS | Harbor 门户和核心 API 在此端口接受 HTTPS 请求。您可以在配置文件中更改此端口。 |
4443 | HTTPS | 连接到 Harbor 的 Docker Content Trust 服务。您可以在配置文件中更改此端口。 |
80 | HTTP | Harbor 门户和核心 API 在此端口接受 HTTP 请求。您可以在配置文件中更改此端口。 |
进入服务器的ssh后台界面。
把下载好的离线安装包上传到用户目录下
然后解压该离线安装包
tar -zxvf harbor-offline-installer-v2.11.0.tgz
进入解压出来的harbor文件夹,harbor.yml.tmpl重命名为harbor.yml并修改yml配置文件
#进入文件夹 cd harbor #修改文件名 cp harbor.yml.tmpl harbor.yml #打开配置文件 nano harbor.yml #修改主机名 hostname: reg.mydomain.com #如果启用ssl访问,需要提前申请ssl证书上传到服务器并在这两行指定证书和密钥 certificate: /your/certificate/path private_key: /your/private/key/path #在此处修改web后台admin管理员的初始密码 harbor_admin_password: Harbor12345 #在此处修改数据库的管理员密码 database: # The password for the root user of Harbor DB. Change this before any production use. password: root123 #其他内容根据实际需要修改即可
配置文件修改好后执行安装脚本
sudo ./install.sh
如果安装成功了即可在浏览器输入IP地址打开web后台,默认的管理员用户名和密码为admin和Harbor12345
这里贴出安装脚本执行过程
root@harbor:/home/yumo/harbor# ./install.sh [Step 0]: checking if docker is installed ... Note: docker version: 26.1.4 [Step 1]: checking docker-compose is installed ... Note: Docker Compose version v2.27.1 [Step 2]: loading Harbor images ... Loaded image: goharbor/harbor-core:v2.11.0 Loaded image: goharbor/harbor-db:v2.11.0 Loaded image: goharbor/nginx-photon:v2.11.0 Loaded image: goharbor/trivy-adapter-photon:v2.11.0 Loaded image: goharbor/redis-photon:v2.11.0 Loaded image: goharbor/registry-photon:v2.11.0 Loaded image: goharbor/prepare:v2.11.0 Loaded image: goharbor/harbor-portal:v2.11.0 Loaded image: goharbor/harbor-log:v2.11.0 Loaded image: goharbor/harbor-jobservice:v2.11.0 Loaded image: goharbor/harbor-registryctl:v2.11.0 Loaded image: goharbor/harbor-exporter:v2.11.0 [Step 3]: preparing environment ... [Step 4]: preparing harbor configs ... prepare base dir is set to /home/yumo/harbor Generated configuration file: /config/portal/nginx.conf Generated configuration file: /config/log/logrotate.conf Generated configuration file: /config/log/rsyslog_docker.conf Generated configuration file: /config/nginx/nginx.conf Generated configuration file: /config/core/env Generated configuration file: /config/core/app.conf Generated configuration file: /config/registry/config.yml Generated configuration file: /config/registryctl/env Generated configuration file: /config/registryctl/config.yml Generated configuration file: /config/db/env Generated configuration file: /config/jobservice/env Generated configuration file: /config/jobservice/config.yml Generated and saved secret to file: /data/secret/keys/secretkey Successfully called func: create_root_cert Generated configuration file: /compose_location/docker-compose.yml Clean up the input dir Note: stopping existing Harbor instance ... WARN[0000] /home/yumo/harbor/docker-compose.yml: `version` is obsolete [Step 5]: starting Harbor ... WARN[0000] /home/yumo/harbor/docker-compose.yml: `version` is obsolete [+] Running 10/10 ✔ Network harbor_harbor Created 0.1s ✔ Container harbor-log Started 4.0s ✔ Container registry Started 6.4s ✔ Container registryctl Started 5.1s ✔ Container redis Started 6.7s ✔ Container harbor-portal Started 6.4s ✔ Container harbor-db Started 6.7s ✔ Container harbor-core Started 8.0s ✔ Container nginx Started 9.4s ✔ Container harbor-jobservice Started 9.9s ✔ ----Harbor has been installed and started successfully.----
-----------------------------------------------------------
如果重启服务器后发现harbor网页后台进不去,可到安装目录下用root用户权限执行以下命令
cd harbor docker-compose start #配置文件里的所有容器会启动,以下内容是执行后输出的 WARN[0000] /home/yumo/harbor/docker-compose.yml: `version` is obsolete [+] Running 5/5 ✔ Container harbor-db Started 0.9s ✔ Container registryctl Started 0.8s ✔ Container redis Started 1.0s ✔ Container nginx Started 0.9s ✔ Container harbor-jobservice Started