aix6安装apche2及配置负载+tomcat群集
1.安装编译环境gcc gcc-4.2.0-3.aix6.1.ppc.rpm gcc-cplusplus-4.2.0-3.aix6.1.ppc.rpm libgcc-4.2.0-3.aix6.1.ppc.rpm libstdcplusplus-4.2.0-3.aix6.1.ppc.rpm libstdcplusplus-devel-4.2.0-3.aix6.1.ppc.rpm
1.1下载地址: http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/rpmgroups.html#Development/Tools ftp下载地址: ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/gcc/
1.2安装gcc
rpm -ivh gcc-4.2.0-3.aix6.1.ppc.rpm
rpm -ivh libgcc-4.2.0-3.aix6.1.ppc.rpm
rpm -ivh libstdcplusplus-4.2.0-3.aix6.1.ppc.rpm
rpm -ivh libstdcplusplus-devel-4.2.0-3.aix6.1.ppc.rpm
rpm -ivh gcc-cplusplus-4.2.0-3.aix6.1.ppc.rpm
2.安装apche
2.1到apache官网http://httpd.apache.org/下载最新版本的httpd-2.2.20.tar.gz
2.2远程登录aix6 telnet 10.161.14.20 输入用户名:root 输入密码: xxx
2.3利用ftp上传httpd-2.2.20.tar.gz到aix6系统中/opt/soft目录下 创建文件夹soft
cd /opt
mkdir soft
2.4解压httpd-2.2.20.tar.gz
cd /opt/soft
gzip -d httpd-2.2.20.tar.gz
tar -xvf httpd-2.2.20.tar
2.5创建apche安装目录
cd /opt
mkdir cist
cd cist
mkdir apache2
2.6拷贝httpd-2.2.20文件到/opt/cist目录下
cd /opt/soft
cp -r httpd-2.2.20 /opt/cist/httpd-2.2.20
2.7配置apche安装环境,编译,安装.
./configure --prefix=/opt/cist/apache2/ --enable-proxy --enable-proxy-ajp --enable-proxy-balancer --enable-proxy-connect --enable-proxy-http --enable-info
make
make install
2.8修改配置文件
cd /opt/cist/apche2/conf
vi httpd.conf
把以下的两行 User daemon Group daemon 改为 User nobody Group nobody
3.配置apche负载
3.1修改配置文件httpd.conf
cd /opt/cist/apche2/conf
vi httpd.conf
Supplemental configuration
The configuration files in the conf/extra/ directory can be
included to add extra features or to modify the default configuration of
the server, or you may simply copy their contents here and change as
necessary.
Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf
Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf
Fancy directory listings
#Include conf/extra/httpd-autoindex.conf
Language settings
#Include conf/extra/httpd-languages.conf
User home directories
#Include conf/extra/httpd-userdir.conf
Real-time info on requests and configuration
Virtual hosts
Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf
Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf
Various default settings
#Include conf/extra/httpd-default.conf
Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
Note: The following must must be present to support
starting without SSL on platforms with no /dev/random equivalent
but a statically compiled-in mod_ssl.
3.2开启后台监控 为了了解某个节点负载多少,响应时间多久,服务是否正常呢?Apache提供了负载均衡监控平台,默认情况下服务是关闭的,需要通过修改配置文件开启服务,开启服务后,通过访问http://localhost/balancer-manager就可以查看负载详细情况
除了用于负载均衡还有http://localhost/server-status和http://localhost/server-info
修改配置文件httpd-info.conf
cd /opt/cist/apache2/conf/extra/
vi httpd-info.conf
Get information about the requests being processed by the server
and the configuration of the server.
Required modules: mod_status (for the server-status handler),
mod_info (for the server-info handler)
Allow server status reports generated by mod_status,
with the URL of http://servername/server-status
Change the ".localhost" to match your domain to enable.
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from all
ExtendedStatus controls whether Apache will generate "full" status
information (ExtendedStatus On) or just basic information (ExtendedStatus
Off) when the "server-status" handler is called. The default is Off.
ExtendedStatus On
Allow remote server configuration reports, with the URL of
http://servername/server-info (requires that mod_info.c be loaded).
Change the ".localhost" to match your domain to enable.
<Location /server-info> SetHandler server-info Order deny,allow Deny from all Allow from all
3.3配置apche虚拟主机 修改配置文件httpd-vhosts.conf
cd /opt/cist/apache2/conf/extra/
vi httpd-vhosts.conf
Virtual Hosts
If you want to maintain multiple domains/hostnames on your
machine you can setup VirtualHost containers for them. Most configurations
use only name-based virtual hosts so the server doesn't need to worry about
IP addresses. This is indicated by the asterisks in the directives below.
Please see the documentation at
URL:http://httpd.apache.org/docs/2.2/vhosts/
for further details before you try to setup virtual hosts.
You may use the command line option '-S' to verify your virtual host
configuration.
Use name-based virtual hosting.
NameVirtualHost *:80
VirtualHost example:
Almost any Apache directive may go into a VirtualHost container.
The first VirtualHost section is used for all requests that do not
match a ServerName or ServerAlias in any block.
<VirtualHost *:80> ServerAdmin webmaster@dummy-host.localhost DocumentRoot "D:/Apache2.2/docs/dummy-host.localhost" ServerName localhost ServerAlias localhost ProxyPass /gygis balancer://gycluster/ stickysession=jsessionid nofailover=On ProxyPassReverse /gygis balancer://gycluster/ ErrorLog "logs/dummy-host.localhost-error.log" CustomLog "logs/dummy-host.localhost-access.log" common
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.localhost DocumentRoot "D:/Apache2.2/docs/dummy-host2.localhost" ServerName dummy-host2.localhost ErrorLog "logs/dummy-host2.localhost-error.log" CustomLog "logs/dummy-host2.localhost-access.log" common
3.4开启/停止apche
cd /opt/cist/apache2/bin
./apachectl -k start
或者
./apachectl -k stop
或者
./apachectl -k restart
3.5配置Tomcat相关模块(AJP)
vi /opt/cist/tomcat7/conf/server.xml
3.5.1开启AJP配置
<Connector port="8055" protocol="AJP/1.3"
URIEncoding="UTF-8"
redirectPort="8443" />
3.5.2开启Session唯一,粘性会话
<Engine defaultHost="localhost" name="Catalina" <span style="color:red">jvmRoute="gis55"</span>>
<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
<!-- Use the LockOutRealm to prevent attempts to guess user passwords
via a brute-force attack -->
<Realm className="org.apache.catalina.realm.LockOutRealm">
<!-- This Realm uses the UserDatabase configured in the global JNDI
resources under the key "UserDatabase". Any edits
that are performed against this UserDatabase are immediately
available for use by the Realm. -->
<Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
</Realm>
<Host appBase="webapps" autoDeploy="true" name="localhost" unpackWARs="true">
<!-- SingleSignOn valve, share authentication between web applications
Documentation at: /docs/config/valve.html -->
<!--
<Valve className="org.apache.catalina.authenticator.SingleSignOn" />
-->
<!-- Access log processes all example.
Documentation at: /docs/config/valve.html
Note: The pattern used is equivalent to using pattern="common" -->
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t "%r" %s %b" prefix="localhost_access_log." resolveHosts="false" suffix=".txt"/>
3.6修改JAVAEE应用中WebRoot/WEB-INF/web.xml文件
<display-name>xxx</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
4.AIX重启时,apache自动启动
4.1创建启动脚本
cd /etc
touch rc.apache
chown g+x rc.apache或者 chmod 700 rc.apache
vi rc.apache
#!/usr/bin/ksh echo "----------------apache starting---------------------------------" su - root "-c /opt/cist/apache2/bin/apachectl -k start" echo "----------------apache start completed---------------------------------"
4.2添加启动脚本到/etc/inittab最下面,实现自启动。并且输出启动日志。
vi /etc/inittab
rc.apache:2:wait:/etc/rc.apache > /dev/console 2>&1