麒麟系统适配环境准备(x86_64运行arm容器)
公司产品需要做麒麟系统适配,而该系统的运行环境是在arm的架构上运行的,前期准备在x86的虚拟机通过qemu工具做指令转换,达到运行arm容器。由于系统是基于Ubuntu做的二次封装,选择镜像使用ubuntu。
# 麒麟系统适配环境准备(x86运行arm容器)
ubuntu 镜像ISO:https://mirrors.tuna.tsinghua.edu.cn/ubuntu-releases/20.04/ubuntu-20.04.4-desktop-amd64.iso
# 安装docker
#更新配置源
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
#安装docker
apt-get -y install docker-ce docker-ce-cli containerd.io docker-compose-plugin curl wget
#默认安装就会启动服务,如果想要停止docker服务,最好是三个服务都一起停止
systemctl status docker.service
systemctl status docker.socket
systemctl status containerd.service
2
3
4
5
6
7
8
9
10
11
12
13
14
# 配置qemu
- 下载,
cd /opt
wget https://github.com/multiarch/qemu-user-static/releases/download/v5.1.0-5/qemu-aarch64-static.tar.gz
tar xf qemu-aarch64-static.tar.gz
cp -a qemu-aarch64-static /usr/bin/
ls -l /usr/bin/qemu-aarch64-static
2
3
4
5
- 配置arm指令转换镜像
会有一堆的提示信息
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- 测试,运行一个arm镜像
docker run --rm -t arm64v8/ubuntu uname -a
- 常用镜像
docker pull arm64v8/ubuntu:latest #20.04
docker pull arm64v8/mysql:oracle
docker pull arm64v8/nginx:1.20
docker pull arm64v8/postgres:12.10
2
3
4
# 制作一个postgis3的postgresql-12数据库
# 制作docker镜像
- 基于已有的镜像添加postgis插件
#cat Dockerfile
FROM arm64v8/postgres:12.10
MAINTAINER <yangfk>
RUN apt-get -y update; apt-get -y install gnupg2 wget ca-certificates rpl pwgen lsb-release \
&& wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
&& echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list \
&& apt-get -y update; apt-get -y install postgis postgresql-12-postgis-3 \
&& rm -rf /var/lib/apt/lists/* && apt-get clean
#postgis postgresql-9.5-postgis-2
EXPOSE 5432
CMD ["postgres"]
2
3
4
5
6
7
8
9
10
11
12
13
14
- 构建镜像
docker build -t arm64v8/postgres-postgis3:12.10 .
- 启动postgresql-12
docker run -d \
--name some-postgres \
-p 5432:5432 \
-e POSTGRES_PASSWORD=123456 \
-e PGDATA=/var/lib/postgresql/data/pgdata \
-v /opt/server/pgdata:/var/lib/postgresql/data arm64v8/postgres-postgis3:12.10
2
3
4
5
6
# 制作一个arm版jdk
选择合适的版本:
jdk-8u251-linux-arm64-vfp-hflt.tar.gz
# 制作docker镜像
root@dev-yfk-machine:/opt/jdk/jdk# cat Dockerfile
FROM arm64v8/ubuntu:latest
#20.04
MAINTAINER "yangfk"
LABEL version="jdk-8u251"
WORKDIR /java
ADD ./jdk-8u251-linux-arm64-vfp-hflt.tar.gz /java/
#注意清理cache
RUN rm -rf /var/lib/apt/lists/*
#配置时区
ENV TZ Asia/Shanghai
#配置JDK环境变量
ENV JAVA_HOME /java/jdk1.8.0_251
ENV CLASSPATH=$JAVA_HOME/bin
ENV PATH $JAVA_HOME/bin:$PATH
ENV LANG en_US.UTF-8
WORKDIR /java-work
#CMD ["java", "-jar", "system-service.jar", "--spring.profiles.active=dev"]
#CMD ["java", "-jar", "system-service.jar", "--spring.config.location=classpath:/application.yml,/java-work/application-product.yml"]
CMD ["bash"]
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
- 构建镜像
docker build -t arm64v8/ubuntu/jdk:8u251 .
- 测试
docker run -it --rm --name jdk-test arm64v8/ubuntu/jdk:8u251 java -version
# 制作arm版nacos
# 制作docker镜像
基于docker镜像
nacos/nacos-server:v2.1.0-slim
,制作arm版的nacos
root@dev-yfk-machine:/opt/nacos-2.1.0# cat Dockerfile
FROM arm64v8/ubuntu:latest
#20.04
MAINTAINER "yangfk"
LABEL version="jdk-8u251",nacos="2.1.0"
#docker镜像nacos/nacos-server:v2.1.0-slim 拷贝/home/nacos目录制作nacos.tar包
ADD ./jdk-8u251-linux-arm64-vfp-hflt.tar.gz /java/
ADD ./nacos.tar.gz /home/
WORKDIR /home/nacos
#输出信息软链接
RUN touch logs/start.out && ln -sf /dev/stdout logs/start.out && ln -sf /dev/stderr logs/start.out \
&& rm -rf /var/lib/apt/lists/*
#配置JDK环境变量
ENV JAVA_VERSION=1.8.0_251
ENV JAVA_HOME /java/jdk1.8.0_251
ENV CLASSPATH=$JAVA_HOME/bin
ENV PATH $JAVA_HOME/bin:$PATH
#nacos
ENV MODE=cluster PREFER_HOST_MODE=ip BASE_DIR=/home/nacos CLASSPATH=.:/home/nacos/conf: CLUSTER_CONF=/home/nacos/conf/cluster.conf FUNCTION_MODE=all NACOS_USER=nacos JAVA=/java/jdk1.8.0_251/bin/java JVM_XMS=1g JVM_XMX=1g JVM_XMN=512m JVM_MS=128m JVM_MMS=320m NACOS_DEBUG=n TOMCAT_ACCESSLOG_ENABLED=false TZ=Asia/Shanghai LANG=en_US.UTF-8
EXPOSE 8848
ENTRYPOINT ["bin/docker-startup.sh"]
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
- 构建镜像
docker build -t arm64v8/nacos-server:v2.1.0 .
- 启动mariadb,
docker run --name some-mariadb \
-v /opt/server/mariadb:/var/lib/mysql -v /opt/server/mariadb/some-mariadb-socket:/var/run/mysqld \
-e MARIADB_MYSQL_LOCALHOST_USER=1 -e MARIADB_MYSQL_LOCALHOST_GRANTS="RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR" -e MARIADB_ROOT_PASSWORD=123456 \
-p 3306:3306 \
-d arm64v8/mariadb:10.4.22
2
3
4
5
按照官方文档,导入sql,修改配置文件,
nacos.io官方文档 (opens new window)
- 启动nacos
docker run -d --restart=always \
--name nacos-server \
-p 8848:8848 \
--env-file /opt/server/nacos/nacos-cluster/env/nacos-standlone-mysql.env \
-v /opt/server/nacos/nacos-cluster/standalone-logs/:/home/nacos/logs \
-v /opt/server/nacos/nacos-cluster/init.d/custom.properties:/home/nacos/init.d/custom.properties \
arm64v8/nacos-server:v2.1.0
2
3
4
5
6
7
# 麒麟系统
实际使用是这样的,
- 查看系统
- 配置源
root@greatwall:/opt# cat /etc/apt/sources.list
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.0 main restricted universe multiverse
deb http://archive.kylinos.cn/kylin/partner juniper main
2
3
- 安装应用
apt install -y postgresql redis-server nginx mariadb-server
apt install -y postgis
2
配置jdk环境,直接使用Java -jar XXX.jar 运行项目,包括nacos
运行nacos
启动nacos
wget -c https://github.com/alibaba/nacos/releases/download/2.1.0/nacos-server-2.1.0.zip
cd /opt/server/nacos/bin
bash startup.sh -m standalone
2
3
4
- 运行minio 7
mkdir -p minio/{bin,data,logs}
#启动minio
wget -c https://dl.min.io/server/minio/release/linux-arm64/archive/minio.RELEASE.2021-06-07T21-40-51Z
mv minio.RELEASE.2021-06-07T21-40-51Z minio/bin/minio && chmod +x minio/bin/minio
#浏览器访问的账号和密码,各节点要保持一致,密码不能过于简单否则启动失败
export MINIO_ACCESS_KEY=minio
export MINIO_SECRET_KEY=Yfklife.cn
./minio/bin/minio server --address :29200 ./minio/data &> ./minio/logs/minio.log 2>&1 &
2
3
4
5
6
7
8
9
10
11
12
# 麒麟系统配置源
# 桌面系统源
软件源使用方法:在系统的/etc/apt/sources.list文件中,根据不同版本填入以下内容
#4.0.2桌面版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2-desktop main restricted universe multiverse
#4.0.2-sp1桌面版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp1-desktop main restricted universe multiverse
#4.0.2-sp2桌面版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-desktop main restricted universe multiverse
#4.0.2服务器版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2-server main restricted universe multiverse
#4.0.2-sp1服务器版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp1-server main restricted universe multiverse
#4.0.2-sp2服务器版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server main restricted universe multiverse
#4.0.2-sp2 FT2000+服务器版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp2-server-ft2000 main restricted universe multiverse
#4.0.2-sp3桌面版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp3-desktop main restricted universe multiverse
#4.0.2-sp3服务器版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp3-server main restricted universe multiverse
#4.0.2-sp4桌面版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 4.0.2sp4 main restricted universe multiverse
#10.0版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.0 main restricted universe multiverse
#10.1版本:
deb http://archive.kylinos.cn/kylin/KYLIN-ALL 10.1 main restricted universe multiverse
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
# 服务器centos8源
Kylin Linux Advanced Server
###Kylin Linux Advanced Server 10 - os repo###
[ks10-adv-os]
name = Kylin Linux Advanced Server 10 - Os
baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/base/$basearch/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
[ks10-adv-updates]
name = Kylin Linux Advanced Server 10 - Updates
baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/updates/$basearch/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 1
[ks10-adv-addons]
name = Kylin Linux Advanced Server 10 - Addons
baseurl = http://update.cs2c.com.cn:8080/NS/V10/V10SP1.1/os/adv/lic/addons/$basearch/
gpgcheck = 1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-kylin
enabled = 0
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
记录
默认适配服务器端口全放开,在安全组添加一个ssh 22 端口策略,其余端口使用iptables命令添加
放开 58080 端口
iptables -A INPUT -p tcp --dport 58080 -m state --state NEW,ESTABLISHED -j ACCEPT
# 个人存储下载地址。。。
#docker镜像
arm64v8-postgres-postgis3.12.10.tar.gz
arm64v8-mariadb-10.4.22.tar.gz
arm64v8-redis-latest.tar.gz
arm64v8-nacos-server-v2.1.0.tar.gz
arm64v8-nginx-1.20.tar.gz
arm64v8-ubuntu-jdk-8u251.tar.gz
minio-RELEASE.2020-07-22T00-26-33Z-arm64.tar.gz
multiarch-qemu-user-static-latest.tar.gz
qemu-aarch64-static.tar.gz
jdk-8u251-linux-arm64-vfp-hflt.tar.gz
2
3
4
5
6
7
8
9
10
11
12
13
14
如果对你有帮助,给博主买杯咖啡吧