解决Linux下ArcGIS Server的Tomcat不稳定问题,nginx配置反向代理时的一个小问题
背景:Linux上的ArcGIS Server的Tomcat进程基本上一天崩溃一次,全天在处理rest请求,压力较大。而SOM与SOC压力较小
解决方案:使用多个Web Service,加入另一台nginx反向代理服务器的upstream。
遇到问题:使用了反向代理的缘故,web service handler必须要用arcgis/rest方式暴露服务。所以如何配置tomcat,便成了一个比较重要的问题。
问题处理:在tomcat配置文件server.xml的host标签中加入Context,指明应用根目录。
<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="/arcgis/rest" docBase="./arcgis/rest" reloadable="true"/> <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>
这样,就可以像访问arcgis server一样,访问localhost:8080/arcgis/rest了(注意修改每个REST Service Handler的SOM地址)。
在nginx中,配置为:
worker_processes auto; events { worker_connections 1024; use epoll; } http { include mime.types; default_type application/octet-stream; access_log off; sendfile on; keepalive_timeout 65; upstream gpsarcgis{ server SERVER1:6080 max_fails=3; server SERVER2:6080 max_fails=3; server Server3:6080 max_fails=3; server Server4:8081 max_fails=3 weight=3; server Server5:8081 max_fails=3 weight=3; server Server6 :8081 max_fails=3 weight=3; } server { listen 6080; server_name IP1 IP2; charset utf-8; location / { proxy_pass http://gpsarcgis; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_504 http_404; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
前三个为ArcGIS Server原始地址和端口,后面为tomcat。打上双保险,舒服多了!