当前位置:8090st.com >环境搭建 > 查看文章
阿里云优惠码

Tomcat7+jdk1.6.0_32环境配置说明

需要的软件包(10.86.87.150):
– jdk1.6.0_32.tar.gz #jdk安装包
– tomcat-7.0.57.tar.gz #tomcat安装包
– readme.txt #软件及环境变量配置说明

下载地址:
http://soft.8090st.com/jdk/jdk1.6.0_32.tar.gz
http://soft.8090st.com/tomcat/tomcat-7.0.57.tar.gz

修改说明:
jdk;
– 增加连接sap的包:
/usr/local/jdk1.6.0_32/lib/sapjco3.jar
/usr/local/jdk1.6.0_32/jre/lib/amd64/server/libsapjco3.so
/usr/local/jdk1.6.0_32/jre/lib/amd64/libsaproc.so

tomcat:
– 增加setenv.sh环境变量设置文件
– 增加日志切割配置,每天生成一个catalina.out,格式:catalina-2016-07-15.out
– 增加维护脚本
– 增加默认测试页面
– 删除webapps下面的所有文件
– server.xml优化(关闭自动部署、线程优化等)

1、获取软件包;
wget http://soft.8090st/jdk/jdk1.6.0_32.tar.gz
wget http://soft.8090st.com/tomcat/tomcat-7.0.57.tar.gz

2、JDK安装配置

2.1 解压jdk
解压:tar xzf jdk1.6.0_32.tar.gz
得到:jdk1.6.0_32
将软件包移动到/usr/local/
mv jdk1.6.0_32 /usr/local/jdk1.6.0_32
ln -s /usr/local/jdk1.6.0_32 /usr/local/java

2.2 配置环境变量
vim /etc/profile
#将如下配置加入到此文件末尾

export JAVA_HOME=/usr/local/java
export PATH=$PATH:$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib.dt.jar:$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/sapjco3.jar
export JRE_HOME=$JAVA_HOME/jre
LD_LIBRARY_PATH=dir:$LD_LIBRARY_PATH:$JAVA_HOME/jre/lib/amd64/server
export LD_LIBRARY_PATH

2.3 测试
输入命令:java -version 看到如下输出,说明jdk配置成功。
java version “1.6.0_32″
Java(TM) SE Runtime Environment (build 1.6.0_32-b05)
Java HotSpot(TM) 64-Bit Server VM (build 20.7-b02, mixed mode)

3、tomcat安装配置
解压tomcat-7.0.57.tar.gz
tar xzf tomcat-7.0.57.tar.gz
得到:tomcat-7.0.57
移动到mv apache-tomcat-7.0.57 /geelyapp/tomcat-mes

说明:
tomcat-mes为项目名称,命名规范:tomcat-项目名,确保命名唯一性。

3.1 配置tomcat
1)修改server.xml
修改默认端口(一台服务器跑多个tomcat实例时,需要修改如下端口,以免出现端口冲突,导致服务无法启动)
shutdown端口:8005 —>>>
http端口:8080 —>>>

2)tomcat的JVM启动参数已做优化,相关内存配置可根据实际情况进行调整

4、应用发布
4.1 编辑service配置:
vim /etc/services
将如下配置加入到此文件末尾(tcp端口根据实际连接的sap端口来配置)
sapgw00 3300/tcp #SAP Gateway
sapgw10 3310/tcp #SAP Gateway

说明:
1)sapgw00和sapgw10的tcp端口需根据应用连接的sap端口来确定,实际配置过程中需要根据实际情况修改。

4.2 应用发布
将打包好的程序war包放到tomcat的webapps下面,启动tomcat即可。

5、维护脚本:
实际应用中,需根据实际部署情况,修改脚本中的初始变量值。如CATALINA_HOME、CATALINA_BASE
使用方法:将如下代码保存到 /etc/init.d 目录下,命名为tomcat 。
加入到系统服务:
chkconfig –add tomcat

启动tomcat:
service tomcat start

停止tomcat:
service tomcat stop

重启tomcat:
service tomcat restart

#!/bin/bash
#
# chkconfig: – 99 28
# description: Starts/Stops Apache Tomcat
#
# Release updates:
# Updated method for gathering pid of the current proccess
# Added usage of CATALINA_BASE
# Added coloring and additional status
# Added check for existence of the tomcat user
#

#Location of JAVA_HOME (bin files)
export JAVA_HOME=/usr/local/java

#Add Java binary files to PATH
export PATH=$JAVA_HOME/bin:$PATH

#CATALINA_HOME is the location of the bin files of Tomcat
export CATALINA_HOME=/geelyapp/tomcat-mes

#CATALINA_BASE is the location of the configuration files of this instance of Tomcat
export CATALINA_BASE=/root/tomcat-mes

#TOMCAT_USER is the default user of tomcat
export TOMCAT_USER=root

#TOMCAT_USAGE is the message if this script is called without any options
TOMCAT_USAGE=”Usage: $0 {\e[00;32mstart\e[00m|\e[00;31mstop\e[00m|\e[00;32mstatus\e[00m|\e[00;31mrestart\e[00m}”

#SHUTDOWN_WAIT is wait time in seconds for java proccess to stop
SHUTDOWN_WAIT=20

tomcat_pid() {
echo `ps -fe | grep $CATALINA_BASE | grep -v grep | tr -s ” “|cut -d” ” -f2`
}

start() {
pid=$(tomcat_pid)
if [ -n “$pid” ]
then
echo -e “\e[00;31mTomcat is already running (pid: $pid)\e[00m”
else
# Start tomcat
echo -e “\e[00;32mStarting tomcat\e[00m”
#ulimit -n 100000
#umask 007
#/bin/su -p -s /bin/sh tomcat
if [ `user_exists $TOMCAT_USER` = “1” ]
then
su $TOMCAT_USER -c $CATALINA_HOME/bin/startup.sh
else
sh $CATALINA_HOME/bin/startup.sh
fi
status
fi
return 0
}

status(){
pid=$(tomcat_pid)
if [ -n “$pid” ]; then echo -e “\e[00;32mTomcat is running with pid: $pid\e[00m”
else echo -e “\e[00;31mTomcat is not running\e[00m”
fi
}

stop() {
pid=$(tomcat_pid)
if [ -n “$pid” ]
then
echo -e “\e[00;31mStoping Tomcat\e[00m”
#/bin/su -p -s /bin/sh tomcat
sh $CATALINA_HOME/bin/shutdown.sh

let kwait=$SHUTDOWN_WAIT
count=0;
until [ `ps -p $pid | grep -c $pid` = ‘0’ ] || [ $count -gt $kwait ]
do
echo -n -e “\n\e[00;31mwaiting for processes to exit\e[00m”;
sleep 1
let count=$count+1;
done

if [ $count -gt $kwait ]; then
echo -n -e “\n\e[00;31mkilling processes which didn’t stop after $SHUTDOWN_WAIT seconds\e[00m”
kill -9 $pid
fi
else
echo -e “\e[00;31mTomcat is not running\e[00m”
fi

return 0
}

user_exists(){
if id -u $1 >/dev/null 2>&1; then
echo “1”
else
echo “0”
fi
}

case $1 in

start)
start
;;

stop)
stop
;;

restart)
stop
start
;;

status)
status

;;

*)
echo -e $TOMCAT_USAGE
;;
esac
exit 0

相关文章
为您推荐
各种观点
暂时还木有人评论,坐等沙发!
发表评论

您必须 [ 登录 ] 才能发表留言!