项目地址
https://github.com/docker/compose
https://github.com/goharbor/harbor
下载
wget https://github.com/docker/compose/releases/download/1.26.0/docker-compose-Linux-x86_64
sudo mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
[rancher@rmaster02 ~]$ docker-compose versiondocker-compose version 1.26.0, build d4451659docker-py version: 4.2.1CPython version: 3.7.7OpenSSL version: OpenSSL 1.1.0l 10 Sep 2019[rancher@rmaster02 ~]$
[rancher@rmaster02 home]$ lltotal 488972-rw-r--r-- 1 root root 500705880 Jun 7 08:57 harbor-offline-installer-v2.0.0.tgzdrwx------. 2 login01 login01 62 Jan 11 13:41 login01drwx------ 4 rancher rancher 107 Jun 7 08:53 rancher[rancher@rmaster02 home]$ sudo tar xf harbor-offline-installer-v2.0.0.tgz[rancher@rmaster02 home]$ cd /home/harbor/[rancher@rmaster02 harbor]$ lltotal 491056-rw-r--r-- 1 root root 3361 May 11 18:47 common.sh-rw-r--r-- 1 root root 502808042 May 11 18:48 harbor.v2.0.0.tar.gz-rw-r--r-- 1 root root 7816 May 11 18:47 harbor.yml.tmpl-rwxr-xr-x 1 root root 2523 May 11 18:47 install.sh-rw-r--r-- 1 root root 11347 May 11 18:47 LICENSE-rwxr-xr-x 1 root root 1856 May 11 18:47 prepare[rancher@rmaster02 harbor]$
重命名 harbor.yml.tmpl 为 harbor.yml
修改文件内容
hostname: 192.168.11.101# http related confighttp:# port for http, default is 80. If https enabled, this port will redirect to https portport: 80# https related config#https:# https port for harbor, default is 443# port: 443# The path of cert and key files for nginx# certificate: /your/certificate/path# private_key: /your/private/key/path
开始部署
#开启helm仓库功能
./install.sh --with-trivy --with-chartmuseum
[root@harboor harbor]# ./install.sh --with-trivy --with-clair✖ Clair is deprecated please remove it from installation arguments !!!./install.sh --with-trivy
[root@rmaster02 ~]#[root@rmaster02 ~]# cd /home/harbor/[root@rmaster02 harbor]#[root@rmaster02 harbor]# lltotal 491056-rw-r--r-- 1 root root 3361 May 11 18:47 common.sh-rw-r--r-- 1 root root 502808042 May 11 18:48 harbor.v2.0.0.tar.gz-rw-r--r-- 1 root root 7818 Jun 7 09:03 harbor.yml-rwxr-xr-x 1 root root 2523 May 11 18:47 install.sh-rw-r--r-- 1 root root 11347 May 11 18:47 LICENSE-rwxr-xr-x 1 root root 1856 May 11 18:47 prepare[root@rmaster02 harbor]# ./install.sh --with-trivy --with-clair[root@rmaster02 harbor]# docker-compose psName Command State Ports------------------------------------------------------------------------------------------------------harbor-core /harbor/entrypoint.sh Up (health: starting)harbor-db /docker-entrypoint.sh Up (health: starting) 5432/tcpharbor-jobservice /harbor/entrypoint.sh Up (health: starting)harbor-log /bin/sh -c /usr/local/bin/ ... Up (health: starting) 127.0.0.1:1514->10514/tcpharbor-portal nginx -g daemon off; Up (health: starting) 8080/tcpnginx nginx -g daemon off; Up (health: starting) 0.0.0.0:80->8080/tcpredis redis-server /etc/redis.conf Up (health: starting) 6379/tcpregistry /home/harbor/entrypoint.sh Up (health: starting) 5000/tcpregistryctl /home/harbor/start.sh Up (health: starting)[root@rmaster02 harbor]#

Harbor 主机关机重启后容器是无法顺序重启的
[root@harboor harbor]# docker-compose psName Command State Ports---------------------------------------------------------------------------------------------------harbor-core /harbor/entrypoint.sh Up (health: starting)harbor-db /docker-entrypoint.sh 96 13 Exit 137harbor-jobservice /harbor/entrypoint.sh Exit 137harbor-log /bin/sh -c /usr/local/bin/ Up (healthy) 127.0.0.1:1514->10514/tcp...harbor-portal nginx -g daemon off; Exit 128nginx nginx -g daemon off; Exit 128redis redis-server Exit 128/etc/redis.confregistry /home/harbor/entrypoint.sh Exit 137registryctl /home/harbor/start.sh Exit 137trivy-adapter /home/scanner/entrypoint.sh Exit 137[root@harboor harbor]#
解决方式1 手动全部关闭容器,再手动启动一次
[root@harboor harbor]# docker-compose down -vStopping harbor-core ... doneStopping harbor-log ... doneRemoving nginx ... doneRemoving harbor-jobservice ... doneRemoving harbor-core ... doneRemoving trivy-adapter ... doneRemoving registryctl ... doneRemoving harbor-portal ... doneRemoving harbor-db ... doneRemoving registry ... doneRemoving redis ... doneRemoving harbor-log ... doneRemoving network harbor_harbor[root@harboor harbor]# docker-compose up -dCreating network "harbor_harbor" with the default driverCreating harbor-log ... doneCreating harbor-db ... doneCreating redis ... doneCreating harbor-portal ... doneCreating registry ... doneCreating registryctl ... doneCreating trivy-adapter ... doneCreating harbor-core ... doneCreating harbor-jobservice ... doneCreating nginx ... done[root@harboor harbor]# docker-compose psName Command State Ports---------------------------------------------------------------------------------------------------harbor-core /harbor/entrypoint.sh Up (health: starting)harbor-db /docker-entrypoint.sh 96 13 Up (health: starting)harbor-jobservice /harbor/entrypoint.sh Up (health: starting)harbor-log /bin/sh -c /usr/local/bin/ Up (health: starting) 127.0.0.1:1514->10514/tcp...harbor-portal nginx -g daemon off; Up (health: starting)nginx nginx -g daemon off; Up (health: starting) 0.0.0.0:80->8080/tcpredis redis-server Up (health: starting)/etc/redis.confregistry /home/harbor/entrypoint.sh Up (health: starting)registryctl /home/harbor/start.sh Up (health: starting)trivy-adapter /home/scanner/entrypoint.sh Up (health: starting)[root@harboor harbor]#
解决方式2 编写systemctl服务来管理harbor服务启动
vi /etc/systemd/system/harbor.service#####################[Unit]Description=HarborAfter=docker.service systemd-networkd.service systemd-resolved.serviceRequires=docker.serviceDocumentation=http://github.com/goharbor/harbor[Service]Type=simpleRestart=on-failureRestartSec=5ExecStart=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml upExecStop=/usr/local/bin/docker-compose -f /opt/harbor/docker-compose.yml down[Install]WantedBy=multi-user.target#####################[root@harboor harbor]# systemctl enable harbor.serviceCreated symlink from /etc/systemd/system/multi-user.target.wants/harbor.service to /etc/systemd/system/harbor.service.
上述操作假定你的harbor安装在/opt/harbor下
Harbor v2.2 及更高版本中支持Prometheus监控Harbor
https://blog.51cto.com/lidabai/5177735
启用harbor Prometheus监控配置
# metric:# enabled: false# port: 9090# path: /metrics
导入 grafana面板
https://grafana.com/grafana/dashboards/?search=harbor
