解压文件#
# tar -xf harbor-offline-installer-v2.0.2.tgz
# mv harbor /usr/local/
复制ssl证书#
# cp ~/install_harbor/ssl/* /usr/local/harbor/ssl/
# cd /usr/local/harbor/ssl
# chmod 600 harbor.test.com.crt harbor.test.com.key
# chmod 600 ca.crt ca.key
执行安装脚本#
# cd /usr/local/harbor/
# sudo ./install.sh --with-notary --with-clair --with-chartmuseum
创建开机启动脚本#
# vim /usr/lib/systemd/system/harbor.service
[Unit]
Description=Harbor Service
After=network.target
After=network-online.target
After=docker.service
Requires=network.target
Requires=network-online.target
Requires=docker.service
[Service]
Type=simple
ExecStart=/usr/local/harbor/harbor_startup.sh start
ExecStop=/usr/local/harbor/harbor_startup.sh stop
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
# systemctl daemon-loread
# systemctl enable harbor
创建执⾏脚本#
# cat /usr/local/harbor/harbor_startup.sh
#!/bin/sh
cd /usr/local/harbor
action=$1
if [[ $action = "start" ]];then
docker-compose down -v
docker-compose up -d
elif [[ $action = "stop" ]];then
docker-compose down -v
fi
# systemctl start harbor
更换 SSL 合法证书#
把证书⽂件拷贝到 /usr/local/harbor/ssl
ls -l /usr/local/harbor/ssl/cloud.com.crt
ls -l /usr/local/harbor/ssl/cloud.com.key
ls -l /usr/local/harbor/ssl/gsrsaovsslca2018.crt # CA 根证书
修改配置⽂件#
设置证书文件
# vim /usr/local/harbor/harbor.yml
# https related config
https:
# https port for harbor, default is 443
port: 443
# The path of cert and key files for nginx
certificate: /usr/local/harbor/ssl/cloud.com.crt
private_key: /usr/local/harbor/ssl/cloud.com.key
重新安装harbor#
# cd /usr/loca/harbor/
# sudo ./install.sh --with-notary --with-clair --with-chartmuseum
# systemctl restart harbor