参考文章: nacos 构建ARM64版本docker镜像
Arm64 架构部署 Nacos
编译 nacos 镜像
下载 nacos-docker 仓库
1
git clone https://github.com/nacos-group/nacos-docker.git
下载指定版本的 nacos 安装包
1
wget https://github.com/alibaba/nacos/releases/download/2.0.2/nacos-server-2.0.2.tar.gz -P ./nacos-docker/build
修改 Dockerfile 文件
1
2
3
4
5# 编辑 Dockerfile 文件,主要修改以下几个部分
ARG NACOS_VERSION=2.0.2 # 需要编译的 Nacos 版本
# 将下载 nacos 压缩包的指令替换成以下指令,并提前下载好对应版本的压缩包到当前目录
COPY nacos-server-2.0.2.tar.gz /home/nacos-server-2.0.2.tar.gz执行构建镜像命令
1
docker build -t registry-changsha.vonebaas.com/publics/nacos-serve:2.0.2 .
将购建好的 nacos 推送到 Harbor 仓库
1
docker push registry-changsha.vonebaas.com/publics/nacos-serve:2.0.2
安装 docker-compose
下载 docker-compose 二进制执行文件
1
wget https://github.com/docker/compose/releases/download/v2.11.2/docker-compose-linux-aarch64
修改文件名以及添加执行权限
1
2
3mv docker-compose-linux-aarch64 /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose检查 docker-compose 版本
1
docker-compose version
使用 docker-compose 部署 nacos
创建 docker-compose.yaml 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25mkdir /usr/local/nacos && cd /usr/local/nacos
cat > docker-compose.yaml <<EOF
version: "3"
services:
nacos:
image: registry-changsha.vonebaas.com/nacos/nacos-server:2.0.2
container_name: nacos
environment:
- MODE=standalone
- SPRING_DATASOURCE_PLATFORM=mysql
- MYSQL_SERVICE_HOST=192.168.0.9
- MYSQL_SERVICE_DB_NAME=nacos_config
- MYSQL_SERVICE_PORT=3306
- MYSQL_SERVICE_USER=nacos
- MYSQL_SERVICE_PASSWORD=6Siknnr6c~Pa
- MYSQL_SERVICE_DB_PARAM=allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useSSL=false
volumes:
- ./standalone-logs/:/home/nacos/logs
ports:
- "8848:8848"
- "9848:9848"
- "9555:9555"
restart: always
EOF下载镜像
1
docker-compose pull
启动服务
1
docker-compose up -d
使用 ingress-nginx 代理 nacos
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54cat > projects/others/nacos-ingress.yaml <<EOF
apiVersion: v1
kind: Service
metadata:
labels:
app: nacos
name: nacos
namespace: publics
spec:
ports:
- port: 80
name: http
protocol: TCP
targetPort: 8848
type: ClusterIP
---
apiVersion: v1
kind: Endpoints
metadata:
labels:
app: nacos
name: nacos
namespace: publics
subsets:
- addresses:
- ip: 192.168.0.9
ports:
- name: http
port: 8848
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nacos
namespace: publics
annotations:
nginx.ingress.kubernetes.io/proxy-body-size: 20m
spec:
ingressClassName: nginx
rules:
- host: nacos.vonebaas.com
http:
paths:
- backend:
service:
name: nacos
port:
number: 80
path: /
pathType: ImplementationSpecific
EOF
$ kubectl create -f nacos-ingress.yaml