先装置好 Docker,docker-compose
华为云 arm 架构装置 Docker
arm 架构装置 docker-compose
Harbor 官网: https://github.com/goharbor/h…
Harbor 官网没有提供 arm 架构的包, 须要本人编译, 我编译好的版本是:harbor-1.9.1
大家能够按我的博客, 本人去编译, 或评论留言给我, 我发给大家
我编译好的版本是: harbor-1.9.1
arm 架构下编译 Harbor
#下载源码包 https://github.com/goharbor/harbor/archive/v1.9.1.tar.gz
wget https://codeload.github.com/goharbor/harbor/tar.gz/v1.9.1
#解压 harbor 源码包
tar -zxvf v1.9.1.tar.gz
#进入源码根目录
cd harbor-1.9.1
#编辑 harbor.yml 配置文件,批改其中的参数,例如主机名、明码等信息。vim make/harbor.yml
#hostname = reg.mydomain.com
#主机 IP
hostname: 122.9.0.1
#明码
harbor_admin_password: Harbor12345
#批改数据保留目录
data_volume: /data1/harbor
log:
location: /data1/var/log/harbor
#harbor 从 1.6 版本之后仅反对 PostgreSQL 数据库作为内部数据库, 之前版本能够应用 mysql
#能够应用内部的 redis
#也能够应用自带的 redis, 就不要放开正文
external_redis:
host: 192.168.1.1
port: 6379
password: beyond2020
#批改 Dockerfile,将 photon:2.0 批改为 photon:3.0,是因为 photon 3.0 才开始反对 aarch64。#有可能是 photon:1.0 批改为 photon:3.0
find ./ -type f|grep "Dockerfile$"|grep -v "\.D"|xargs sed -i "s#photon:2.0#photon:3.0#g"
find ./ -type f|grep "Dockerfile$"|grep -v "\.D"|xargs sed -i "s#photon:1.0#photon:3.0#g"
#启动编译组件性能。vim Makefile
... ...
BUILDBIN=true
... ...
REGISTRYVERSION=v2.7.1
... ...
#批改以下几个文件,这几处是软件存在的 BUG,请知悉。vim make/photon/Makefile
#批改为: /binary/bin/registry
#如下:
@echo "building registry container for photon..."
@chmod 655 $(DOCKERFILEPATH_REG)/binary/bin/registry && $(DOCKERBUILD) -f $(DOCKERFILEPATH_REG)/$(DOCKERFILENAME_REG) -t $(DOCKERIMAGENAME_REG):$(REGISTRYVERSION)-$(VERSIONTAG) .
@echo "Done."
vim make/photon/registry/Dockerfile
#批改为: COPY ./make/photon/registry/binary/bin/registry /usr/bin
#如下
COPY ./make/photon/common/install_cert.sh /harbor
COPY ./make/photon/registry/entrypoint.sh /
COPY ./make/photon/registry/binary/bin/registry /usr/bin
vim make/photon/registryctl/Dockerfile
#批改为: COPY ./make/photon/registry/binary/bin/registry /usr/bin
#如下:
COPY ./make/photon/common/install_cert.sh /harbor
COPY ./make/photon/registry/binary/bin/registry /usr/bin
COPY ./make/photon/registryctl/start.sh /harbor/
COPY ./make/photon/registryctl/harbor_registryctl /harbor/
#拉取 golang 1.12.12 官网镜像。docker pull golang:1.12.12
#编译、装置和启动 harbor 服务,开启 Notary 和 Clair 性能,执行如下命令。cd harbor-1.9.1
make install GOBUILDIMAGE=golang:1.12.12 VERSIONTAG=v1.9.1 PKGVERSIONTAG=v1.9.1 UIVERSIONTAG=v1.9.1
编译完查看 Harbor 启动状况
docker ps
#redis 始终在重启 Restarting
goharbor/redis-photon:v1.9.1 "redis-server /etc/r…" 6 minutes ago Restarting (139) 19 seconds ago
goharbor/redis-photon:v1.9.1 查看日志报错如下:
<jemalloc>: Unsupported system page size
华为云 arm 架构 docker 启动 redis 报错:: Unsupported system page size
# 再次查看
docker ps
#harbor-core 始终在重启 Restarting
goharbor/harbor-core:v1.9.1 "/harbor/harbor_core" 8 minutes ago Restarting (1) 4 seconds ago
#查看日志报错
[ERROR] [/common/config/manager.go:118]: loadSystemConfigFromEnv failed, config item, key: clair_db_port, err: strconv.Atoi: parsing "": invalid syntax
[FATAL] [/core/main.go:185]: failed to initialize database: register db Ping `default`, pq: password authentication failed for user "postgres"
#进入容器
docker-compose exec postgresql sh
docker exec -ti harbor-db psql
#执行 sql
psql
\l
\c registry
\c registry
TRUNCATE TABLE project_blob;
#退出
\q
#查看日志
tail -f /var/log/harbor/core.log
#进行 harbor
docker-compose stop
#启动 harbor
docker-compose start
#最终解决了下面的问题
vim common/config/core/env
CLAIR_DB_PORT=5432
#还有这个问题:
[FATAL] [/core/main.go:185]: failed to initialize database: register db Ping `default`, pq: password authentication failed for user "postgres"
#删除 database
mkdir /data1/cert/
rm -rf /data1/database
https://github.com/goharbor/harbor/issues/7609
#其实我还做了件事件,进入 harbor-db 的容器 执行了以下命令
su - postgres
psql
alter role postgres with password 'root123';
#而后我又创立了下面那个门路,再 harbor-compose 重启了 而后就好了,我起初又敞开, 删了 /data1/cert/ 又好了,真不知道是什么动作影响了后果。#如果应用内部的 redis, 正文掉 redis 的编译打镜像, 从新编译, 胜利了
vim harbor-1.9.1/make/photon/Makefile
#如下:
_build_redis:
@echo "building redis container for photon..."
#正文了 redis 的编译打镜像
#@$(DOCKERBUILD) -f $(DOCKERFILEPATH_REDIS)/$(DOCKERFILENAME_REDIS) -t $(DOCKERIMAGENAME_REDIS):$(REDISVERSION) .
@echo "Done."
#从新编译
make install GOBUILDIMAGE=golang:1.12.12 VERSIONTAG=v1.9.1 PKGVERSIONTAG=v1.9.1 UIVERSIONTAG=v1.9.1
docker ps
#发现所有 harbor 相干的服务都启动 OK 了,示意装置结束
拜访 Harbor
浏览器拜访
http://122.9.0.1/
默认账号 / 明码:admin/Harbor12345
Docker 配置 Harbor 仓库地址
vim /etc/docker/daemon.json
#减少上面内容,harbor 默认端口为 80 状况,如果非 80,须要在 IP 后加端口
#{"insecure-registries":["harbor 服务端 IP"]}
{"insecure-registries":["122.9.0.1"]}
#从新加载配置
systemctl daemon-reload
#重启 docker
systemctl restart docker
#登录胜利
docker login 122.9.0.1
输出账户和明码
#或者
docker login 122.9.0.1 -u admin -p Harbor12345
#推送镜像到 Harbor 仓库
docker push 122.9.0.1/library/test:1.0
docker-compose 相干命令
docker-compose up -d
docker-compose top
docker-compose ps
docker-compose stop
docker-compose start 再次启动
docker-compose down 停用移除所有容器
docker-compose logs
Harbor 相干镜像保留到网盘
把编译胜利的镜像保存起来
有须要的, 能够评论留言, 发给大家
docker save -o goharbor_harbor-jobservice_arm64.tar goharbor/harbor-jobservice:v1.9.1
docker save -o goharbor_nginx-photon_arm64.tar goharbor/nginx-photon:v1.9.1
docker save -o goharbor_harbor-core_arm64.tar goharbor/harbor-core:v1.9.1
docker save -o goharbor_registry-photon_arm64.tar goharbor/registry-photon:v2.7.1-v1.9.1
docker save -o goharbor_harbor-registryctl_arm64.tar goharbor/harbor-registryctl:v1.9.1
docker save -o goharbor_harbor-portal_arm64.tar goharbor/harbor-portal:v1.9.1
docker save -o goharbor_harbor-db_arm64.tar goharbor/harbor-db:v1.9.1
docker save -o goharbor_redis-photon_arm64.tar goharbor/redis-photon:v1.9.1
docker save -o goharbor_harbor-log_arm64.tar goharbor/harbor-log:v1.9.1
docker save -o goharbor_prepare_arm64.tar goharbor/prepare:v1.9.1
docker save -o photon_arm64.tar photon:3.0
docker save -o debian_arm64.tar debian:buster-slim
docker save -o golang_1_12_12_arm64.tar golang:1.12.12
docker save -o golang_1_11_arm64.tar golang:1.11
docker load -i goharbor_harbor-jobservice_arm64.tar
参考链接:
https://bbs.huaweicloud.com/f…