注:geoserver 版本 Linux geoserver2.15.0 安装 :bin方式安装(内嵌jetty,非war安装)
一。geoserver调优之Java图像处理优化
1.原生JAI和ImageIO
GeoServer的图像处理功能使用了Java的JAI和JAI ImageIO功能,但由于Java的JAI和JAI ImageIO库默认是Java实现,若将其换为原生库可显著提高图像处理速度。注意,在windows下只有32位Java环境才可用,64位Java环境不可用原生库。下载和拷贝原生库文件的操作参考以下代码:
cd /tmp
#解压
gunzip -c jai-1_1_3-lib-linux-amd64.tar.gz | tar xf -
gunzip -c jai_imageio-1_1-lib-linux-amd64.tar.gz | tar xf -
#把解压之后的相关文件拷贝到jre目录下(jdk安装目录)
#/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64 指jdk安装目录,查看jdk安装目录,参考:
https://www.cnblogs.com/luminccs-5308/p/10043338.html
cp /tmp/jai-1_1_3/lib/*.jar /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/
cp /tmp/jai-1_1_3/lib/*.so /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/amd64/
cp /tmp/jai_imageio-1_1/lib/*.jar /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/
cp /tmp/jai_imageio-1_1/lib/*.so /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/amd64/
2.重启geoserver报错 geoserver启动 Could not initialize class javax.media.jai.JAI
3.解决:删除$CATALINA_BASE/webapps/geoserver/WEB-INF/lib目录下的 jai_codec-1.1.3.jar; jai_core-1.1.3.jar; jai_imageio-1.1.jar 三个文件
注:先备份后删除
mkdir -p /tmp/geoserver/
cp /usr/local/geoserver-2.15.0/webapps/geoserver/WEB-INF/lib/jai*.jar /tmp/geoserver/
cd /usr/local/geoserver-2.15.0/webapps/geoserver/WEB-INF/lib
ls
ls jai*
rm -f -r jai_codec-1.1.3.jar
ls jai*
rm -f -r jai_core-1.1.3.jar
ls
ls jai*
rm -f -r jai_imageio-1.1.jar
ls jai*
4.重启geoserver
二。原生库变回java库
1.删除jre下的原生jar包(核对是否是自己之前复制过去的那些jar包)
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/jai_codec.jar
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/jai_core.jar
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/jai_imageio.jar
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/mlibwrapper_jai.jar
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/ext/clibwrapper_jiio.jar
2.删除jre下的原生so文件(核对是否是自己之前复制过去的那些文件)
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/amd64/libmlib_jai.so
rm -f -r /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.171-8.b10.el7_5.x86_64/jre/lib/amd64/libclib_jiio.so
3.把之前删除的/webapps/geoserver/WEB-INF/lib目录下的 jai_codec-1.1.3.jar; jai_core-1.1.3.jar; jai_imageio-1.1.jar 三个文件还原
cp -r /tmp/geoserver/*.jar /usr/local/geoserver-2.15.0/webapps/geoserver/WEB-INF/lib/