澳门皇冠金沙网站-澳门皇冠844网站

热门关键词: 澳门皇冠金沙网站,澳门皇冠844网站

库性能优化,安全配置与高并发优化

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-12/149295.htm

CentOS 6.6下安装配置Tomcat环境  http://www.linuxidc.com/Linux/2015-08/122234.htm

 # rm -rf /usr/local/apache-tomcat-8.5.16/webapps/*
 # rm -rf /usr/local/apache-tomcat-8.5.16/conf/tomcat-users.xml

7.安装tomcat-native

//配置gcc依赖
yum install gcc

Tomcat权威指南(第二版)(中英高清PDF版 带书签)  http://www.linuxidc.com/Linux/2015-02/113062.htm 

Tomcat可以使用Apache Portable Runtime来提供卓越的性能及可扩展性,更好地与本地服务器技术的集成。Apache Portable Runtime是一个高度可移植的库,位于Apache HTTP Server 2.x的核心。APR有许多用途,包括访问高级IO功能(如sendfile,epoll和OpenSSL),操作系统级功能(随机数生成,系统状态等)以及本地进程处理(共享内存,NT管道和Unix套接字)。

具体参考:

4.maxThreads 连接数限制修改配置

CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm 

APR连接器的特点:

Ubuntu 16.04安装Tomcat 8 图解  http://www.linuxidc.com/Linux/2017-10/147773.htm

Ubuntu 16.04安装Tomcat 8 图解  http://www.linuxidc.com/Linux/2017-10/147773.htm

RedHat Linux 5.5安装JDK Tomcat并部署Java项目  http://www.linuxidc.com/Linux/2015-02/113528.htm 

更多Tomcat相关教程见以下内容

APR 1.2 development headers (libapr1-dev package)
OpenSSL 1.0.2 development headers (libssl-dev package)
JNI headers from Java compatible JDK 1.4
GNU development environment (gcc, make)

//配置环境变量
vi /etc/profile
//在末尾添加
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
source /etc/profile

Ubuntu 16.04下安装Tomcat 8.5.9  http://www.linuxidc.com/Linux/2017-06/144809.htm

# systemctl restart tomcat
# cat /usr/local/tomcat/logs/catalina.out

...
INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib]
INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
...

注意: style="color: #000000;">可以看到红色部分,提示找不到基于APR的Apache Tomcat Native库,因此无法使用APR模式启动。

解决方案:

# cp -R /usr/local/apr/lib/* /usr/lib64
# cp -R /usr/local/apr/lib/* /usr/lib

再次重启tomcat,并查看启动日志

# cat /usr/local/tomcat/logs/catalina.out

...
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8080"]
INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-8009"]
...

本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-05/143305.htm

CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm 

# yum -y install gcc gcc-c   libtool* autoconf automake expat-devel perl perl-devel

//安装tomcat-native
cd
wget
tar -zxvf tomcat-native-1.2.12-src.tar.gz
cd tomcat-native-1.2.12-src/native
./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
make && make install

3.应用程序安全&关闭自动部署

Tomcat 的详细介绍:请点这里
Tomcat 的下载地址:请点这里

Linux下使用Xshell查看Tomcat实时日志中文乱码解决方案 http://www.linuxidc.com/Linux/2015-01/112395.htm 

CentOS 6.6下安装配置Tomcat环境  http://www.linuxidc.com/Linux/2015-08/122234.htm

Tomcat配置文件server.xml详解  http://www.linuxidc.com/Linux/2017-10/148003.htm

CentOS 64-bit下安装JDK和Tomcat并设置Tomcat开机启动操作步骤 http://www.linuxidc.com/Linux/2015-01/111485.htm 

7.删除禁用默认管理页面以及相关配置文件

Tomcat 安全配置与性能优化 http://www.linuxidc.com/Linux/2015-02/113060.htm 

//测试
cat /usr/local/tomcat/logs/catalina.out
//可以看到类似下面的消息即可
[main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-apr-18080"]
INFO: Loaded APR based Apache Tomcat Native library 1.1.33 using APR version 1.5.2.
org.apache.catalina.core.AprLifecycleListener.init Loaded APR based Apache Tomcat Native library 1.1.29 using APR version 1.5.0.

Tomcat单机多实例部署-多项目部署  http://www.linuxidc.com/Linux/2017-10/147259.htm

# vim /etc/profile.d/jdk.sh
export LD_LIBRARY_PATH=/usr/local/apr/lib:$LD_LIBRARY_PATH
# source /etc/profile.d/jdk.sh

CentOS 6.5下安装Tomcat  http://www.linuxidc.com/Linux/2015-01/111415.htm 

Tomcat配置文件server.xml详解  http://www.linuxidc.com/Linux/2017-10/148003.htm

至此APR安装成功。

图片 1

默认值:

<!--
 <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"
 maxThreads="150" minSpareThreads="4"/>
 -->

修改为:

<Executor
 name="tomcatThreadPool"
 namePrefix="catalina-exec-"
 maxThreads="500"
 minSpareThreads="30"
 maxIdleTime="60000"
 prestartminSpareThreads = "true"
 maxQueueSize = "100"
/>

参数解释:

maxThreads:最大并发数,默认设置 200,一般建议在 500 ~ 800,根据硬件设施和业务来判断
minSpareThreads:Tomcat 初始化时创建的线程数,默认设置 25
maxIdleTime:如果当前线程大于初始化线程,那空闲线程存活的时间,单位毫秒,默认60000=60秒=1分钟。
prestartminSpareThreads:在 Tomcat 初始化的时候就初始化 minSpareThreads 的参数值,如果不等于 true,minSpareThreads 的值就没啥效果了
maxQueueSize:最大的等待队列数,超过则拒绝请求

4.安装apr-iconv

Tomcat Native是用于Tomcat的一个可选组件,能够允许Tomcat使用一定的本地资源、性能、兼容性。

6.隐藏或修改 Tomcat 版本号

官方要求:

//安装openssl
wget
tar -zxvf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e
./config --prefix=/usr/local/openssl
make && make install

图片 2

本文由澳门皇冠金沙网站发布于网络操作,转载请注明出处:库性能优化,安全配置与高并发优化