上传文件至 /

This commit is contained in:
wxin 2024-08-12 22:04:18 +08:00
commit f55d4f4542
1 changed files with 242 additions and 0 deletions

242
Harbor部署.md Normal file
View File

@ -0,0 +1,242 @@
### Harbor部署
------
### 1. 初始化
准备干净的机器,将 */etc/yum.repos.d/* 中的 yum 源清空,导入阿里云镜像站中的 epel 镜像源和 centos 镜像源。
1. 清空yum源
```bash
# rm -rf /etc/yum.repos.d/*
```
2. 导入centos镜像源
```bash
# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
```
3. 导入epel镜像源
```bash
# wget -O /etc/yum.repos.d/epel.repo https://mirrors.aliyun.com/repo/epel-7.repo
```
4. 生成缓存
```bash
# yum makecache
```
### 2. 安装docker-ce
1. 安装必要的一些系统工具
```bash
# yum install -y yum-utils device-mapper-persistent-data lvm2
```
2. 添加软件源信息
```bash
# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
```
3. 修改源信息
```bash
# sed -i 's+download.docker.com+mirrors.aliyun.com/docker-ce+' /etc/yum.repos.d/docker-ce.repo
```
4. 更新并安装Docker-CE
```bash
# yum makecache fast
# yum -y install docker-ce
```
5. 开启Docker服务
```bash
# service docker start
```
### 3. 安装docker-compose
1. 获取源文件
```bash
# wget http://182.92.143.66:40072/directlink/1/docker-compose-linux-x86_64
```
2. 移动到 /usr/local/bin ,并修改为 docker-compose
```bash
# mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
```
3. 赋予执行权限
```bash
# chmod +x /usr/local/bin/docker-compose
```
4. 查看安装结果
```bash
# docker-compose version
```
### 4. 安装harbor
1. 获取安装文件
```bash
# wget http://182.92.143.66:40072/directlink/2/harbor-offline-installer-v2.8.2.tgz
```
2. 解压文件并移动到 /usr/local/ 目录
```bash
# tar xf harbor-offline-installer-v2.8.2.tgz -C /usr/local/
```
3. 将 harbor.yml.tmpl 文件名修改为 harbor.yml
```bash
# cd /usr/local/harbor
# mv harbor.yml.tmpl harbor.yml
```
4. 修改 harbor.yml 文件
```bash
# vim harbor.yml
hostname: 192.168.109.220 # 修改为本地IP地址
# 将以下信息注释掉
#https:
# port: 443
# certificate: /your/certificate/path
# private_key: /your/private/key/path
```
5. 重启 docker
```bash
# systemctl restart docker
```
### 5. 获取 harbor 安装镜像
1. 获取镜像拉去脚本
```bash
# wget http://182.92.143.66:40072/directlink/2/harbor_download.sh
```
2. 修改镜像脚本
```bash
# vim harbor_download.sh
#!/bin/bash
version="v2.8.2"
images=(harbor-core notary-signer-photon harbor-db harbor-portal prepare harbor-exporter harbor-registryctl redis-photon harbor-jobservice nginx-photon registry-photon harbor-log notary-server-photon trivy-adapter-photon)
for i in ${images[*]}
do
docker pull 192.168.109.167/library/${i}:$version
done
```
3. 添加容器加速
```bash
# vim /etc/docker/daemon.json
{
"insecure-registries": ["192.168.109.167"]
}
# systemctl daemon-reload
# systemctl restart docker
```
4. 运行脚本
```bash
# bash harbor_download.sh
```
### 6. 运行 harbor
1. 安装初始化
```bash
# cd /usr/local/harbor
# ./prepare
# ./install.sh
```
2. 运行服务器
```bash
# docker-compose up -d #启动
# docker-compose stop #停止
# docker-compose restar #重启
```