当前位置:   article > 正文

银河麒麟操作系统离线安装Docker-tomcat服务_银河麒麟安装tomcat

银河麒麟安装tomcat

本文只适用X86架构的麒麟操作系统
由于麒麟操作系统的内核使用的是CentOS 8 ,我们只需下载适用CentOS系统的Docker版本。

1. 从官方下载Docker安装包并上传到服务器
https://download.docker.com/linux/static/stable/x86_64/

2. 解压安装包

tar -xvf docker-19.03.9.tgz
  • 1

3. 将解压出来的docker文件内容移动到 /usr/bin/ 目录下

#移动命令 复制命令请用cp
mv docker/* /usr/bin/ 
  • 1
  • 2

4. 将docker注册为service服务

vi /etc/systemd/system/docker.service
  • 1

5. 配置全局参数

mkdir -p /etc/docker

tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://06us4gvd.mirrors.aliyuncs.com"],
  "log-driver":"json-file",
  "log-opts": {"max-size":"500m", "max-file":"3"}
}
EOF
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

6. 配置docker.service

[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
  • 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

7. 启动docker

chmod +x /etc/systemd/system/docker.service #设置权限
systemctl daemon-reload
systemctl start docker            #启动Docker
systemctl enable docker.service   #设置开机自启
  • 1
  • 2
  • 3
  • 4

8. 验证

systemctl status docker  #查看Docker状态
docker -v                #查看Docker版本
  • 1
  • 2

9. 将制作好的镜像上传到服务器
10. 加载相关镜像

#!/bin/sh
#安装mysql镜像
docker load -i /soft/images/mysql5.7.tar
#安装ftp镜像
docker load -i /soft/images/ftp.tar
#安装open-office镜像
docker load -i /soft/images/open-office.tar
#安装xxl-job镜像
docker load -i /soft/images/xxl-job.tar
#安装tomcat镜像
docker load -i /soft/images/tomcat8.5.7.tar
#安装考试系统tomcat镜像
docker load -i /soft/images/exam.tar
#安装Adminer镜像
docker load -i /soft/images/adminer.tar
#查看安装镜像列表
docker images
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

11. 启动tomcat服务

docker run --name $CONTAINER -p $PORT:8080 -v /ReachData/$CONTAINER/web:/usr/local/docker/apache-tomcat-8.5.77/webapps -v /ReachData/$CONTAINER/logs:/usr/local/docker/apache-tomcat-8.5.77/logs -v /ReachData/$CONTAINER/file/RecData:/RecData   -v /ReachData/$CONTAINER/conf/server.xml:/usr/local/docker/apache-tomcat-8.5.77/conf/server.xml --restart=always -v /etc/localtime:/etc/localtime:ro --link mysql:mysql --link open-office:open-office -d f780b6663e72
  • 1

系统启动后报错,使用 docker logs 命令查看日志

library initialization failed - unable to allocate file descriptor table - out of memoryAborted (core dumped)
  • 1

解决方案:在执行 docker run 命令时添加参数 --ulimit nofile=65535:65535 --ulimit nproc=65535:65535 --privileged=true

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Li_阴宅/article/detail/940822
推荐阅读
相关标签
  

闽ICP备14008679号