Tomcat支持三种接收请求的处理方式:BIO、NIO、APR
软件版本: Tomcat9.0.85
操作系统: Rockylinux8.9
BIO由于每个请求都要创建一个线程来处理,线程开销比较大,不能再高并发的场景,性能也是最低的。
NIO是一个基于缓冲区、并能提供非阻塞I/O操作的Java API,比传统的bio更好的并发性能。
APR(Apache Portable Run-time libraries)简单理解,就是从操作系统级别解决异步IO问题,大幅度的提高服务器的处理和响应性能, 也是Tomcat运行高并发应用的首选模式。
所需软件的下载地址
https://mirrors.cloud.tencent.com/apache/apr/
tomcat-native在tomcat的bin下
* apr
* apr-iconv
* apr-util
* tomcat-native
安装依赖
yum install -y apr-devel openssl-devel gcc make expat-devel libtool
安装软件
cd /usr/local/src
wget https://mirrors.cloud.tencent.com/apache/apr/apr-1.6.5.tar.gz
tar xf apr-1.6.5.tar.gz
cd apr-1.6.5/
./configure --prefix=/usr/local/apr
make && make install
cd /usr/local/src
wget https://mirrors.cloud.tencent.com/apache/apr/apr-iconv-1.2.2.tar.gz
tar xf apr-iconv-1.2.2.tar.gz
cd apr-iconv-1.2.2/
./configure --with-apr=/usr/local/apr --prefix=/usr/local/apr-iconv
make && make install
cd /usr/local/src
wget https://mirrors.cloud.tencent.com/apache/apr/apr-util-1.6.3.tar.gz
tar xf apr-util-1.6.3.tar.gz
cd apr-util-1.6.3/
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr --with-apr-iconv=/usr/local/apr-iconv/bin/apriconv
make && make install
wget https://mirrors.cloud.tencent.com/apache/tomcat/tomcat-connectors/native/1.2.39/source/tomcat-native-1.2.39-src.tar.gz
tar xf tomcat-native-1.2.39-src.tar.gz
./configure --prefix=/usr/local/tomcat-native --with-apr=/usr/local/apr --with-ssl=yes
make && make install
echo -e 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib\nexport LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/tomcat-native/lib:$CATALINA_HOME/lib\nexport LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib' >> /etc/profile
source /etc/profile
启用 Tomcat Native Library(上面已配置,这一步可不做)
在 $CATALINA_HOME/bin 目录下新建 setenv.sh:
LD_LIBRARY_PATH=/home/mongo/soft/tomcat-native-1.2.35/lib:$CATALINA_HOME/lib
export LD_LIBRARY_PATH
/usr/local/tomcat/bin/startup.sh
查看端口情况
[root@slave bin]# netstat -tulnp | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 84309/java
标签:tomcat,tar,APR,模式,apr,usr,--,local,Tomcat9 From: https://www.cnblogs.com/lightsoft2021/p/18021392