利用APR提高Tomcat效能
最近新找到了一篇關於APR提高效能的安裝部署
http://mirror.bjtu.edu.cn/apache/apr/
http://archive.apache.org/dist/apr/
apr-1.5.2.tar.gz
tomcat-native.tar.gz 可以在tomcat/bin目錄下找到
安裝步驟如下:
安裝 apr
tar zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure
make
make install
完畢,預設安裝路徑在/usr/local/apr下
安裝apr-util
tar zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --with-apr=/usr/local/apr
make
make install
安裝tomcat-native
cd /usr/local/tomcat-6.0.18/bin
tar zxvf tomcat-native.tar.gz
cd tomcat-native-1.1.20-src/jni/native
./configure --with-apr=/usr/local/apr --with-java-home=/usr/local/jdk1.6.0_23
make
make install
設定 apr 的環境變數:
vi /etc/profile
// 後面新增以下內容
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/apr/lib
//退出vi,執行下面命令生效
source /etc/profile
重啟tomcat,檢視日誌裡有如下資訊:
資訊: Loaded APR based Apache Tomcat Native library 1.1.20
就表示成功了!
備註:
bio 資訊: Starting ProtocolHandler ["http-bio-8080"] 2013-8-6 16:17:50 org.apache.coyote.AbstractProtocol start nio 資訊: Starting ProtocolHandler ["http-nio-8080"] 2013-8-6 16:59:53 org.apache.coyote.AbstractProtocol start apr資訊: Starting ProtocolHandler ["http-apr-8080"] 2013-8-6 17:03:07 org.apache.coyote.AbstractProtocol start
centos 7
安裝OpenSSL 1.0.2
由於centos 7 當前的yum 庫只有1.0.1 的OpenSSL,所以我們需要手工安裝1.0.2
# cd /usr/local/src
# wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz
# tar -xzxf openssl-1.0.2-latest.tar.gz
# cd openssl-1.0.2g
# ./config --prefix=/usr/local/openssl -fPIC
// 注意這裡需要加入 -fPIC引數,否則後面在安裝tomcat native 元件會出錯
// 注意:不要按照提示去執行 make depend
# make
# make install
# mv /usr/bin/openssl ~
# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# openssl version
// 確認版本資訊是1.0.2
重新安裝 tomcat-native元件
# cd $CATALINA_HOME/bin
# tar -xzvf tomcat-native.tar.gz
# cd tomcat-native-1.2.7-src/native
# ./configure --with-apr=/usr/local/apr --with-ssl=/usr/local/openssl
# make
# make install