Harbor离线部署

一、离线安装包

docker安装包地址:https://download.docker.com/linux/static/stable/x86_64/
docker-compose安装包地址:https://github.com/docker/compose/releases
harbor安装包地址:https://github.com/goharbor/harbor/releases

二、安装步骤

1.安装docker

解压安装包

tar -xzvf docker-19.03.9.tgz

拷贝到/usr/bin下

cp docker/* /usr/bin/

创建并编辑docker.service文件

vi /etc/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
 
[Service]
Type=notify
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
 
[Install]
WantedBy=multi-user.target

添加权限

chmod +x /etc/systemd/system/docker.service

重新加载服务配置文件

systemctl daemon-reload

设置docker开机自启

systemctl enable docker.service

启动docker

systemctl start docker

查看docker状态

systemctl status docker

docker version
Client:
 Version:           20.10.7
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        f0df350
 Built:             Wed Jun  2 11:51:04 2021
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.7
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       b0f5bc3
  Built:            Wed Jun  2 11:55:29 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          v1.4.6
  GitCommit:        d71fcd7d8303cbf684402823e425e9dd2e99285d
 runc:
  Version:          1.0.0-rc95
  GitCommit:        b9ee9c6314599f1b4a7f497e1f1f856fe433d3b7
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

2.安装docker-compose

将安装包移动到/usr/bin目录下,并修改名称

mv docker-compose-Linux-x86_64 /usr/local/bin/docker-compose

修改权限

chmod a+x /usr/local/bin/docker-compose

查看版本

docker-compose -v
docker-compose version 1.29.2, build 5becea4c

3.安装Harbor

解压安装包

tar -xzvf harbor-offline-installer-v2.3.2.tgz -C /opt/

修改文件名

cp /opt/harbor/harbor.yml.tmpl /opt/harbor/harbor.yml
vi /opt/harbor/harbor.yml
修改配置文件harbor.yml,hostname修改为IP或者域名;并配置ssl证书位置,将ssl相关配置注释,不使用https访问。

解压镜像

docker load -i /opt/harbor/harbor.v2.1.1.tar.gz

执行准备程序

bash /opt/harbor/prepare

执行安装程序

bash /opt/harbor/install.sh

[Step 5]: starting Harbor ...
Creating network "harbor_harbor" with the default driver
Creating harbor-log ... done
Creating registry      ... done
Creating harbor-db     ... done
Creating registryctl   ... done
Creating harbor-portal ... done
Creating redis         ... done
Creating harbor-core   ... done
Creating nginx             ... done
Creating harbor-jobservice ... done
✔ ----Harbor has been installed and started successfully.----

查看docker-compose状态

docker-compose ps

 Name                     Command                  State                                          Ports                                    
------------------------------------------------------------------------------------------------------------------------------------------------
harbor-core         /harbor/entrypoint.sh            Up (healthy)                                                                               
harbor-db           /docker-entrypoint.sh 96 13      Up (healthy)                                                                               
harbor-jobservice   /harbor/entrypoint.sh            Up (healthy)                                                                               
harbor-log          /bin/sh -c /usr/local/bin/ ...   Up (healthy)   127.0.0.1:1514->10514/tcp                                                   
harbor-portal       nginx -g daemon off;             Up (healthy)                                                                               
nginx               nginx -g daemon off;             Up (healthy)   0.0.0.0:80->8080/tcp,:::80->8080/tcp, 0.0.0.0:443->8443/tcp,:::443->8443/tcp
redis               redis-server /etc/redis.conf     Up (healthy)                                                                               
registry            /home/harbor/entrypoint.sh       Up (healthy)                                                                               
registryctl         /home/harbor/start.sh            Up (healthy)   

启动停止

docker-compose down -v
docker-compose up -d

通过IP访问web页面

admin
Harbor12345

三、k8s 节点登录harbor

在其他worker计算节点操作

docker login  172.16.124.55

四、登录报错

使用http协议的harbor登录报错:

Error response from daemon: Get https://172.16.60.213/v1/users/: dial
tcp 172.16.60.213:443: connect: connection refused

在/etc/docker/daemon.json文件里添加"insecure-registries"配置。(如果还不行,可以尝试将下面添加的地址由"172.16.60.213"改为"http://172.16.60.213")

[root@docker-client ~]# vim /etc/docker/daemon.json
{
    "insecure-registries": [
        "172.16.60.213"
      ]
}

然后重启docker服务

[root@docker-client ~]# systemctl restart docker

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

范一刀

你的鼓励是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值