在Centos7搭建高可用Harbor集群
一、主机清单
IP地址 | 主机名 | 描述 |
---|---|---|
192.168.0.211 | / | 负载均衡VIP,5000端口 |
192.168.0.212 | harbor01 | Harbor实例1,5000端口 |
192.168.0.213 | harbor02 | Harbor实例2,5000端口 |
192.168.0.214 | Docker Server | 打包及上传docker镜像 |
-
harbor01与harbor02需要安装docker 、docker-compose、harbor、keepalived
-
Docker Server服务器需要安装docker 、docker-compose
-
二、系统升级
1、更新软件包列表
yum update -y
2、列出可用的 更新软件包
# yum list updates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.ustc.edu.cn
* updates: mirrors.aliyun.com
3、查看当前系统版本
# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
4、更新系统
# yum upgrade
# cat /etc/centos-release
CentOS Linux release 7.9.2009 (Core)
三、内核升级
1、查看当前内核版本
# uname -r
3.10.0-1160.71.1.el7.x86_64
2、查看可升级内核版本
# yum list kernel
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.ustc.edu.cn
* updates: mirrors.aliyun.com
Installed Packages
kernel.x86_64 3.10.0-1160.71.1.el7 @anaconda
kernel.x86_64 3.10.0-1160.119.1.el7 @updates
可以看出只有一个内核版本3.10.0,而这次需要升级到内核6.9.7。不能直接使用yum update kernel-*打补丁升级了
3、查看是否安装ELRepo
[root@harbor01 ~]# yum --disablerepo="*" --enablerepo="elrepo-kernel" list available
Loaded plugins: fastestmirror
Error getting repository data for elrepo-kernel, repository not found
ELRepo源是国外的一个只对Linux操作系统的第三方免费软件资源库,支持Linux和CentOS操作系统的软件安装和升级。
4、导入一个公钥
# rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
5、安装一下ELRepo源
# yum install -y https://www.elrepo.org/elrepo-release-7.el7.elrepo.noarch.rpm
6、安装新内核
# yum --enablerepo=elrepo-kernel install kernel-ml -y
7、设置新安装的内核成为默认启动选项
将配置文件中GRUB_DEFAULT参数saved改为0
# sed -i s/saved/0/g /etc/default/grub
8、更新配置文件
# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-6.9.7-1.el7.elrepo.x86_64
Found initrd image: /boot/initramfs-6.9.7-1.el7.elrepo.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.119.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.119.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-1160.71.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-1160.71.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-e227a3c248e94736968e30eee994bdb8
Found initrd image: /boot/initramfs-0-rescue-e227a3c248e94736968e30eee994bdb8.img
done
9、重启:reboot
# reboot
10、升级完成
# uname -r
6.9.7-1.el7.elrepo.x86_64
四、安装docker
1. 卸载旧版本(可选)
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
2、安装需要的[软件包
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3 、设置yum安装源
默认是国外的yum源,基本不可用,我们修改为阿里源。
//中央仓库
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
//国内建议安装阿里仓库
# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@harbor01 ~]# yum makecache fast
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* elrepo: mirrors.tuna.tsinghua.edu.cn
* extras: mirrors.ustc.edu.cn
* updates: mirrors.aliyun.com
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
elrepo | 3.0 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db