1 下载并解压

cd /tmp 

wget https://github.com/goharbor/harbor/releases/download/v2.6.0/harbor-offline-installer-v2.6.0.tgz

   

tar xf harbor-offline-installer-v2.6.0.tgz -C /opt/ 
cd /opt/ 
mv harbor/ harbor-v2.6.0 
ln -s /opt/harbor-v2.6.0/ /opt/harbor

   

2 编辑配置文件

cp harbor.yml.tmpl harbor.yml
   
# vi /opt/harbor/harbor.yml
# 以下是修改项,手动在配置文件中更改
hostname: harbor.st.com
http: 
81
harbor_admin_password:Harbor12345
data_volume: /data/harbor
log: 
    level: info 
    rotate_count: 50
    rotate_size:200M 
/data/harbor/logs

#默认port:80,改成81,为了避免和gitlab的80端口产生冲突

https需注释掉,否则无法启动

kubesphere 中 jwtSecret从哪取 kubesphere istio_docker

  

kubesphere 中 jwtSecret从哪取 kubesphere istio_配置文件_02

   

创建日志目录

mkdir -p /data/harbor/logs

检查配置:

cat /opt/harbor/harbor.yml| egrep -v "#|^$"

   

   

3 使用docker-compose启动harbor harbor依赖compose做单机编排

cd /opt/harbor/ 
yum install docker-compose -y 需要epel源
epel源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
   
sh /opt/harbor/install.sh
docker-compose ps

kubesphere 中 jwtSecret从哪取 kubesphere istio_重启_03

docker ps -a

    

4 使用dns服务器或host文件解析harbor

追加解析

echo 192.168.1.143 harbor.st.com>>/etc/hosts

   

5.insecure-registries选项修改,允许使用http登录

Harbor客户端设置示例

登录前客户端先设置好insecure-registries

Worker节点之前改过了,使用了阿里云加速配置

cat /etc/docker/daemon.json 
{ 
 "registry-mirrors": ["https://82m9ar63.mirror.aliyuncs.com"],
 "exec-opts": ["native.cgroupdriver=systemd"], 
 "log-driver": "json-file", 
 "insecure-registries": ["registry.access.redhat.com","quay.io","harbor.st.com:81","192.168.1.143:81"], 
 "log-opts": { 
 "max-size": "100m" 
 }, 
 "storage-driver": "overlay2" 
}

   

Master节点未改过,未使用阿里云加速配置

{ 
 "log-opts": { 
 "max-size": "5m", 
 "max-file":"3" 
 }, 
 "exec-opts": ["native.cgroupdriver=systemd"], 
 "insecure-registries": ["registry.access.redhat.com","quay.io","harbor.st.com:81","192.168.1.143:81"] 
}

     

重启docker

systemctl restart docker

   

6.登录测试

 修改了默认端口80(已被Gitlab占用),改用了81端口

浏览器输入:harbor.st.com:81或http://192.168.1.143:81/
用户名:admin 密码:Harbor12345

   

docker登录

docker login harbor.st.com -uadmin -pHarbor12345

    

   

排错: Harbor访问出现502Bad Gateway的情况

cd /opt/harbor/

使用docker-compose ps [列出所有容器] 查看容器情况

入调试模式查看异常情况

docker-compose up [列出所有容器的日志,退出时关闭容器]

docker-compose up & 后台执行

docker ps 检查是否有unhealthy的容器

   

解决方法:

重启unhealthy的容器

重启docker服务

重启计算机并执行docker-compose up

放大招:重新安装 /opt/harbor/install.sh

   

data_volume已存在本机,重新编排后以前上传的镜像仍存在