在cloudfoundry中运行GeoServer

许多组织和应用程序都在向云计算提供商转移工作负载。应用程序的一个目标平台是 Cloud Foundry . 虽然它不是GeoServer密集使用的最佳环境,但对于简单使用来说,它已经足够了。本教程是关于基本部署的简单指南。

有关更高级的部署,请参阅部分 Advanced Topics

Java环境

CloudFoundry使用语言构建包的抽象概念来运行用多种语言编写的微服务。这个 java buildpack 从版本支持OpenJDK和专有的JREs和tomcat 6.0.0 to 9.x.y

云铸造客户端

要与CloudFoundry交互,请安装 command line tool 为了你的平台。

使用云计算服务(试用版)

注册免费试用帐户 SAP 或者IBM。

警告 在这个时候, IBM 不允许在空闲实例中有更多64MB内存,这会阻止启动geoserver。本教程将更新,如果这一变化,然而,云铸造命令和清单文件是相同的,因为云铸造真正是多云!

SAP云平台上的Cloud Foundry

Logon to your cockpit 然后选择你的审判机构

../../_images/sap_cp_trial1.png

注意这个区域 组织名称 还有云计算公司 API终结点 .

../../_images/sap_cp_trial2.png

使用这两个值使用命令行登录:

$ cf login -a https://api.cf.eu10.hana.ondemand.com -o your_org_name_trial
API endpoint: https://api.cf.eu10.hana.ondemand.com

Email: your.email@here.com

Password:
Authenticating...
OK

Targeted org your_org_name_trial

Targeted space dev



API endpoint:   https://api.cf.eu10.hana.ondemand.com (API version: 3.88.0)
User:           your.email@here.com
Org:            your_org_name_trial
Space:          dev

现在您已经登录,可以列出应用程序:

cf apps
Getting apps in org your_org_name_trial / space dev as your.email@here.com...
OK

No apps found

发布GeoServer

现在您已经登录到cloudfoundry空间,可以将GeoServer发布为servlet。下载GeoServer作为war文件。创建名为的部署配置文件 manifest.yml

---
applications:
- name: geoserver
path: ./geoserver.war
health-check-type: process
random-route: true
buildpacks:
    - java_buildpack

默认行为是使用最新的OpenJRE和tomcat版本。以及 你好 ,您可以发布GeoServer了!:

$ cf push -f manifest.yml
Pushing from manifest to org your.email@here.com / space dev as your.email@here.com...
Using manifest file manifest.yml
Getting app info...
[...]
Packaging files to upload...
Uploading files...
    45.38 MiB / 45.38 MiB [=================================================================] 100.00% 3m59s
[...]
Waiting for app to start...
[...]

第一次执行此操作需要两分钟,然后您可以运行以下命令来检查应用程序状态:

$ cf apps
Getting apps in org 2d2950f1trial / space dev as your.email@here.com...
OK

name        requested state   instances   memory   disk   urls
geoserver   started           1/1         1G       1G     geoserver-humble-puku-pi.cfapps.eu10.hana.ondemand.com

您可以在浏览器中打开该url。HTTP被自动重定向到HTTPS,流量使用云铸造平台证书进行加密,大多数浏览器都信任这些证书。

高级主题

更改内存限制

使用命令 cf比例尺 ,例如,要将限制设置为2Gigabytes,请执行:

$cf scale geoserver -m 2G -f
Scaling app geoserver in org 2d2950f1trial / space dev as your.email@here.com...

重新启动应用程序:,然后显示新的限制:

     state     since                    cpu    memory         disk           details
#0   running   2020-11-13 01:54:56 PM   0.4%   470.8M of 2G   250.2M of 1G

对于大多数参数,也可以在清单文件中设置资源限制

更改清单文件

清单文件允许您配置:
  • 资源限制(内存和cpu)

  • 配置路由URL

  • 设置环境变量,例如设置特定的tomcat版本

---
applications:
- name: geoserver
path: ./geoserver.war
health-check-type: process
random-route: true
buildpacks:
    - https://github.com/cloudfoundry/java-buildpack.git
env:
    JBP_CONFIG_TOMCAT: '{ tomcat: { version: 8.0.+ } }'

扩展挑战

总内存限制为8 GB。CloudFoundry作为一个微服务平台的目标是将一个单一的应用程序分成更小的块。在IBM和SAP平台中,容器的容量限制为8GB。