centos harbor 安装与踩坑

centos harbor 安装与踩坑

centos7 harbor 安装流程以及遇到的坑



前言

harbor为企业级的docker镜像仓库,可结合kubernetes作为其后端仓库。harbor镜像仓库为VMware产品,harbor仓库较其他仓库软件的优点有:审计管控、权限分配等。为企业私库的首选。


提示:以下是本篇文章正文内容,下面案例可供参考

1.环境准备

本次演示环境,我是在虚拟机Linux Centos7上操作,以下是安装的软件及版本:

Docker:version 19.03.13
Docker-compose: version 1.27.4
Harbor: version 2.1.1
安装过程略过~~~

2.下载离线包

下载地址:
官方网站:https://goharbor.io/
官方开源:https://github.com/goharbor/harbor
下载离线包地址:https://github.com/goharbor/harbor/releases
centos harbor 安装与踩坑


3.解压安转包

下载地址:
tar -zxvf harbor-offline-installer-v2.1.1.tgz
cd harbor
里面会有一个harbor.yml.tmpl配置文件模版
我们cp一下
cp harbor.yml.tmpl harbor.yml
vim harbor.yml
centos harbor 安装与踩坑
修改完成后 wq保存。

执行 ./prepare 检查一下配置
执行 ./install.sh 开始安装
centos harbor 安装与踩坑
出现这个就算成功啦~~~~


4.可能遇到的坑

(1)按照上面步骤安装后发现访问主页 502 Bad Gateway
检查docker 状态
docker ps -a
centos harbor 安装与踩坑
发现nginx容器异常。。。
我们进入容器看看 docker exec -it 5f23bda73d4c bash
进入后输入nginx -t 检测nginx配置
centos harbor 安装与踩坑
显示正常。好吧我门回去看看harbor的日志。
cd /var/log/harbor/
因为是nginx服务有问题,所以我们看看proxy.log
tail -f proxy.log
提示报错
centos harbor 安装与踩坑
提示无法链接upstream
猜测可能是防火墙的问题
我们检查一下防火墙
systemctl status firewalld.service
发现运行中
我们把防火墙关闭试试
systemctl stop firewalld.service #关闭防火墙
systemctl disable firewalld.service #设置开机不自动启动防火墙
然后cd harbor的目录
service docker restart #关闭防火墙之后docker需要重启
docker-compose stop #然后关闭
docker-compose up -d #再启动一下看看
nice!!!
centos harbor 安装与踩坑

(2)出现错误ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule
centos harbor 安装与踩坑
ERROR: Failed to Setup IP tables: Unable to enable SKIP DNAT rule: (iptables failed: iptables --wait -t nat -I DOCKER -i br-2add1a39bc5d -j RETURN: iptables: No chain/target/match by that name.

原因是关闭防火墙之后docker需要重启,执行以下命令重启docker即可:

service docker restart


总结

出现错误可以多查看日志,排除相关问题~~~