harbor 1.1之安装

一.harbor是docker存放镜像的私有仓库,官网地址,官网地址:https://github.com/goharbor/harbor

实验准备:两台机器,安装harbor的机器至少2G

1.为harbor颁发证书

[root@hd2 ~]# hostnamectl set-hostname harbor 
[root@harbor ~]# mkdir /data/ssl -p
[root@harbor ~]# cd /data/ssl/
生成ca证书:
root@harbor ssl]# openssl genrsa -out ca.key 3072
#生成一个3072位的key,也就是私钥
[root@harbor ssl]# openssl req -new -x509 -days 3650 -key ca.key -out ca.pem
#生成一个数字证书ca.pem,3650表示证书的有效时间是10年,按箭头提示填写即可,没有箭头标注的为空:
生成域名的证书:
[root@harbor ssl]# openssl genrsa -out harbor.key  3072
#生成一个3072位的key,也就是私钥
openssl req -new -key harbor.key -out harbor.csr
签发证书:
openssl x509 -req -in harbor.csr -CA ca.pem -CAkey ca.key -CAcreateserial -out harbor.pem -days 3650

显示如下,说明证书签发好了:

 

 

2.设置时间同步

#配置时间同步
[root@filebeat ~]# yum install -y ntpdate
[root@filebeat ~]# ntpdate ntp1.aliyun.com
#编写计划任务
[root@filebeat ~]# crontab -e
* */1 * * * /usr/sbin/ntpdate   ntp1.aliyun.com
重启crond服务使配置生效:
[root@filebeat ~]# systemctl restart crond

3.配置hosts文件,使两台机器能相互解析

vim /etc/hosts

4.安装docker&harbor所需依赖包

[root@harbor ~]#yum install -y python-devel epel-release openssh-server socat  ipvsadm conntrack

5.安装docker-ce源

wget  http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

6.安装docker并且启动docker

[root@filebeat yum.repos.d]# yum install -y docker-ce
[root@filebeat yum.repos.d]# systemctl start docker

7.查看docker版本docker version

8.开启数据包转发功能

[root@filebeat yum.repos.d]# cat /etc/sysctl.conf 
net.ipv4.ip_forward=1

重启下

[root@filebeat ]# sysctl -p

9.配置镜像加速,登录自己控制台容器镜像服务 (aliyun.com)并重启systemctl daemon-reload

10.安装harbor

(1)创建harbr目录

mkdir /opt/harbor

(2)进入harbor目录下,下载harbor的tar包并解压,可以去github网站上下载

(3)解压出来一个harbor目录,进入目录

 

 (4)配置harbor的配置文件,

[root@harbor ]# vim /opt/harbor/harbor.yml.tmpl
hostname:  harbor 
#修改hostname,跟上面签发的证书域名保持一致
#协议用https
certificate: /data/ssl/harbor.pem
private_key: /data/ssl/harbor.key
 

 harbor默认的账号密码:admin/Harbor12345

(5)安装docker-compose

yum Install -y docker-compose

(6)看到harbor文件下有个install.sh脚本,执行下

 

 (7)配置自己windows的host文件,使得可以解析Windows/System32/drivers/etc/hosts

192.168.213.6 myharbor     

 

 

 

(8)浏览器输入https://myharbor

 

 (9)默认密码admin    Harbor12345

 

posted @ 2022-06-16 23:22  多次拒绝黄宗泽  阅读(344)  评论(0编辑  收藏  举报