背景:
在访问harbor镜像仓库时提示报错如下:
问题分析:
根据提供的报错内容来看时harbor服务的nginx组件服务异常了的,导致无法访问harbor服务,查看harbor服务结果如下:
service@harbor:~/harbor$ docker-compose ps
Name Command State Ports
-----------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver /harbor/start.sh Up
harbor-core /harbor/start.sh Up
harbor-db /entrypoint.sh postgres Up 5432/tcp
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c /usr/local/bin/ ... Up 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Restarting
nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp
redis docker-entrypoint.sh redis ... Up 6379/tcp
registry /entrypoint.sh /etc/regist ... Up 5000/tcp
registryctl /harbor/start.sh Up
根据docker-compose ps查询的内容来看,是harbor-portal组件服务异常了,导致了nginx组件服务也异常了。
这时候查看harbor服务各个组件的健康状态情况,通过docker ps服务查看
service@harbor:~/harbor$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3fc9f7342c5d goharbor/nginx-photon:v1.7.1 "nginx -g 'daemon ..." 3 months ago Up 13 hours (unhealthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx
6eee31ef2bfc goharbor/harbor-jobservice:v1.7.1 "/harbor/start.sh" 3 months ago Up 13 hours harbor-jobservice
321ef98c530a goharbor/harbor-portal:v1.7.1 "nginx -g 'daemon ..." 3 months ago Restarting (1) 6 hours ago harbor-portal
fed5f6eaf486 goharbor/harbor-core:v1.7.1 "/harbor/start.sh" 3 months ago Up 13 hours (healthy) harbor-core
122bbc2f6b56 goharbor/harbor-registryctl:v1.7.1 "/harbor/start.sh" 3 months ago Up 13 hours (healthy) registryctl
7be0ed1ad358 goharbor/harbor-db:v1.7.1 "/entrypoint.sh po..." 3 months ago Up 13 hours (healthy) 5432/tcp harbor-db
2448c27d1db9 goharbor/registry-photon:v2.6.2-v1.7.1 "/entrypoint.sh /e..." 3 months ago Up 13 hours (healthy) 5000/tcp registry
d7a2691f9a2c goharbor/harbor-adminserver:v1.7.1 "/harbor/start.sh" 3 months ago Up 13 hours (healthy) harbor-adminserver
d987bcb50630 goharbor/redis-photon:v1.7.1 "docker-entrypoint..." 3 months ago Up 13 hours 6379/tcp redis
d7df267a0dc9 goharbor/harbor-log:v1.7.1 "/bin/sh -c /usr/l..." 3 months ago Up 13 hours (healthy) 127.0.0.1:1514->10514/tcp harbor-log
这里可以发现nginx处于unhealthy,不健康的状态。
这时候需要分析harbor-portal组件服务为什么报错了,因为harbor使用了syslog服务作为存放日志,所以我们只需要到/var/log/harbor目录下找到对应的服务日志文件查看即可。
service@harbor:/var/log/harbor$ tail -1000f portal.log
........
Jun 4 03:58:54 localhost portal[119121]: 2024/06/03 19:58:54 [emerg] 1#0: mkdir() "/etc//nginx/client_body_temp" failed (13: Permission denied)
Jun 4 03:58:54 localhost portal[119121]: nginx: [emerg] mkdir() "/etc//nginx/client_body_temp" failed (13: Permission denied)
根据日志的提示是portal容器在运行的时候需要创建/etc/nginx/client_body_temp目录,但是提示权限不足无法创建。
问题解决方案:
这里的处理方案就是重新创建portal服务即可。
先停止harbor-portal服务
service@harbor:~/harbor$ docker-compose stop portal
Stopping harbor-portal ... done
查看是否已经停止掉harbor-portal服务
service@harbor:~/harbor$ docker-compose ps
Name Command State Ports
-------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver /harbor/start.sh Up
harbor-core /harbor/start.sh Up
harbor-db /entrypoint.sh postgres Up 5432/tcp
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c /usr/local/bin/ ... Up 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Exit 1
nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp
redis docker-entrypoint.sh redis ... Up 6379/tcp
registry /entrypoint.sh /etc/regist ... Up 5000/tcp
registryctl /harbor/start.sh Up
重建harbor-portal服务
service@harbor:~/harbor$ docker-compose up portal
Creating harbor-portal ... done
harbor-adminserver is up-to-date
registry is up-to-date
harbor-core is up-to-date
Creating harbor-portal ...
Attaching to harbor-portal
harbor-portal | WARNING: no logs are available with the 'syslog' log driver
harbor-portal exited with code 0
验证harbor-portal服务是否恢复,nginx服务是否也是恢复了
service@harbor:~/harbor$ docker-compose ps
Name Command State Ports
------------------------------------------------------------------------------------------------------------------------------
harbor-adminserver /harbor/start.sh Up
harbor-core /harbor/start.sh Up
harbor-db /entrypoint.sh postgres Up 5432/tcp
harbor-jobservice /harbor/start.sh Up
harbor-log /bin/sh -c /usr/local/bin/ ... Up 127.0.0.1:1514->10514/tcp
harbor-portal nginx -g daemon off; Up 80/tcp
nginx nginx -g daemon off; Up 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp, 0.0.0.0:80->80/tcp
redis docker-entrypoint.sh redis ... Up 6379/tcp
registry /entrypoint.sh /etc/regist ... Up 5000/tcp
registryctl /harbor/start.sh Up
service@harbor:~/harbor$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d729ec76f0c goharbor/harbor-portal:v1.7.1 "nginx -g 'daemon ..." 2 minutes ago Up 2 minutes (healthy) 80/tcp harbor-portal
3fc9f7342c5d goharbor/nginx-photon:v1.7.1 "nginx -g 'daemon ..." 3 months ago Up 14 hours (healthy) 0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp, 0.0.0.0:4443->4443/tcp nginx
6eee31ef2bfc goharbor/harbor-jobservice:v1.7.1 "/harbor/start.sh" 3 months ago Up 14 hours harbor-jobservice
fed5f6eaf486 goharbor/harbor-core:v1.7.1 "/harbor/start.sh" 3 months ago Up 14 hours (healthy) harbor-core
122bbc2f6b56 goharbor/harbor-registryctl:v1.7.1 "/harbor/start.sh" 3 months ago Up 14 hours (healthy) registryctl
7be0ed1ad358 goharbor/harbor-db:v1.7.1 "/entrypoint.sh po..." 3 months ago Up 14 hours (healthy) 5432/tcp harbor-db
2448c27d1db9 goharbor/registry-photon:v2.6.2-v1.7.1 "/entrypoint.sh /e..." 3 months ago Up 14 hours (healthy) 5000/tcp registry
d7a2691f9a2c goharbor/harbor-adminserver:v1.7.1 "/harbor/start.sh" 3 months ago Up 14 hours (healthy) harbor-adminserver
d987bcb50630 goharbor/redis-photon:v1.7.1 "docker-entrypoint..." 3 months ago Up 14 hours 6379/tcp redis
d7df267a0dc9 goharbor/harbor-log:v1.7.1 "/bin/sh -c /usr/l..." 3 months ago Up 14 hours (healthy) 127.0.0.1:1514->10514/tcp harbor-log
这时候发现nginx服务也是healthy状态了,然后去浏览器上访问一下:
然后去输入账号密码即可。
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » harbor1.7.1的访问报错502 bad gateway
发表评论 取消回复