Ubuntu22.04 LTS 部署harbor-v2.7.2高可用

news/2024/12/14 23:05:27/文章来源:https://www.cnblogs.com/jasper2023/p/18607394

Ubuntu22.04 LTS 部署harbor高可用

一、harbor 环境部署

1. 下载harbor包

[root@harbor01:~]# wget https://github.com/goharbor/harbor/releases/download/v2.7.2/harbor-offline-installer-v2.7.2.tgz

2. 解压软件包

[root@harbor01:~]# tar xf harbor-offline-installer-v2.7.2.tgz -C /caixiangjia/softwares/
[root@harbor01:~]# cd /caixiangjia/softwares/harbor/

3. 准备配置文件

[root@harbor01:harbor]# cp harbor.yml.tmpl harbor.yml
[root@harbor01:harbor]# ll harbor.yml*
-rw-r--r-- 1 root root 11567 Dec 14 21:13 harbor.yml
-rw-r--r-- 1 root root 11567 Apr 24  2023 harbor.yml.tmpl

4. 编辑harbor配置文件

...
hostname: 10.0.0.20
...12 # https related config13 #https:14 #  # https port for harbor, default is 44315 #  port: 44316 #  # The path of cert and key files for nginx17 #  certificate: /your/certificate/path18 #  private_key: /your/private/key/path
...34 harbor_admin_password: 1
...53 data_volume: /caixiangjia/data/harbor
...
# 此处方便后期prometheus监控
220 metric:
221   enabled: true                                                                                           222   port: 9099
223   path: /metrics

5. 安装 harbor

[root@harbor01:harbor]# ./install.sh --with-chartmuseum
...
[+] Building 0.0s (0/0)                                                                                                                                                            docker:default
[+] Running 13/13✔ Network harbor_harbor-chartmuseum  Created                                                                                                                                                0.1s ✔ Network harbor_harbor              Created                                                                                                                                                0.1s ✔ Container harbor-log               Started                                                                                                                                                0.0s ✔ Container chartmuseum              Started                                                                                                                                                0.0s ✔ Container registry                 Started                                                                                                                                                0.0s ✔ Container registryctl              Started                                                                                                                                                0.0s ✔ Container harbor-portal            Started                                                                                                                                                0.0s ✔ Container harbor-db                Started                                                                                                                                                0.0s ✔ Container redis                    Started                                                                                                                                                0.0s ✔ Container harbor-core              Started                                                                                                                                                0.0s ✔ Container nginx                    Started                                                                                                                                                0.0s ✔ Container harbor-jobservice        Started                                                                                                                                                0.0s ✔ Container harbor-exporter          Started                                                                                                                                                0.0s 
✔ ----Harbor has been installed and started successfully.----

6. 访问 harbor 的 WebUI

http://10.0.0.20/用户名:admin
密码:1


二、harbor 的基本使用

1. 客户端配置

[root@harbor01:~]# cat /etc/docker/daemon.json
{"insecure-registries": ["10.0.0.20"]
}[root@harbor01:~]# systemctl restart docker.service 

2. harbor 创建仓库

3. 给镜像打 tag

[root@harbor01:~]# docker images
REPOSITORY                      TAG       IMAGE ID       CREATED         SIZE
hello-world                     latest    d2c94e258dcb   19 months ago   13.3kB
[root@harbor01:~]# docker tag hello-world:latest 10.0.0.20/test/hello-world-latest

4. 推送镜像到harbor仓库

# 未登录之前
[root@harbor01:~]# docker push 10.0.0.20/test/hello-world
Using default tag: latest
The push refers to repository [10.0.0.20/test/hello-world]
ac28800ec8bb: Preparing 
unauthorized: unauthorized to access repository: test/hello-world, action: push: unauthorized to access repository: test/hello-world, action: push[root@harbor01:~]# docker login 10.0.0.20
Username: admin 	# 输入用户名
Password: 			# 输入密码,输入密码时看不见输入字符!
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded# 登录成功后会保存登录信息
[root@harbor01:~]# more /root/.docker/config.json
{"auths": {"10.0.0.20": {"auth": "YWRtaW46MQ=="}}
}# 通过 base64 -d 查看你的密码
[root@harbor01:~]# echo YWRtaW46MQ== | base64 -d | more
admin:1#登录之后
[root@harbor01:~]# docker push 10.0.0.20/test/hello-world
Using default tag: latest
The push refers to repository [10.0.0.20/test/hello-world]
ac28800ec8bb: Pushed 
latest: digest: sha256:d37ada95d47ad12224c205a938129df7a3e52345828b4fa27b03a98825d1e2e7 size: 524

