Mac M1 Parallels CentOS7.9 Install Harbor

一、官网下载

下载地址: https://github.com/goharbor/harbor/releases

# 本机执行, 上传
scp Downloads/harbor/harbor-offline-installer-v2.3.4.tgz [email protected]:~
# 解压
mkdir -p /opt/harbor && tar -xzf harbor-offline-installer-v2.3.4.tgz -C /opt/

二、修改配置

cp /opt/harbor/harbor.yml.tmpl /opt/harbor/harbor.yml
vi /opt/harbor/harbor.yml
 
# 修改hostname,注释掉https
hostname: harbor.zhinian.com

Mac M1 Parallels CentOS7.9 Install Harbor_第1张图片

三、安装

3.1 安装docker

# 1 切换镜像源
[root@master ~]# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo

# 2 查看当前镜像源中支持的docker版本
[root@master ~]# yum list docker-ce --showduplicates

# 3 安装特定版本的docker-ce
# 必须指定--setopt=obsoletes=0,否则yum会自动安装更高版本
[root@master ~]# yum install --setopt=obsoletes=0 docker-ce-18.06.3.ce-3.el7 -y(推荐) yum install -y docker-ce-19.03.9-3.el7 docker-ce-cli-19.03.9-3.el7

# 4 配置文件
vim /etc/systemd/system/docker.service

# 内容BEGIN
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
# 内容END

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

# 5 启动docker
# 重新加载配置文件
systemctl daemon-reload
# 启动docker
systemctl start docker
# 设置开机启动
systemctl enable docker.service

# 6 检查docker状态和版本
[root@master ~]# docker version

# 查询镜像加速地址: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
# 可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "exec-opts": ["native.cgroupdriver=systemd"],
  "registry-mirrors": ["https://3io13djb.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload && sudo systemctl restart docker

# 7 配置ipv4
# 1 安装ipset和ipvsadm
[root@master ~]# yum install ipset ipvsadmin -y
# 如果提示No package ipvsadmin available.需要使用 yum install -y ipvsadm

# 2 添加需要加载的模块写入脚本文件
[root@master ~]# cat <  /etc/sysconfig/modules/ipvs.modules
#!/bin/bash
modprobe -- ip_vs
modprobe -- ip_vs_rr
modprobe -- ip_vs_wrr
modprobe -- ip_vs_sh
modprobe -- nf_conntrack
EOF

# 3 为脚本文件添加执行权限
[root@master ~]# chmod +x /etc/sysconfig/modules/ipvs.modules

# 4 执行脚本文件
[root@master ~]# /bin/bash /etc/sysconfig/modules/ipvs.modules

# 5 查看对应的模块是否加载成功
[root@master ~]# lsmod | grep -e ip_vs -e nf_conntrack_ipv4

3.2 安装docker-compose

# 运行以下命令以下载 Docker Compose 的当前稳定版本, 要安装其他版本的 Compose, 请替换 1.24.1
wget https://github.com/docker/compose/releases/download/v2.3.4/docker-compose-linux-aarch64
mv docker-compose-linux-aarch64 docker-compose
cp docker-compose /usr/local/bin/docker-compose

# 将可执行权限应用于二进制文件:
sudo chmod +x /usr/local/bin/docker-compose

# 创建软链
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
 
# 测试是否安装成功
docker-compose --version

Mac M1 Parallels CentOS7.9 Install Harbor_第2张图片

3.3 安装Harbor

yum install -y openssl
./install.sh

Mac M1 Parallels CentOS7.9 Install Harbor_第3张图片

四、常用命令

docker-compose up -d   # 启动
docker-compose stop    # 停止
docker-compose restart # 重新启动

五、访问测试

默认账户密码:admin/Harbor12345

访问 harbor.zhinian.com
Mac M1 Parallels CentOS7.9 Install Harbor_第4张图片

安装成功!

你可能感兴趣的:(macos)