• 基于Docker部署GeoWebCache(离线地图)


    1前言

    正常情况,生产环境有可能是离线环境,那么就先按照《CentOS7离线环境安装Docker-CE各种版本》一文进行安装docker

    2 Docker-各应用部署

    上传或把各应用的镜像到服务器上,所需镜像我打包放在档案管理部署.zip解压后的档案管理部署/镜像/目录下

    [root@localhost jack]# ll
    总用量 5087704
    drwxrwxr-x. 2 1000 1000        138 3月  28 02:42 docker
    -rw-r--r--. 1 root root   48053260 8月   7 08:36 docker-18.09.4.tgz
    -rw-r--r--. 1 root root  922612736 8月   7 08:37 es-head.tar
    -rw-r--r--. 1 root root 3096436736 8月   7 08:38 es-ik.tar
    -rw-r--r--. 1 root root  765418496 8月   7 08:38 jw-ftp.tar
    -rw-r--r--. 1 root root  377282560 8月   7 08:38 jw-mysql.tar
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    2.1 部署mysql

    [root@localhost jack]# docker load -i jw-mysql.tar
    5dacd731af1b: Loading layer [==================================================>]  58.45MB/58.45MB
    f411d8bde01c: Loading layer [==================================================>]  338.4kB/338.4kB
    0aa7d65147ef: Loading layer [==================================================>]  10.44MB/10.44MB
    3437f67a712b: Loading layer [==================================================>]  4.472MB/4.472MB
    ec41e34b35a0: Loading layer [==================================================>]  1.536kB/1.536kB
    458d25c646d8: Loading layer [==================================================>]  46.15MB/46.15MB
    97874ea0e7f9: Loading layer [==================================================>]  31.74kB/31.74kB
    5075b9328698: Loading layer [==================================================>]  3.584kB/3.584kB
    364557e875f1: Loading layer [==================================================>]  257.3MB/257.3MB
    9209148debed: Loading layer [==================================================>]  9.728kB/9.728kB
    82582edf9553: Loading layer [==================================================>]  1.536kB/1.536kB
    c05b3f3ca6d3: Loading layer [==================================================>]  8.704kB/8.704kB
    Loaded image: jw-mysql:latest
    [root@localhost jack]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    jw-mysql            latest              05f525546ef7        14 hours ago        372MB
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17

    可以看到,jw-mysql的镜像已经加载出来了,下面就开始运行mysql容器了

    [root@localhost jack]# docker run -di --restart=always --name jw-mysql -p 3306:3306 -v /apps/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d --privileged=true -e MYSQL_ROOT_PASSWORD=123456 jw-mysql
    844bd13bc5c7146288dbc083d1800c105c81c0725055adfdf1eaca4b73990e09
    [root@localhost jack]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                               NAMES
    844bd13bc5c7        jw-mysql            "docker-entrypoint.s…"   5 seconds ago       Up 4 seconds        0.0.0.0:3306->3306/tcp, 33060/tcp   jw-mysql
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    解释一下:

    • –restart=always 总是启动,相当于开机自动重启
    • –name jw-mysql 代表容器的名称,方便后续的操作
    • -p 3306:3306 代表端口映射,格式为 宿主机映射端口:容器运行端口
    • -v /apps/mysql/mysql.conf.d:/etc/mysql/mysql.conf.d 映射mysql配置文件所在目录,方便后期修改配置文件
    • –privileged=true 因为如果CentOS7中的安全模块selinux把权限禁掉了,我们需要添加这个参数来解决挂载目录没有权限的问题
    • -e MYSQL_ROOT_PASSWORD=你的数据库密码 代表添加环境变量MYSQL_ROOT_PASSWORD是root用户的登陆密码

    验证一下:

    验证数据库是否部署成功

    至此,mysql在docker中的部署已经成功!

    2.2 部署文件服务器(VSFTP+NGINX+RSYNC)

    vsftp和nginx、rsync封装到了一起,所以,现在开始加载ftp和nginx的镜像jw-ftp

    [root@localhost jack]# docker load -i jw-ftp.tar
    d69483a6face: Loading layer [==================================================>]  209.5MB/209.5MB
    e09789e022b9: Loading layer [==================================================>]  37.68MB/37.68MB
    0fcf5f72ae39: Loading layer [==================================================>]   23.3MB/23.3MB
    fcc1601a8810: Loading layer [==================================================>]  4.096kB/4.096kB
    f5bd29f17664: Loading layer [==================================================>]  4.096kB/4.096kB
    3dc53c092fe8: Loading layer [==================================================>]  3.072kB/3.072kB
    22c8da61c837: Loading layer [==================================================>]   5.12kB/5.12kB
    ed0699bb234c: Loading layer [==================================================>]   5.12kB/5.12kB
    4ba1b4dbeb92: Loading layer [==================================================>]  2.048kB/2.048kB
    f52ded63720f: Loading layer [==================================================>]  2.048kB/2.048kB
    9eb89bfe8f09: Loading layer [==================================================>]  104.8MB/104.8MB
    927a7a728354: Loading layer [==================================================>]  283.6MB/283.6MB
    1edd7b9640a1: Loading layer [==================================================>]  105.6MB/105.6MB
    15e134a323cb: Loading layer [==================================================>]  36.35kB/36.35kB
    21b466c70f76: Loading layer [==================================================>]  349.7kB/349.7kB
    f9c9542b766b: Loading layer [==================================================>]     64kB/64kB
    3bb7355a4d26: Loading layer [==================================================>]  382.5kB/382.5kB
    Loaded image: jw-ftp:latest
    [root@localhost jack]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    jw-ftp              latest              de9910f5b16b        14 hours ago        750MB
    jw-mysql            latest              05f525546ef7        14 hours ago        372MB
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    可以看到,jw-ftp的镜像已经加载出来了,下面就开始运行jw-ftp容器了

    [root@localhost jack]# docker run -d --name jw-ftp --restart=always -v /home/vsftpd:/home/vsftpd -v /var/log/vsftpd/:/var/log/vsftpd -v /var/log/nginx:/var/log/nginx --privileged=true -p 80:80 -p 20020:20 -p 20021:21 -p 21100-21110:21100-21110 -e FTP_USER=jw -e FTP_PASS=jw2019 -e PASV_ADDRESS=192.168.142.129 jw-ftp
    e961db12954ee3dda0d09253f69321abab06d0d0f26b6690ed87504f9920609a
    [root@localhost jack]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                    NAMES
    e961db12954e        jw-ftp              "/usr/sbin/run-vsftp…"   4 seconds ago       Up 2 seconds        0.0.0.0:80->80/tcp, 0.0.0.0:21100-21110->21100-21110/tcp, 0.0.0.0:20020->20/tcp, 0.0.0.0:20021->21/tcp   jw-ftp
    844bd13bc5c7        jw-mysql            "docker-entrypoint.s…"   20 minutes ago      Up 20 minutes       0.0.0.0:3306->3306/tcp, 33060/tcp                                                                        jw-mysql
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    解释一下:

    • –restart=always 总是启动,相当于开机自动重启
    • –name jw-ftp 代表容器的名称,方便后续的操作
    • -p 80:80 代表端口映射,格式为 宿主机映射端口:容器运行端口,这里映射的是nginx默认的端口号80
    • -p 20020:20 这里映射的是vsftp 的端口号20到20020 我这边本机的20端口已被占用,所以映射到20020
    • -p 20021:21 这里映射的是vsftp 的端口号21到20021 我这边本机的20端口已被占用,所以映射到20021
    • -p 21100-21110:21100-21110 映射的是被动模式下端口使用范围
    • -v /home/vsftpd:/home/vsftpd 进行文件目录的映射 FTP_UESR 和FTP_PASS如果设定了会在container里面的/vsftpd/virtual_users.txt
    • –privileged=true 因为如果CentOS7中的安全模块selinux把权限禁掉了,我们需要添加这个参数来解决挂载目录没有权限的问题
    • -e FTP_USER=jw -e代表配置环境变量,这里是设置FTP的用户名
    • -e FTP_PASS=jw2019 -e代表配置环境变量,这里是设置FTP的密码
    • PASV_ADDRESS指的的宿主机的IP地址

    还没完,进入jw-ftp容器中

    [root@localhost jack]# docker exec -it jw-ftp bash
    [root@e961db12954e /]# cd /etc/nginx/
    [root@e961db12954e nginx]# ls
    conf.d  fastcgi_params  koi-utf  koi-win  mime.types  modules  nginx.conf  on  scgi_params  uwsgi_params  win-utf
    [root@e961db12954e nginx]# vi nginx.conf 
    [root@e961db12954e nginx]# pwd
    /etc/nginx
    [root@e961db12954e nginx]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    修改nginx配置

    修改nginx配置文件

    重启nginx服务器,先进入/etc/nginx目录,执行nginx -c nginx.conf,校验一下ps aux | grep nginx

    [root@9845398ab81e /]# cd /etc/nginx
    [root@9845398ab81e nginx]# pwd
    /etc/nginx
    [root@9845398ab81e nginx]# nginx -c nginx.conf
    [root@9845398ab81e nginx]# ps aux | grep nginx
    root         55  0.0  0.0  46456  1000 ?        Ss   Aug02   0:00 nginx: master process nginx -c nginx.conf
    root         56  0.0  0.0  46960  2192 ?        S    Aug02   0:00 nginx: worker process
    root        520  0.0  0.0   9088   672 pts/3    S+   06:14   0:00 grep --color=auto nginx
    [root@9845398ab81e nginx]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    验证一下:我使用的FileZilla软件+Chrome浏览器测试

    ftp测试

    我们打开浏览器看看,可以看到ftp部署成功

    FTP验证

    同步服务:

    查看是否安装了rsync,默认我们的镜像是封装了rsync,这里做个确认

    [root@9845398ab81e /]# rsync --version
    rsync  version 3.1.2  protocol version 31
    Copyright (C) 1996-2015 by Andrew Tridgell, Wayne Davison, and others.
    Web site: http://rsync.samba.org/
    Capabilities:
        64-bit files, 64-bit inums, 64-bit timestamps, 64-bit long ints,
        socketpairs, hardlinks, symlinks, IPv6, batchfiles, inplace,
        append, ACLs, xattrs, iconv, symtimes, prealloc
    
    rsync comes with ABSOLUTELY NO WARRANTY.  This is free software, and you
    are welcome to redistribute it under certain conditions.  See the GNU
    General Public Licence for details.
    [root@9845398ab81e /]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13

    后续的同步服务未完善,待续……

    至此,文件服务器也部署成功

    2.3 部署搜索引擎(es-ik和es-head)

    es比较大,加载过程比较慢,耐心等待

    [root@localhost jack]# docker load -i es-ik.tar 
    071d8bd76517: Loading layer [==================================================>]  210.2MB/210.2MB
    f82bc681981a: Loading layer [==================================================>]  310.5MB/310.5MB
    eba581f49a5d: Loading layer [==================================================>]   95.7MB/95.7MB
    4e46fe2301ba: Loading layer [==================================================>]  311.3kB/311.3kB
    d49eb1b97d3c: Loading layer [==================================================>]  237.5MB/237.5MB
    893043adafbe: Loading layer [==================================================>]   7.68kB/7.68kB
    ed95fd8006d7: Loading layer [==================================================>]  9.728kB/9.728kB
    72c73b88b2dc: Loading layer [==================================================>]  25.31MB/25.31MB
    cb6b87a02fdf: Loading layer [==================================================>]  2.217GB/2.217GB
    Loaded image: es-ik:latest
    [root@localhost jack]# docker load -i es-head.tar 
    b6ca02dfe5e6: Loading layer [==================================================>]  128.9MB/128.9MB
    60a0858edcd5: Loading layer [==================================================>]  45.19MB/45.19MB
    53c779688d06: Loading layer [==================================================>]  126.6MB/126.6MB
    0a5e2b2ddeaa: Loading layer [==================================================>]  330.5MB/330.5MB
    fa18e5ffd316: Loading layer [==================================================>]  352.3kB/352.3kB
    604c78617f34: Loading layer [==================================================>]  113.7kB/113.7kB
    cf2eea3d6e04: Loading layer [==================================================>]  50.16MB/50.16MB
    d556e03b8284: Loading layer [==================================================>]   2.56kB/2.56kB
    95ea76455b84: Loading layer [==================================================>]  12.72MB/12.72MB
    ce5705289a91: Loading layer [==================================================>]  4.096kB/4.096kB
    d09533ddfc0d: Loading layer [==================================================>]  143.3MB/143.3MB
    eb415bbb4658: Loading layer [==================================================>]  23.71MB/23.71MB
    584171f3627d: Loading layer [==================================================>]  61.05MB/61.05MB
    Loaded image: es-head:latest
    [root@localhost jack]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    jw-ftp              latest              de9910f5b16b        22 hours ago        750MB
    es-head             latest              550e9d955b41        23 hours ago        884MB
    es-ik               latest              ab547b99477e        23 hours ago        3.08GB
    jw-mysql            latest              05f525546ef7        23 hours ago        372MB
    [root@localhost jack]# 
    
    
    • 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

    可以看到,es-ik和es-head的镜像已经加载出来了,下面就开始运行这两个容器

    [root@localhost jack]# docker run -d --name es-ik --restart=always -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" es-ik
    32cc99b397cba61196cd2f3f937a85d38bd893ae62362043dca0954d6d39f172
    [root@localhost jack]# docker run -d --name es-head --restart=always -p 9100:9100 es-head
    4ba8a0fc22df48cbde5365d04ab54845a0961264c1f1032c423a0c82c03d3d57
    [root@localhost jack]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                    NAMES
    4ba8a0fc22df        es-head             "/bin/sh -c 'grunt s…"   7 seconds ago       Up 5 seconds        0.0.0.0:9100->9100/tcp                                                                                   es-head
    32cc99b397cb        es-ik               "/usr/local/bin/dock…"   22 seconds ago      Up 18 seconds       0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp                                                           es-ik
    e961db12954e        jw-ftp              "/usr/sbin/run-vsftp…"   9 hours ago         Up 9 hours          0.0.0.0:80->80/tcp, 0.0.0.0:21100-21110->21100-21110/tcp, 0.0.0.0:20020->20/tcp, 0.0.0.0:20021->21/tcp   jw-ftp
    844bd13bc5c7        jw-mysql            "docker-entrypoint.s…"   9 hours ago         Up 9 hours          0.0.0.0:3306->3306/tcp, 33060/tcp                                                                        jw-mysql
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    解释一下:

    • –restart=always 总是启动,相当于开机自动重启
    • –name es-ik 代表容器的名称,方便后续的操作
    • –name es-head 代表容器的名称,方便后续的操作
    • -p 9100:9100 代表端口映射,格式为 宿主机映射端口:容器运行端口
    • -e “discovery.type=single-node” 环境配置,单节点模式

    验证一下:

    在本机浏览器输入http://IP:9100,如果出现如下图信息表示成功,否则检查一下防火墙是否打开了或者端口号没开放,在主机上curl IP:9100检查宿主机上是否可以,否则删除原来的容器,重新创建容器再试试

    9100信息

    至此,搜索引擎部署成功!

    2.4 部署地图服务器

    前期准备

    1. 一台服务器,装好Docker
    2. 下载GeoWebCache最新版war包 地址
    3. 下载瓦片 下载教程

    如图:GeoWebCache.war、瓦片包,这里可以用我给大家准备的,下载地址 点我 ,当然,你可以自己去官网下载,本教程编写时最新版本是:1.15.2版本
    资料包

    瓦片包解压出来是这样的:

    瓦片包

    部署

    docker拉取Tomcat镜像
    拉取tomcat镜像

    编写Dockerfile文件

    FROM tomcat:latest
    MAINTAINER jack "755344386@qq.com"
    WORKDIR /usr/local
    ADD geowebcache.war /usr/local/tomcat/webapps/geowebcache.war
    ENV TZ=Asia/Shanghai
    RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    构建geowebcache镜像gwc

    构建geowebcache镜像gwc

    运行gwc容器

    docker run -d --restart=always --name gwc -p 9001:8080 -v /apps/jack/webapps:/usr/local/tomcat/webapps -v /apps/jack/map:/usr/map -v /apps/jack/temp/geowebcache:/usr/local/tomcat/temp/geowebcache tomcat
    
    • 1

    运行gwc容器

    将资料包上传到服务器

    在这里插入图片描述

    将war包拷贝到webapps下(/apps/jack/webapps/)

    [root@localhost Gis Map]# cp geowebcache.war /apps/jack/webapps/
    
    • 1

    在这里插入图片描述
    将瓦片包拷贝到/apps/jack/map/layers/

    [root@localhost Gis Map]# cp layers.tar.gz /apps/jack/map/layers/
    
    • 1

    在这里插入图片描述
    然后将瓦片包解压出来,耐心等待,有点多

    [root@localhost Gis Map]# cd /apps/jack/map/layers/
    [root@localhost layers]# ll
    -rw-r--r--.  1 root root 166292342 8月   9 16:54 layers.tar.gz
    [root@localhost Gis Map]# tar -zxvf layers.tar.gz
    [root@localhost layers]# ll
    总用量 162408
    drwxrwxrwx. 13 root root       127 7月   5 18:28 _alllayers
    -rwxrwxrwx.  1 root root       408 7月   2 20:20 conf.cdi
    -rwxrwxrwx.  1 root root      6581 7月   2 20:24 conf.xml
    -rw-r--r--.  1 root root 166292342 8月   9 16:54 layers.tar.gz
    [root@localhost layers]# 
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12

    在这里插入图片描述

    重启gwc容器

    [root@localhost layers]# docker ps
    CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                             NAMES
    babe543bf176        tomcat                "catalina.sh run"        About an hour ago   Up About an hour    0.0.0.0:9001->8080/tcp                            gwc
    8dbbb4f3d87d        jenkins/jenkins:lts   "/sbin/tini -- /usr/…"   7 days ago          Up 7 days           0.0.0.0:9003->8080/tcp, 0.0.0.0:9004->50000/tcp   jenkins
    1685ca22d525        jw-mysql              "docker-entrypoint.s…"   5 weeks ago         Up 11 days          33060/tcp, 0.0.0.0:6033->3306/tcp                 jw-mysql
    [root@localhost layers]# docker restart gwc
    gwc
    [root@localhost layers]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    在本地浏览器输入地址:http://192.168.142.128:9001/geowebcache 访问,如下图,成功了

    在这里插入图片描述

    配置文件

    在开始配置文件之前,先停掉gwc容器

    [root@localhost layers]# docker stop gwc
    gwc
    [root@localhost layers]# 
    
    • 1
    • 2
    • 3

    进入webapps,删除.war包,删除之前确认已经停掉gwc容器

    [root@localhost ~]# cd /apps/jack/webapps/
    [root@localhost webapps]# ll
    总用量 58300
    drwxr-x---. 4 root root       80 8月   9 16:49 geowebcache
    -rw-r--r--. 1 root root 59696648 8月   9 16:49 geowebcache.war
    [root@localhost webapps]# rm -rf geowebcache.war 
    [root@localhost webapps]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    进入项目目录WEB-INF

    [root@localhost webapps]# cd geowebcache/WEB-INF/
    [root@localhost WEB-INF]# ll
    总用量 96
    drwxr-x---. 2 root root    94 8月   9 16:49 classes
    -rw-r-----. 1 root root   375 11月 23 2016 geowebcache-arcgiscache-context.xml
    -rw-r-----. 1 root root 10354 1月  18 2019 geowebcache-core-context.xml
    -rw-r-----. 1 root root  1959 2月   9 2018 geowebcache-diskquota-context.xml
    -rw-r-----. 1 root root   543 11月 23 2016 geowebcache-distributed.xml
    -rw-r-----. 1 root root   717 11月 23 2016 geowebcache-georss-context.xml
    -rw-r-----. 1 root root   692 11月 23 2016 geowebcache-gmaps-context.xml
    -rw-r-----. 1 root root   569 2月   9 2018 geowebcache-kmlservice-context.xml
    -rw-r-----. 1 root root  1022 1月  18 2019 geowebcache-rest-context.xml
    -rw-r-----. 1 root root   553 8月  21 2018 geowebcache-s3storage-context.xml
    -rw-r-----. 1 root root  2583 1月  18 2019 geowebcache-security.xml
    -rw-r-----. 1 root root  1848 8月  21 2018 geowebcache-servlet.xml
    -rw-r-----. 1 root root  1102 8月  21 2018 geowebcache-sqlite-context.xml
    -rw-r-----. 1 root root   595 11月 23 2016 geowebcache-tmsservice-context.xml
    -rw-r-----. 1 root root   455 11月 23 2016 geowebcache-virtualearth-context.xml
    -rw-r-----. 1 root root  7067 1月  18 2019 geowebcache-wmsservice-context.xml
    -rw-r-----. 1 root root   918 8月  21 2018 geowebcache-wmtsservice-context.xml
    drwxr-x---. 2 root root  8192 8月   9 16:49 lib
    -rw-r-----. 1 root root    38 11月 23 2016 users.properties
    -rw-r-----. 1 root root  1394 2月   9 2018 web.xml
    [root@localhost WEB-INF]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24

    修改我们的第一个配置文件geowebcache-core-context.xml,打开并修改这个文件中的内容,然后保存


    1. 在这里插入图片描述

    修改第二个配置文件web.xml 这个文件也在WEB-INF目录下(/apps/jack/webapps/geowebcache/WEB-INF)

    在文件最后增加如下红框内容,标签内容指向的是要映射的缓存路径,修改完成,保存

    在这里插入图片描述

    红框内容:

      
        GEOWEBCACHE_CACHE_DIR
        /usr/map/cache
      
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    修改第三个配置文件 geowebcache.xml 这个文件就在上图第二步中value内容所在路径下,因为我们映射出来了,所以进入 /apps/jack/temp/geowebcache/ 这个目录根据自己映射的路径去进入

    在这里插入图片描述

    修改geowebcache.xml 文件

    在这里插入图片描述

    删除最后面标签内的所有内容,替换成如下红框的内容,保存

    在这里插入图片描述

    红框内容:

    
          gis_map
          /usr/map/layers/conf.xml
          
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

    OK,配置文件都修改完成,重启gwc容器

    [root@localhost WEB-INF]# docker restart gwc
    gwc
    [root@localhost WEB-INF]# 
    
    • 1
    • 2
    • 3

    出现如下图,表示成功了一半,嘿嘿嘿

    在这里插入图片描述

    写了个Demo测试是否部署成功!

    修改demo目录下index.html中的这一行,如图红框中,ip:端口号(你的gwc访问)

    在这里插入图片描述
    看到没,地图出来了,完美成功
    在这里插入图片描述

    2.5 部署jaf项目

    先将java:8镜像加载出来

    [root@localhost jack]# docker load -i java.tar 
    a2ae92ffcd29: Loading layer [==================================================>]  128.9MB/128.9MB
    0eb22bfb707d: Loading layer [==================================================>]  45.18MB/45.18MB
    30339f20ced0: Loading layer [==================================================>]  126.6MB/126.6MB
    ce6c8756685b: Loading layer [==================================================>]  1.404MB/1.404MB
    a3483ce177ce: Loading layer [==================================================>]  3.584kB/3.584kB
    6ed1a81ba5b6: Loading layer [==================================================>]  3.584kB/3.584kB
    c3fe59dd9556: Loading layer [==================================================>]  356.7MB/356.7MB
    35c20f26d188: Loading layer [==================================================>]    426kB/426kB
    Loaded image: java:8
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    根据以上部署的应用,配置好jaf项目中的配置信息,然后打包成jar包,上传到服务器上

    上传部署的jar包

    在jar包所在目录下,创建Dockerfile文件

    创建Dockerfile

    并添加如下内容

    FROM java:8
    MAINTAINER jw_tech
    VOLUME /workspace
    ADD jaf-0.0.2-SNAPSHOT.jar /jaf.jar
    ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/jaf.jar"]
    
    • 1
    • 2
    • 3
    • 4
    • 5

    解释一下:

    • FROM 格式为FROM image或FROM image:tag,并且Dockerfile中第一条指令必须是FROM指令,且在同一个Dockerfile中创建多个镜像时,可以使用多个FROM指令。
    • java:8 是使用jdk版本
    • MAINTAINER 格式为MAINTAINER user_name user_email,指定维护者信息
    • VOLUME 格式为 VOLUME [“/data”] 作用是创建在本地主机或其他容器可以挂载的数据卷,用来存放数据。
    • ADD 格式:ADD src dest 该命令将复制指定本地目录中的文件到容器中的dest中,src可以是是一个绝对路径,也可以是一个URL或一个tar文件,tar文件会自动解压为目录,这里我们放的是跟Dockerfile同一目录的jar包
    • jaf-0.0.2-SNAPSHOT.jar是使用jar包名称
    • ADD jaf-0.0.2-SNAPSHOT.jar /jaf.jar 拷贝jar到容器
    • ENTRYPOINT 格式有两种:
      ENTRYPOINT [“executable”,“param1”,“param2”]
      ENTRYPOINT command param1,param2 会在shell中执行。
      用于配置容器启动后执行的命令,这些命令不能被docker run提供的参数覆盖。和CMD一样,每个Dockerfile中只能有一个ENTRYPOINT,当有多个时最后一个生效

    生成镜像:

    [root@localhost jack]# docker build -t jaf .
    Sending build context to Docker daemon  6.157GB
    Step 1/5 : FROM java:8
     ---> d23bdf5b1b1b
    Step 2/5 : MAINTAINER jw_tech
     ---> Running in fe477913f237
    Removing intermediate container fe477913f237
     ---> ef69b1581873
    Step 3/5 : VOLUME /workspace
     ---> Running in 15505ec1743b
    Removing intermediate container 15505ec1743b
     ---> 29786442c501
    Step 4/5 : ADD jaf-0.0.2-SNAPSHOT.jar /jaf.jar
     ---> d9fcee3efce7
    Step 5/5 : ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/jaf.jar"]
     ---> Running in 704cd2c1bab6
    Removing intermediate container 704cd2c1bab6
     ---> ea6b9b313dc1
    Successfully built ea6b9b313dc1
    Successfully tagged jaf:latest
    [root@localhost jack]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
    jaf                 latest              ea6b9b313dc1        About a minute ago   766MB
    jw-ftp              latest              de9910f5b16b        37 hours ago         750MB
    es-head             latest              550e9d955b41        37 hours ago         884MB
    es-ik               latest              ab547b99477e        38 hours ago         3.08GB
    jw-mysql            latest              05f525546ef7        38 hours ago         372MB
    java                8                   d23bdf5b1b1b        2 years ago          643MB
    [root@localhost jack]# 
    
    
    • 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

    注意:jaf是生成的镜像名称,最后面的“.”表示当前路径

    运行容器:

    [root@localhost jack]# docker run -d --restart=always -p 8080:8080 --name jaf -v /var/logs:/var/logs jaf
    94ef993f75539f33c622763f47c26e106d7a412b864c7a78cac9f5b18f19992d
    [root@localhost jack]# docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                                                    NAMES
    94ef993f7553        jaf                 "java -Djava.securit…"   6 seconds ago       Up 3 seconds        0.0.0.0:8080->8080/tcp                                                                                   jaf
    4ba8a0fc22df        es-head             "/bin/sh -c 'grunt s…"   15 hours ago        Up 15 hours         0.0.0.0:9100->9100/tcp                                                                                   es-head
    32cc99b397cb        es-ik               "/usr/local/bin/dock…"   15 hours ago        Up 15 hours         0.0.0.0:9200->9200/tcp, 0.0.0.0:9300->9300/tcp                                                           es-ik
    e961db12954e        jw-ftp              "/usr/sbin/run-vsftp…"   23 hours ago        Up 23 hours         0.0.0.0:80->80/tcp, 0.0.0.0:21100-21110->21100-21110/tcp, 0.0.0.0:20020->20/tcp, 0.0.0.0:20021->21/tcp   jw-ftp
    844bd13bc5c7        jw-mysql            "docker-entrypoint.s…"   24 hours ago        Up 24 hours         0.0.0.0:3306->3306/tcp, 33060/tcp                                                                        jw-mysql
    [root@localhost jack]# 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    解释一下:

    • –restart=always 总是启动,相当于开机自动重启
    • -p 8080:8080 代表端口映射,格式为 宿主机映射端口:容器运行端口
    • –name jaf 代表容器的名称,方便后续的操作
    • -v /var/logs:/var/logs 映射jaf项目的日志文件所在目录,方便在宿主机查看日志

    最后,验证一下:在浏览器输入你docker所在宿主机的IP:映射出来的端口号(我的是8080)访问出现如下图表示成功

    验证jaf项目部署成功

    至此,整个部署过程就完美结束了

  • 相关阅读:
    string(讲解)
    一次简单的 JVM 调优,拿去写到简历里
    设计模式学习笔记 - 开源实战四(中):剖析Spring框架中用来支持扩展的设计模式
    [Machine learning][Part3] numpy 矢量矩阵操作的基础知识
    纯CSS 毛玻璃效果
    数学建模学习(92):Jaya 算法对定位问题进行寻优
    VirtualBox配置共享文件夹,如果你一直安装增强功能失败,又没有尝试过改内核版本。。。
    逐鹿千亿市场:一碗中国面的魅力
    算法 括号生成-(递归回溯+同向双指针)
    div超出部分省略号显示
  • 原文地址:https://blog.csdn.net/cjiankai/article/details/98959406