一、环境准备
1.关闭selinux
修改 vi /etc/selinux/config中的SELINUX=disabled
[root@localhost harbor]# more /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled #修改为disabled
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
二、下载安装包
百度云下载:
链接:https://pan.baidu.com/s/1CTYFnbET9psfQAjvnmZuVw
提取码:3yio
三、安装harbor-offline
3.1 上传安装包到服务器
[root@localhost hb]# ll
总用量 642184
-rw-r--r--. 1 root root 657593723 8月 3 2022 harbor-offline-installer-v2.4.3.tgz
[root@localhost hb]#
3.2 解压安装包
[root@localhost hb]# tar -xzvf harbor-offline-installer-v2.4.3.tgz
harbor/harbor.v2.4.3.tar.gz
harbor/prepare
harbor/LICENSE
harbor/install.sh
harbor/common.sh
harbor/harbor.yml.tmpl
[root@localhost hb]# ll
总用量 642184
drwxr-xr-x. 2 root root 122 4月 25 14:38 harbor
-rw-r--r--. 1 root root 657593723 8月 3 2022 harbor-offline-installer-v2.4.3.tgz
[root@localhost hb]# cd harbor
[root@localhost harbor]# ll
总用量 645676
-rw-r--r--. 1 root root 3361 8月 1 2022 common.sh
-rw-r--r--. 1 root root 661132890 8月 1 2022 harbor.v2.4.3.tar.gz
-rw-r--r--. 1 root root 9668 8月 1 2022 harbor.yml.tmpl
-rwxr-xr-x. 1 root root 2500 8月 1 2022 install.sh
-rw-r--r--. 1 root root 11347 8月 1 2022 LICENSE
-rwxr-xr-x. 1 root root 1881 8月 1 2022 prepare
[root@localhost harbor]# pwd
/opt/hb/harbor
[root@localhost harbor]#
3.3 备份、修改文件
[root@localhost harbor]# cp harbor.yml.tmpl harbor.yml #备份
[root@localhost harbor]#
[root@localhost harbor]# ll
总用量 645688
-rw-r--r--. 1 root root 3361 8月 1 2022 common.sh
-rw-r--r--. 1 root root 661132890 8月 1 2022 harbor.v2.4.3.tar.gz
-rw-r--r--. 1 root root 9668 4月 25 14:43 harbor.yml
-rw-r--r--. 1 root root 9668 8月 1 2022 harbor.yml.tmpl
-rwxr-xr-x. 1 root root 2500 8月 1 2022 install.sh
-rw-r--r--. 1 root root 11347 8月 1 2022 LICENSE
-rwxr-xr-x. 1 root root 1881 8月 1 2022 prepare
[root@localhost harbor]# vi harbor.yml #修改文件
hostname: 192.168.116.20 #修改为当前主机的IP或域名
#https: #注释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
3.4 移动harbor到/usr/local下
[root@localhost harbor]# cd ../
[root@localhost hb]# ll
总用量 642184
drwxr-xr-x. 2 root root 140 4月 25 14:46 harbor
-rw-r--r--. 1 root root 657593723 8月 3 2022 harbor-offline-installer-v2.4.3.tgz
[root@localhost hb]# \mv harbor /usr/local
[root@localhost hb]# cd /usr/local
[root@localhost local]# ll
总用量 0
drwxr-xr-x. 2 root root 6 4月 11 2018 bin
drwxr-xr-x. 2 root root 138 4月 25 11:42 docker
drwxr-xr-x. 2 root root 6 4月 11 2018 etc
drwxr-xr-x. 2 root root 6 4月 11 2018 games
drwxr-xr-x. 2 root root 140 4月 25 14:46 harbor
drwxr-xr-x. 2 root root 6 4月 11 2018 include
drwxr-xr-x. 2 root root 6 4月 11 2018 lib
drwxr-xr-x. 2 root root 6 4月 11 2018 lib64
drwxr-xr-x. 2 root root 6 4月 11 2018 libexec
drwxr-xr-x. 2 root root 6 4月 11 2018 sbin
drwxr-xr-x. 5 root root 49 4月 7 10:16 share
drwxr-xr-x. 2 root root 6 4月 11 2018 src
[root@localhost local]#
3.5 docker Compose安装
[root@localhost harbor]# curl -SL https://github.com/docker/compose/releases/download/v2.7.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:01 --:--:-- 0
100 24.5M 100 24.5M 0 0 2759k 0 0:00:09 0:00:09 --:--:-- 5704k
[root@localhost harbor]# cd /usr/local/bin/
[root@localhost bin]#
[root@localhost bin]# ll
总用量 25188
-rw-r--r--. 1 root root 25792512 4月 25 14:54 docker-compose
[root@localhost bin]# chmod +x /usr/local/bin/docker-compose
[root@localhost bin]#
3.6 安装opensshl
使用rpm -qa | grep openssl 检测是否安装,如果没有安装需要安装
3.7 安装harbor-offline-installer
[root@localhost harbor]# ./install.sh
[Step 0]: checking if docker is installed ...
Note: docker version: 19.03.9
[Step 1]: checking docker-compose is installed ...
Note: docker-compose version: 2.7.0
[Step 2]: loading Harbor images ...
c84d341a47f7: Loading layer [==================================================>] 37.68MB/37.68MB
0bce891d1746: Loading layer [==================================================>] 6.283MB/6.283MB
1562d8daaa10: Loading layer [==================================================>] 4.096kB/4.096kB
558678de660b: Loading layer [==================================================>] 3.072kB/3.072kB
27a4fb8f8d03: Loading layer [==================================================>] 91.21MB/91.21MB
f2f1ab285c2e: Loading layer [==================================================>] 12.65MB/12.65MB
1050b9c06f0d: Loading layer [==================================================>] 104.6MB/104.6MB
Loaded image: goharbor/trivy-adapter-photon:v2.4.3
dff4f5f43cae: Loading layer [==================================================>] 119.7MB/119.7MB
14051e1a30cb: Loading layer [==================================================>] 3.072kB/3.072kB
926d6abf9a96: Loading layer [==================================================>] 59.9kB/59.9kB
872ea29bae05: Loading layer [==================================================>] 61.95kB/61.95kB
Loaded image: goharbor/redis-photon:v2.4.3
b90d08bc3107: Loading layer [==================================================>] 7.668MB/7.668MB
Loaded image: goharbor/nginx-photon:v2.4.3
a3e0b41de875: Loading layer [==================================================>] 5.75MB/5.75MB
54a447a885ef: Loading layer [==================================================>] 5.928MB/5.928MB
0809cbb02a43: Loading layer [==================================================>] 14.47MB/14.47MB
448ee8eda80b: Loading layer [==================================================>] 29.29MB/29.29MB
584f590108df: Loading layer [==================================================>] 22.02kB/22.02kB
d8b2f53d7045: Loading layer [==================================================>] 14.47MB/14.47MB
Loaded image: goharbor/notary-signer-photon:v2.4.3
ac301ae337a3: Loading layer [==================================================>] 168.7MB/168.7MB
1439def47fef: Loading layer [==================================================>] 67.34MB/67.34MB
df3e3323e48b: Loading layer [==================================================>] 2.56kB/2.56kB
bfe3d8e6f350: Loading layer [==================================================>] 1.536kB/1.536kB
1e9fd9410af8: Loading layer [==================================================>] 12.29kB/12.29kB
c57553e10908: Loading layer [==================================================>] 2.622MB/2.622MB
06a4ea157ddb: Loading layer [==================================================>] 326.1kB/326.1kB
Loaded image: goharbor/prepare:v2.4.3
c443487bfd9f: Loading layer [==================================================>] 5.755MB/5.755MB
4001cb9ab689: Loading layer [==================================================>] 4.096kB/4.096kB
9f87457ecde0: Loading layer [==================================================>] 17.32MB/17.32MB
47d4486167de: Loading layer [==================================================>] 3.072kB/3.072kB
f51cabdb6dfd: Loading layer [==================================================>] 28.72MB/28.72MB
380ce2def0ab: Loading layer [==================================================>] 46.84MB/46.84MB
Loaded image: goharbor/harbor-registryctl:v2.4.3
b286fc60426b: Loading layer [==================================================>] 127MB/127MB
7b88908cb054: Loading layer [==================================================>] 3.584kB/3.584kB
93d602edadbf: Loading layer [==================================================>] 3.072kB/3.072kB
49d91f6242c9: Loading layer [==================================================>] 2.56kB/2.56kB
a8647df205f2: Loading layer [==================================================>] 3.072kB/3.072kB
7ccaf27cd68e: Loading layer [==================================================>] 3.584kB/3.584kB
2ff597ded1cb: Loading layer [==================================================>] 20.99kB/20.99kB
Loaded image: goharbor/harbor-log:v2.4.3
52403f89e217: Loading layer [==================================================>] 8.898MB/8.898MB
5a9161bfdb13: Loading layer [==================================================>] 3.584kB/3.584kB
14940e7a959c: Loading layer [==================================================>] 2.56kB/2.56kB
f5c40dfdd3d8: Loading layer [==================================================>] 87.02MB/87.02MB
56cd3734529c: Loading layer [==================================================>] 87.81MB/87.81MB
Loaded image: goharbor/harbor-jobservice:v2.4.3
cd711020314a: Loading layer [==================================================>] 8.898MB/8.898MB
496150210186: Loading layer [==================================================>] 18.19MB/18.19MB
aeb1c396c209: Loading layer [==================================================>] 4.608kB/4.608kB
52724db7c320: Loading layer [==================================================>] 18.98MB/18.98MB
Loaded image: goharbor/harbor-exporter:v2.4.3
24ea24446aab: Loading layer [==================================================>] 5.755MB/5.755MB
40ef608261db: Loading layer [==================================================>] 4.096kB/4.096kB
d51ecd108b3f: Loading layer [==================================================>] 3.072kB/3.072kB
3fa8e4dab4e6: Loading layer [==================================================>] 17.32MB/17.32MB
188c78c94025: Loading layer [==================================================>] 18.12MB/18.12MB
Loaded image: goharbor/registry-photon:v2.4.3
cffc458fe11e: Loading layer [==================================================>] 5.75MB/5.75MB
cd06b198cad8: Loading layer [==================================================>] 5.928MB/5.928MB
4607ebf87688: Loading layer [==================================================>] 15.88MB/15.88MB
c5a43dfc3781: Loading layer [==================================================>] 29.29MB/29.29MB
b7a8c3813dbf: Loading layer [==================================================>] 22.02kB/22.02kB
4c72c181681f: Loading layer [==================================================>] 15.88MB/15.88MB
Loaded image: goharbor/notary-server-photon:v2.4.3
45e25d52465f: Loading layer [==================================================>] 7.668MB/7.668MB
b20a651e8d17: Loading layer [==================================================>] 7.356MB/7.356MB
171c7ff470e7: Loading layer [==================================================>] 1.754MB/1.754MB
Loaded image: goharbor/harbor-portal:v2.4.3
6b1ff6c12327: Loading layer [==================================================>] 8.898MB/8.898MB
f1d366f31d0f: Loading layer [==================================================>] 3.584kB/3.584kB
c38213e1c232: Loading layer [==================================================>] 2.56kB/2.56kB
9fabe842f8c8: Loading layer [==================================================>] 75.66MB/75.66MB
1576255d6597: Loading layer [==================================================>] 5.632kB/5.632kB
5a37726d81c6: Loading layer [==================================================>] 97.28kB/97.28kB
e904f12297e1: Loading layer [==================================================>] 11.78kB/11.78kB
eec3e8d2d82c: Loading layer [==================================================>] 76.56MB/76.56MB
4a8761efde42: Loading layer [==================================================>] 2.56kB/2.56kB
Loaded image: goharbor/harbor-core:v2.4.3
6bae17200200: Loading layer [==================================================>] 1.096MB/1.096MB
5d8836d42eae: Loading layer [==================================================>] 5.888MB/5.888MB
80a44c27e82e: Loading layer [==================================================>] 168.9MB/168.9MB
8180375aafdb: Loading layer [==================================================>] 16.63MB/16.63MB
39491227184d: Loading layer [==================================================>] 4.096kB/4.096kB
4d1c3a894014: Loading layer [==================================================>] 6.144kB/6.144kB
a4203cb7d346: Loading layer [==================================================>] 3.072kB/3.072kB
5ec1ba574847: Loading layer [==================================================>] 2.048kB/2.048kB
6af59dd70003: Loading layer [==================================================>] 2.56kB/2.56kB
faeb6f31b388: Loading layer [==================================================>] 2.56kB/2.56kB
1c684cfee7a6: Loading layer [==================================================>] 2.56kB/2.56kB
96abe5a24d1d: Loading layer [==================================================>] 8.704kB/8.704kB
Loaded image: goharbor/harbor-db:v2.4.3
9f08acda0b00: Loading layer [==================================================>] 5.755MB/5.755MB
668463ff981d: Loading layer [==================================================>] 64.5MB/64.5MB
02d0cb7e0b22: Loading layer [==================================================>] 3.072kB/3.072kB
5c641f452cd1: Loading layer [==================================================>] 4.096kB/4.096kB
feac902a1187: Loading layer [==================================================>] 65.29MB/65.29MB
Loaded image: goharbor/chartmuseum-photon:v2.4.3
[Step 3]: preparing environment ...
[Step 4]: preparing harbor configs ...
prepare base dir is set to /usr/local/harbor
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"write /proc/self/attr/keycreate: permission denied\"": unknown.
[root@localhost harbor]# setenforce 0 #以上报错的话执行这个命令,然后重新执行install.sh
[root@localhost harbor]#
[Step 5]: starting Harbor ...
[+] Running 10/10
⠿ Network harbor_harbor Created 0.5s
⠿ Container harbor-log Started 0.9s
⠿ Container registryctl Started 2.0s
⠿ Container harbor-db Started 1.9s
⠿ Container registry Started 1.8s
⠿ Container redis Started 2.0s
⠿ Container harbor-portal Started 2.0s
⠿ Container harbor-core Started 2.9s
⠿ Container harbor-jobservice Started 4.0s
⠿ Container nginx Started 4.5s
✔ ----Harbor has been installed and started successfully.---- #安装成功
3.8 停止与启动
[root@localhost harbor]# docker-compose stop #停止
[+] Running 9/9
⠿ Container nginx Stopped 0.4s
⠿ Container harbor-jobservice Stopped 0.2s
⠿ Container registryctl Stopped 10.2s
⠿ Container harbor-core Stopped 4.1s
⠿ Container harbor-portal Stopped 0.2s
⠿ Container harbor-db Stopped 0.4s
⠿ Container registry Stopped 0.3s
⠿ Container redis Stopped 0.3s
⠿ Container harbor-log Stopped 10.3s
[root@localhost harbor]# docker-compose start #启动
[+] Running 9/9
⠿ Container harbor-log Started 0.6s
⠿ Container redis Started 0.7s
⠿ Container registryctl Started 1.0s
⠿ Container harbor-portal Started 0.9s
⠿ Container registry Started 1.0s
⠿ Container harbor-db Started 0.9s
⠿ Container harbor-core Started 0.4s
⠿ Container nginx Started 0.8s
⠿ Container harbor-jobservice Started 0.7s
[root@localhost harbor]#
3.9 添加开机自启脚本
[root@localhost harbor]# vi startall.sh
[root@localhost harbor]# more startall.sh #这是自启脚本
#!/bin/bash
cd /usr/local/harbor
docker-compose stop && docker-compose start
[root@localhost harbor]# chmod +x startall.sh #给权限
[root@localhost harbor]# ll /etc/rc.local
lrwxrwxrwx. 1 root root 13 4月 7 10:17 /etc/rc.local -> rc.d/rc.local
[root@localhost harbor]# ll /etc/rc.d/rc.local
-rw-r--r--. 1 root root 473 10月 2 2020 /etc/rc.d/rc.local
[root@localhost harbor]# chmod +x /etc/rc.d/rc.local
[root@localhost harbor]# ll /etc/rc.d/rc.local
-rwxr-xr-x. 1 root root 473 10月 2 2020 /etc/rc.d/rc.local
[root@localhost harbor]# vi /etc/rc.d/rc.local #编辑/etc/rc.d/rc.local
[root@localhost harbor]#
[root@localhost harbor]#
[root@localhost harbor]# vi /etc/rc.d/rc.local #编辑,添加/bin/bash /usr/local/harbor/startall.sh
[root@localhost harbor]# more /etc/rc.d/rc.local
#!/bin/bash
# THIS FILE IS ADDED FOR COMPATIBILITY PURPOSES
#
# It is highly advisable to create own systemd services or udev rules
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.
touch /var/lock/subsys/local
/bin/bash /usr/local/harbor/startall.sh #添加的内容
[root@localhost harbor]#