5.web页面查看

6. 推送镜像完成后立刻退出(避免密码泄露)

[root@harbor01:~]# docker logout 10.0.0.20
Removing login credentials for 10.0.0.20[root@harbor01:~]# more /root/.docker/config.json
{"auths": {}
}
[r

7. 其他客户端拉取镜像,【需要配置信任仓库】

[root@harbor02:~]# cat /etc/docker/daemon.json 
{"insecure-registries": ["10.0.0.20"]
}[root@harbor02:~]# systemctl restart docker.service [root@harbor02:~]# docker pull 10.0.0.20/test/hello-world:latest
latest: Pulling from test/hello-world
c1ec31eb5944: Pull complete 
Digest: sha256:d37ada95d47ad12224c205a938129df7a3e52345828b4fa27b03a98825d1e2e7
Status: Downloaded newer image for 10.0.0.20/test/hello-world:latest
10.0.0.20/test/hello-world:latest

三、harbor 高可用环境搭建

1. 将harbor发送到10.0.0.21节点

[root@harbor01:~]# scp harbor-offline-installer-v2.7.2.tgz 10.0.0.21:/root

2. 解压软件包

[root@harbor02:~]# tar xf harbor-offline-installer-v2.7.2.tgz -C /caixiangjia/softwares/

3. 将harbor配置文件发送到10.0.0.21节点

[root@harbor01:harbor]# scp harbor.yml 10.0.0.21:/caixiangjia/softwares/harbor/

4. 安装harbor

# 修改harbor配置文件
[root@harbor02:harbor]# vim harbor.yml
...
hostname: 10.0.0.21
...[root@harbor02:harbor]# ./install.sh --with-chartmuseum

5. 访问harbor 的WebUi

http://10.0.0.21/账号:admin
密码:1

6. 10.0.0.20节点新建仓库

7. 10.0.0.20节点新建复制规则

8. 10.0.0.21节点新建仓库

9. 10.0.0.21节点新建复制规则

10. 测试验证效果

推送镜像到 20 节点,观察 21 是否有同步数据

[root@harbor01:~]# docker push 10.0.0.20/wordpress/wordpress:latest 


推送镜像到 21 节点,观察 20 是否有同步数据

[root@harbor02:~]# docker push 10.0.0.21/mysql/mysql:8.0.36-oracle


11. 配置keepalived

1. 分别安装keepalived

[root@harbor01:~]# apt -y install keepalived
[root@harbor02:~]# apt -y install keepalived

2. 修改 keepliaved 的配置文件

[root@harbor01:~]# cat > /etc/keepalived/keepalived.conf <<EOF
! Configuration File for keepalived
global_defs {router_id 10.0.0.20
}
vrrp_script chk_nginx {script "/etc/keepalived/check_port.sh 80"interval 2weight -20
}
vrrp_instance VI_1 {state MASTERinterface ens33virtual_router_id 100priority 100advert_int 1mcast_src_ip 10.0.0.20nopreemptauthentication {auth_type PASSauth_pass 11111111}track_script {chk_nginx}virtual_ipaddress {10.0.0.99}
}
EOF[root@harbor02:~]# cat > /etc/keepalived/keepalived.conf <<EOF
! Configuration File for keepalived
global_defs {router_id 10.0.0.21
}
vrrp_script chk_nginx {script "/etc/keepalived/check_port.sh 80"interval 2weight -20
}
vrrp_instance VI_1 {state MASTERinterface ens33virtual_router_id 100priority 100advert_int 1mcast_src_ip 10.0.0.21nopreemptauthentication {auth_type PASSauth_pass 11111111}track_script {chk_nginx}virtual_ipaddress {10.0.0.99}
}
EOF

3. 启动 keepalived

[root@harbor01:~]# systemctl enable --now keepalived
[root@harbor02:~]# systemctl enable --now keepalived

4. 检查VIP地址

[root@harbor01:~]# ip a
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:b2:85:39 brd ff:ff:ff:ff:ff:ffaltname enp2s1inet 10.0.0.20/24 brd 10.0.0.255 scope global ens33valid_lft forever preferred_lft foreverinet 10.0.0.99/32 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:feb2:8539/64 scope link valid_lft forever preferred_lft forever[root@harbor02:~]# ip a
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:c3:05:1b brd ff:ff:ff:ff:ff:ffaltname enp2s1inet 10.0.0.21/24 brd 10.0.0.255 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fec3:51b/64 scope link valid_lft forever preferred_lft forever       

5. 使用VIP地址登录

http://10.0.0.99/

6. 让10.0.0.21节点宕机,观察VIP是否漂移

[root@harbor01:~]# init 0
[root@harbor02:~]# ip a
...
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000link/ether 00:0c:29:c3:05:1b brd ff:ff:ff:ff:ff:ffaltname enp2s1inet 10.0.0.21/24 brd 10.0.0.255 scope global ens33valid_lft forever preferred_lft foreverinet 10.0.0.99/32 scope global ens33valid_lft forever preferred_lft foreverinet6 fe80::20c:29ff:fec3:51b/64 scope link valid_lft forever preferred_lft forever

harbor仓库正常访问

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/852713.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

PolarCTF-Pwn(困难)WP

1、ret2libc 前期准备:int __fastcall main(int argc, const char **argv, const char **envp) {char s[112]; // [rsp+0h] [rbp-70h] BYREFsetvbuf(stdin, 0LL, 2, 0LL);setvbuf(stdout, 0LL, 2, 0LL);setvbuf(stderr, 0LL, 2, 0LL);gets(s);puts(s);return 0; }因为程序是动…

游戏产业加速鸿蒙化步伐:超1800款鸿蒙原生游戏已上架

2024年度中国游戏产业年会于12月12日至13日北京市首钢国际会展中心举办,华为终端云全球生态发展与销售部副总裁张思建受邀出席主论坛,并发表了主题演讲。同期,由华为游戏中心主办的鸿蒙游戏行业论坛也在北京石景山区举行,本次活动邀请了中国音像与数字出版协会常务副理事长…

最强分类器调优秘诀!AdaBoost让性能飙升!

本文已收录在Github,关注我,紧跟本系列专栏文章,咱们下篇再续!作者简介:魔都架构师,多家大厂后端一线研发经验,在分布式系统设计、数据平台架构和AI应用开发等领域都有丰富实践经验。 各大技术社区头部专家博主。具有丰富的引领团队经验,深厚业务架构和解决方案的积累。…

Toyota Programming Contest 2024#12(AtCoder Beginner Contest 384)题解

总体情况感觉这次在起飞。 20 分钟后就在罚坐。 A - aaaadaa 题目描述 给定一个长度为 \(N\) 的字符串 \(S\) ,由小写英文字母以及小写英文字母 \(c_1\) 和 \(c_2\) 组成。 查找将 \(S\) 中所有不属于 \(c_1\) 的字符替换为 \(c_2\) 后得到的字符串。 思路分析 直接模拟。代码…

解决2024.1以后新版本IDEA Lombok (@Data)等不生效的问题

做项目做着做着新模块用不了 lombok 真的要崩溃了,各种检查插件、配置,发现都无法恢复;乱试指定版本:终于可用了。。真的有崩溃感

DNS之公共DNS

阿里 AliDNS 阿里公共DNS是阿里巴巴集团推出的DNS递归解析系统,目标是成为国内互联网基础设施的组成部分,面向互联网用户提供“快速”、“稳定”、“智能”的免费DNS递归解析服务。 DNS 服务器 IP 地址: 首选:223.5.5.5 备选:223.6.6.6 阿里公共DNS114DNS 国内用户量巨大的…

NestJS 部署Apache

要将Nest.JS应用搭建在Apache服务器上,你需要了解Nest.JS是一个基于Node.js的框架,因此它本质上是一个后端服务,而Apache通常用作前端服务器或反向代理。以下是将Nest.JS应用与Apache服务器结合使用的步骤: 一、准备环境安装Node.js:确保在服务器上安装了Node.js。你可以从…

综合设计——多源异构数据采集与融合应用综合实践

这个项目属于哪个课程2024数据采集与融合技术实践 组名 从你的全世界爬过团队logo:项目简介 项目名称:博物识植项目logo:项目介绍:在探索自然奥秘的旅途中,我们常与动植物相伴而行,却无法准确识别它们,更难以深入了解他们的特征。为了更好地理解和欣赏自然界的多样性,…

maven docker-maven-plugin 发布docker 20241214

1、docker开启远程访问 端口 2375docker主机:192.168.177.128 vi /usr/lib/systemd/system/docker.service #修改ExecStart这行 ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 #重新加载配置文件 [root@localhost ~]# systemctl daemon-reload #重启服务 [root@lo…

10大关键技术解构:智能合同审查系统全景解析

前言 随着企业数字化转型的深入,合同管理在业务流程中的重要性愈加凸显。传统的人工审查合同方式不仅耗时耗力,还容易出现疏漏,尤其在复杂法律条款和跨部门协作的场景中,这一问题尤为明显。为了解决这一痛点,思通数科智能合同审查系统应运而生。基于人工智能和大数据分析的…