部署步骤,注意黄色部分即可。
由于tomcat每次重启会重新写gc.log文件,所以在里面增加了日期属性,保留以往的日志做性能分析使用。
10.10.160.10和11上的catalina.sh我已经更新,以后拷贝即可。
<!--[if !supportLists]-->1. <!--[endif]-->建立目录
mkdir -p /application/search/vertical-search/vertical-search
将apache-tomcat-7.0.52解压缩到/application/search/vertical-search/vertical-search目录下
将JDK7解压到/application/search/vertical-search/java目录下
并增加软链接
ln -s /application/search/vertical-search/java/jdk1.7.0_51 /application/search/vertical-search/java/latest
<!--[if !supportLists]-->2. <!--[endif]-->修改/application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/bin/catalina.sh
首行增加
JAVA_HOME=/application/search/vertical-search/java/latest
CURRENT_TIME=`date +%Y-%m-%d_%H:%M:%S`
VERTICAL_SEARCH_LOG="/data0/search/vertical-search"
#如果自定义配置文件,需要增加VERTICAL_SEARCH_CONF变量,并且在JAVA_OPTS添加该变量,-DVERTICAL_SEARCH_CONF=${VERTICAL_SEARCH_CONF}
#VERTICAL_SEARCH_CONF="/application/search/vertical-search/conf"
JAVA_OPTS='-server -verbose:gc -Xms4000m -Xmx4000m -Xmn2000m -XX:PermSize=128m -XX:MaxPermSize=128m -Xss256k -XX:NewSize=500m -XX:MaxNewSize=500m -XX:+UseConcMarkSweepGC -XX:ParallelGCThreads=16 -XX:+UseCMSCompactAtFullCollection -XX:CMSMaxAbortablePrecleanTime=5000 -XX:+UseParNewGC -XX:+DisableExplicitGC -Xloggc:${VERTICAL_SEARCH_LOG}/logs/ gc.${CURRENT_TIME}.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${VERTICAL_SEARCH_LOG}/logs/HeapDumpOnOutOfMemoryError.log -XX:+DisableExplicitGC -XX:+PrintGC -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -DVERTICAL_SEARCH_LOG=${VERTICAL_SEARCH_LOG}'
<!--[if !supportLists]-->3. <!--[endif]-->修改/application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/conf/server.xml
修改http连接点
<Connector port="8199"
protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
URIEncoding="UTF-8"
useBodyEncodingForURI="true"
maxThreads="1024"
minSpareThreads="256"
enableLookups="false" />
删除AJP协议,减少端口占用
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!--[if !supportLists]-->4. <!--[endif]-->修改/application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/tomcat-users.xml,方便跟踪调试,观察线上性能情况
在</tomcat-users>节点增加以下行
<user name="root" password="vertical" roles="admin,manager,manager-gui" />
注意:请不要删除/application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/webapps目录下的文件,管理页面和后期性能监控要靠看这个页面
<!--[if !supportLists]-->5. <!--[endif]-->日志设置,请注意不要删除logs下面的已有日志,切记!
创建logs输出目录
mkdir -p /data0/search/vertical-search
将tomcat的服务器日志修改到/data0磁盘下
mv /application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/logs /data0/search/vertical-search
建立软连接
ln -s /data0/search/vertical-search/logs /application/search/vertical-search/vertical-search/apache-tomcat-7.0.52/logs
<!--[if !supportLists]-->6. <!--[endif]-->maven打包命令
mvn clean package -U -Dmaven.test.skip=true -Ponline -T 1C
<!--[if !supportLists]-->7. <!--[endif]-->操作系统内核优化(需要ROOT权限,并且需要注意CENTOS6.4和5.5的版本区别),修改/etc/sysctl.conf ,并追加以下内容
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 5
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.ip_local_port_range = 2000 65535
net.ipv4.tcp_max_tw_buckets = 5000
net.ipv4.netfilter.ip_conntrack_max = 1000000