tomcat性能优化之如何搭建Apr模块
åè¨
tomcatæ¯ä¸ä¸ªè¢«å¹¿æ³ä½¿ç¨çjava web容å¨ï¼åç§è°ä¼æ°ä¸èæ°ï¼ç±äºtomcat主è¦è¿è¡jspçå¨æ页é¢ï¼æ以å¶è®¾è®¡ä¸»è¦æ¯é对å¨æ页é¢è¿è¡ä¼åï¼è对éææ件çå¤çæç并ä¸é«ã
å¾å¤æ¶åå·¥ç¨å¸æ´æ¿æ使ç¨nginxæèapacheæå¡å¨æ¥è¾å©tomcatå¤çéææ件æ¥æé«æå¡å¨è¿è¡æçï¼ä½å¶å®tomcatæ¬èº«å¯ä»¥è°ç¨apacheçæ¹æ³æ¥å¤çéææ件ï¼æ大çæé«å¤çæçã
tomcatæå¡å¨çä¸ç§æ¨¡å¼bio ï¼æ¶æ¯é»å¡æ¨¡å¼ï¼ï¼nioï¼éé»å¡æ¨¡å¼ï¼ ï¼aprï¼ä½¿ç¨apacheéææ件å¤çåºå¤çéææ件ï¼
å¦ä½å¨ä¸å°å¨æ°çlinuxä¸é¨ç½²tomcatçapr模åï¼
对äºå·²ç¨³å®ä½¿ç¨çæºå¨å¯ä»¥ç´æ¥ç第ä¸æ¥
1.å®è£åå¦æåç°yumæºä¸åé
CentOS 5 ä¿®æ¹yumæºæ¹å¼
wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-5.repo
æè
curl -o /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6 ä¿®æ¹yumæºæ¹å¼
wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-6.repo
æè
curl -o /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7 ä¿®æ¹yumæºæ¹å¼
wget -O /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-7.repo
æè
curl -o /etc/yum.repos.d/CentOS-Base.repo
http://mirrors.aliyun.com/repo/Centos-7.repo
2.å¦æ解æç½åé误 curl: (6) Could not resolve host
éç½®dnsæ¥éª¤å¦ä¸
vim /etc/resolv.conf
#ä¸è¬æ¯ä¸ªç©ºæ件ï¼å¨æ件éå è¿ä¹ä¸¤ä¸ªdnséç½®
nameserver 114.114.114.114 nameserver 8.8.8.8
3.å®è£tomcat opensslåaprç»ä»¶
ç®åTomcat 8.xé»è®¤æåµä¸å¨é¨æ¯è¿è¡å¨nio模å¼ä¸ï¼èaprçæ¬è´¨å°±æ¯ä½¿ç¨jniææ¯è°ç¨æä½ç³»ç»åºå±çIOæ¥å£ï¼æ以éè¦æåå®è£æéè¦çä¾èµï¼é¦åæ¯éè¦å®è£opensslåapr
yum -y install openssl-devel yum -y install apr-devel
4.å®è£native,apr,apr-utilç»ä»¶
åå»tomcatå®ç½ä¸è½½native,apr,apr-utilç»ä»¶ï¼nativeå¯ä»¥çææ¯tomcatåapr交äºçä¸é´ç¯èï¼ä¸è½½å°åæ¯ï¼
http://tomcat.apache.org/download-native.cgi ,
apr å°åæ¯ http://apache.fayea.com//apr æµè§å¨ä¸å»çä¸ä¸ï¼å 为apacheä¸å®æ¶æ´æ°ãè¿éåºå®å以åå¯è½wget æä¸ä¸æ¥ï¼æ以ä¸åºå®åï¼å¤§å®¶èªè¡ä¸è½½
å解åå®è£
tar -xvzf apr-1.6.5.tar.gz cd apr-1.6.5 ./configure --prefix=/usr/local/apr make && make install tar -zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
#ç¶åè¿émakeå¯è½åºé®é¢ åå æ¯å°ä¸ä¸ªç¼è¯åº expat-devel
å¯ä»¥ä½¿ç¨ yum install expat-devel -y æ¥è¿è¡å®è£
ï¼å¦æè¿ä¹æ¥ä¸è¡çè¯ï¼åªè½ä»ç³»ç»å®è£åçéæ¾äºï¼ï¼ç¶å
make && make install
åå®è£native模å
tar -xvzf tomcat-native-1.2.10-src.tar.gz cd tomcat-native-1.2.10-src/native/ ./configure
è¿æ¶å¯è½ä¼å®è£å¤±è´¥ï¼å 为opensslçæ¬è¾ä½ å»å®ç½çä¸ä¸ææ°çå°åï¼https://www.openssl.org/source/ ç¶åwget ä¸æ¥
tar -xvzf openssl-1.1.0e.tar.gz cd openssl-1.1.0e/ ./config --prefix=/usr/local/openssl --openssldir=/usr/local/openssl make && make install
ç¨çä¸ä¼å°±å®è£æåäºï¼ç°å¨å次è¿å¥nativeåæç¼è¯çç®å½ä¸ï¼éæ°æ§è¡å¦ä¸å½ä»¤å®è£ï¼
./configure --with-ssl=/usr/local/openssl make && make installefix=/usr/local/openssl --openssldir=/usr/local/openssl make && make install
5.ä¿®æ¹tomcatéç½®æ件
è¿å¥ä½ çtomcatç®æå¡å¨ç®å½ï¼ç¼è¾éç½®æ件ï¼conf/server.xml
å°é»è®¤çprotocol="HTTP/1.1"ä¿®æ¹ä¸º
protocol="org.apache.coyote.http11.Http11AprProtocol"
ä¿®æ¹å®æä¿å并éåº
6.éç½®ç¯å¢åéï¼ä¸¤ç§æ¹å¼ï¼
è¿å¥tomcatå®è£ç®å½ä¸
æå¼ bin/catalina.shæ件
å¨åæåéJAVA_OPTSåé¢è¿½å 对åºçéç½®å³å¯ï¼æ·»å ä¸è¡æ°çå°±å¯ä»¥ï¼
JAVA_OPTS="$JAVA_OPTS -Djava.library.path=/usr/local/apr/lib"
ç¶åä¿å并éåºå å°±å¯ä»¥ç»æå®è£
éæ°å¯å¨ä½ çtomcatæå¡å¨ï¼ çå° catalina.out æåè¾¹çæ¥å¿
tomcatå¯å¨æ¥å¿
说ætomcat Apr å·²ç»éç½®æåäº
æè
å¨ç¯å¢åéä¸å å¥aprçç®å½ï¼è®©tomcatå¯ä»¥ä½¿ç¨ç³»ç»åéæç´¢å°
ç¼è¾/etc/profileå¨æåæ·»å å¦ä¸ä¸¤è¡å容ï¼
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib export LD_RUN_PATH=$LD_RUN_PATH:/usr/local/apr/lib
ä¿åä¹åï¼æ§è¡ source /etc/profile 使éç½®çæ
ç¶åéæ°å¯å¨ä½ çtomcatæå¡å¨ï¼ çå° catalina.out æåè¾¹çæ¥å¿
说ætomcat Apr å·²ç»éç½®æåäº
以ä¸å°±æ¯æ¬æçå¨é¨å容ï¼å¸æ对大家çå¦ä¹ ææ帮å©ï¼ä¹å¸æ大家å¤å¤æ¯æèæ¬ä¹å®¶ã