mkdir /etc/skel/www
mkdir /etc/skel/logs
echo "Under construction" > /etc/skel/www/index.html
<Host name="yourdomain" appBase=""
unpackWARs="true" autoDeploy="true">
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="/home/username/logs" prefix="yourdomain_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"/>
<Context path="" docBase="webapps/yourdomain" reloadable="false" />
</Host>
# VH begin: yourdomain
log4j.appender.username=org.apache.log4j.RollingFileAppender
log4j.appender.username.File=/home/username/logs/tomcat.log
log4j.appender.username.MaxFileSize=10MB
log4j.appender.username.MaxBackupIndex=10
log4j.appender.username.layout=org.apache.log4j.PatternLayout
log4j.appender.username.layout.ConversionPattern=%d - %5p (%C:%L) - %m%n
log4j.logger.org.apache.catalina.core.ContainerBase.[Catalina].[yourdomain]=INFO, username
log4j.additivity.org.apache.catalina.core.ContainerBase.[Catalina].[yourdomain]=false
# VH end: yourdomain
#!/bin/bash
# Name: Tomcat newsite.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.5
# Last Modified: 2009-03-29
CATALINA_HOME=/var/tomcat6
WORKER_ROOT="/var/robust"
WORKER_LIST=( worker1 worker2 )
username=$1
password=$2
yourdomain=$3
useradd -s /sbin/nologin -g tomcat ${username}
echo "${username}:${password}" | chpasswd
ln -s /home/${username}/www /var/webapps/${yourdomain}
chmod 755 /home/${username}
mkdir /home/${username}/logs
chmod 775 /home/${username}/logs
# for Tomcat5
#sed -e "s/yourdomain/${yourdomain}/g" -e "s/username/${username}/g" /root/newsite/log4j.newhost >> ${CATALINA_HOME}/common/classes/log4j.properties
# for Tomcat6
sed -e "s/yourdomain/${yourdomain}/g" -e "s/username/${username}/g" /root/newsite/log4j.newhost >> ${CATALINA_HOME}/lib/log4j.properties
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
mkdir -p ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/Catalina/${yourdomain}
# for Tomcat5
#cp -rf ${CATALINA_HOME}/server/webapps/manager/manager.xml ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/Catalina/${yourdomain}/.
# for Tomcat6
cp -rf ${CATALINA_HOME}/webapps/host-manager/manager.xml ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/Catalina/${yourdomain}/.
sed -e "s/yourdomain/${yourdomain}/g" -e "s/username/${username}/g" /root/newsite/server.newhost >> ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/server.host
cd ${WORKER_ROOT}/${WORKER_LIST[i]}/conf
cat server.header server.host server.footer > server.xml
done
sed -e "s/yourdomain/${yourdomain}/g" /root/newsite/awstats.newhost > /etc/awstats/awstats.${yourdomain}.conf
#!/bin/bash
# Name: Tomcat delsite.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.2
# Last Modified: 2009-03-29
CATALINA_HOME=/var/tomcat6
WORKER_ROOT="/var/robust"
WORKER_LIST=( worker1 worker2 )
username=$1
yourdomain=$2
userdel -r ${username}
rm -rf /var/webapps/${yourdomain}
# for Tomcat5
#sed -i -e "s/${yourdomain}/yourdomain/g" -e '/# VH begin: yourdomain/,/end: yourdomain>/d' ${CATALINA_HOME}/common/classes/log4j.properties
# for Tomcat6
sed -i -e "s/${yourdomain}/yourdomain/g" -e '/# VH begin: yourdomain/,/end: yourdomain>/d' ${CATALINA_HOME}/lib/log4j.properties
for (( i = 0 ; i < ${#WORKER_LIST[@]} ; i++ ))
do
rm -rf ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/Catalina/${yourdomain}
#sed -i '/<Host name="${yourdomain}"/,/Host>/d' ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/server.host
sed -i -e "s/${yourdomain}/yourdomain/g" -e '/<Host name="yourdomain"/,/Host>/d' ${WORKER_ROOT}/${WORKER_LIST[i]}/conf/server.host
cd ${WORKER_ROOT}/${WORKER_LIST[i]}/conf
cat server.header server.host server.footer > server.xml
done
rm -rf /etc/awstats/awstats.${yourdomain}.conf
#!/bin/bash
RETVAL=0
WORKER_ROOT=/var/robust
CONF_CHANGED=`find ${WORKER_ROOT}/worker1/conf/*.xml -mmin -15 | grep -v tomcat-users.xml | wc -l`
if [ $CONF_CHANGED != 0 ]; then
echo "Tomcat restart began at `date`"
/etc/init.d/tomcat restart
echo "Tomcat restart ended at `date`"
fi
exit $RETVAL
檔案名稱 | delsite.sh |
描述 | Shell script for deleting a Tomcat virtual host |
檔案大小 | 1 Kbytes |
下載次數 | 26 次 |
下載 |
檔案名稱 | tomcat_conf_check.sh |
描述 | Shell script for auto restart Tomcat when config file changes |
檔案大小 | 325 bytes |
下載次數 | 19 次 |
下載 |
檔案名稱 | awstats.newhost |
描述 | AWStats template for a new host |
檔案大小 | 58 Kbytes |
下載次數 | 29 次 |
下載 |
檔案名稱 | server.newhost |
描述 | server.xml template for a new host |
檔案大小 | 400 bytes |
下載次數 | 26 次 |
下載 |
檔案名稱 | log4j.newhost |
描述 | Log4J template for a new host |
檔案大小 | 561 bytes |
下載次數 | 25 次 |
下載 |
檔案名稱 | newsite.sh |
描述 | Shell script for creating a new Tomcat virtual host |
檔案大小 | 2 Kbytes |
下載次數 | 27 次 |
下載 |
Microsoft Windows XP [版本 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Andowson>ping aaa.tw
Pinging aaa.tw [67.220.219.231] with 32 bytes of data:
Reply from 10.77.16.252: Destination host unreachable.
Reply from 10.77.16.252: Destination host unreachable.
Reply from 10.77.16.252: Destination host unreachable.
Request timed out.
Ping statistics for 67.220.219.231:
Packets: Sent = 4, Received = 3, Lost = 1 (25% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
C:\Documents and Settings\Andowson>
123.123.123.123 aaa.tw
#!/bin/bash
# Name: awstats.sh
# Author: Andowson Chang (andowson [at] gmail [dot] com)
# Version: 1.2
# Last Modified: 2010-05-17
#
# check the latest stable version of AWStats 6.x
#
wget http://awstats.sourceforge.net/ -q -t 1 -T 5 -O /tmp/awstats.html
if [ -s /tmp/awstats.html ]; then
AWSTATS_URL=`grep rpm /tmp/awstats.html | cut -d"\"" -f2`
AWSTATS_FILENAME=`echo ${AWSTATS_URL}|cut -d "/" -f5`
AWSTATS_VERSION=`echo ${AWSTATS_FILENAME} | cut -d "-" -f2`
fi
rm -rf /tmp/awstats.html
if [ ! -r ${AWSTATS_FILENAME} ]; then
wget http://nchc.dl.sourceforge.net/sourceforge/awstats/${AWSTATS_FILENAME}
fi
if [ ! -r ${AWSTATS_FILENAME} ]; then
echo "Install failed: ${AWSTATS_FILENAME} not found!"
exit 1
fi
echo "Install AWStats ${AWSTATS_VERSION}"
yum -y install perl-libwww-perl.noarch
rpm -Uvh ${AWSTATS_FILENAME}
mkdir -p /etc/awstats
cp -rf /usr/etc/awstats/awstats.model.conf /etc/awstats/.
#
# install GeoIP plugin
#
if [ ! -d /usr/local/share/GeoIP/ ]; then
mkdir /usr/local/share/GeoIP/
fi
if [ ! -r /usr/local/share/GeoIP/GeoIP.dat ]; then
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip GeoIP.dat.gz
mv GeoIP.dat /usr/local/share/GeoIP/GeoIP.dat
fi
if [ ! -r /usr/local/share/GeoIP/GeoLiteCity.dat ]; then
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip GeoLiteCity.dat.gz
mv GeoLiteCity.dat /usr/local/share/GeoIP/GeoLiteCity.dat
fi
yum -y install zlib-devel
if [ ! -r GeoIP.tar.gz ]; then
wget http://geolite.maxmind.com/download/geoip/api/c/GeoIP.tar.gz
fi
tar zxvf GeoIP.tar.gz
cd GeoIP-*
./configure
make
make check
make install
echo '/usr/local/lib' >> /etc/ld.so.conf
/sbin/ldconfig /etc/ld.so.conf
cd ..
if [ ! -r Geo-IP-1.38.tar.gz ]; then
wget http://geolite.maxmind.com/download/geoip/api/perl/Geo-IP-1.38.tar.gz
fi
tar zxvf Geo-IP-1.38.tar.gz
cd Geo-IP-*
perl Makefile.PL LIBS='-L/usr/local/lib' INC='-I/usr/local/include'
make
make test
make install
cd ..
#
# install HostInfo plugin
#
if [ ! -r Net-XWhois-0.90.tar.gz ]; then
wget http://cpan.nctu.edu.tw/authors/id/V/VI/VIPUL/Net-XWhois-0.90.tar.gz
fi
tar -xzvf Net-XWhois-0.90.tar.gz
cd Net-XWhois-0.90
perl Makefile.PL
make
make install
#
# generate awstats.conf
#
echo '#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/awstats/wwwroot/classes/"
Alias /awstatscss "/usr/local/awstats/wwwroot/css/"
Alias /awstatsicons "/usr/local/awstats/wwwroot/icon/"
Alias /awstatsjs "/usr/local/awstats/wwwroot/js/"
ScriptAlias /awstats/ "/usr/local/awstats/wwwroot/cgi-bin/"
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/awstats/wwwroot">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>' > /etc/httpd/conf.d/awstats.conf
#
# add cronjob
#
echo '
# update GeoIP.dat ('`date +%Y.%m.%d`')
00 2 5 * * root /root/admin/updateGeoIP_dat.sh >/dev/null 2>&1
# update AWstats record ('`date +%Y.%m.%d`')
01 * * * * root /usr/local/awstats/tools/awstats_updateall.pl now >/dev/null' >> /etc/crontab
檔案名稱 | awstats.sh |
描述 | AWStats auto installer |
檔案大小 | 3 Kbytes |
下載次數 | 3 次 |
下載 |
andowson wrote:caramel您好:
您可以參考這個連結上面的圖片及說明:
http://www.easywayserver.com/implementation-tomcat-clustering.htm
Vertical Clustering