aix6安装apche2及配置负载+tomcat群集

[b]1.安装编译环境gcc[/b]
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下载地址:
[url]http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/rpmgroups.html#Development/Tools[/url]
ftp下载地址:
[url]ftp://ftp.software.ibm.com/aix/freeSoftware/aixtoolbox/RPMS/ppc/gcc/[/url]

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


[b]2.安装apche[/b]

2.1到apache官网[url]http://httpd.apache.org/[/url]下载最新版本的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[color=red] nobody[/color]
Group [color=red]nobody[/color]


[b]3.配置apche负载[/b]

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
[color=red]
<!--取消注释,配置后台监控-->
Include conf/extra/httpd-info.conf
[/color]

# Virtual hosts
[color=red]
<!--取消注释,配置apche虚拟主机-->
Include conf/extra/httpd-vhosts.conf
[/color]

# 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.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>

[color=blue]
<!--配置AJP分发节点-->
ProxyRequests Off
<proxy balancer://gycluster>
BalancerMember ajp://10.161.14.55:8055/gis loadfactor=1 route=gis55
BalancerMember ajp://10.161.14.20:8020/gis loadfactor=1 route=gis20
</proxy>
[/color]


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
[color=red]
<!--修改为all,允许所有IP访问. 默认为.localhost只允许localhost访问-->
Allow from [color=blue]all[/color]
[/color]
</Location>

#
# 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.
#
[color=red]ExtendedStatus On[/color]

#
# 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
[color=red]
<!--修改为all,允许所有IP访问. 默认为.localhost只允许localhost访问-->
Allow from [color=blue]all[/color]
[/color]
</Location>

[color=red]
<!--开启负载信息监控-->
<Location /balancer-manager>
SetHandler balancer-manager
Order Deny,Allow
Deny from all
Allow from all
</Location>
[/color]


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 <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.localhost
DocumentRoot "D:/Apache2.2/docs/dummy-host.localhost"
[color=red]
<!--配置负载均衡节点balancer://gycluster-->
ServerName localhost
ServerAlias localhost
ProxyPass /gygis balancer://gycluster/ stickysession=jsessionid nofailover=On
ProxyPassReverse /gygis balancer://gycluster/ [/color]
ErrorLog "logs/dummy-host.localhost-error.log"
CustomLog "logs/dummy-host.localhost-access.log" common
</VirtualHost>

<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
</VirtualHost>


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配置

<!--修改ajp连接端口-->
<Connector [color=red] port="8055"[/color] protocol="AJP/1.3"
URIEncoding="UTF-8"
redirectPort="8443" />


3.5.2开启Session唯一,粘性会话

<Engine defaultHost="localhost" name="Catalina" [color=red]jvmRoute="gis55"[/color]>

<!--For clustering, please take a look at documentation at:
/docs/cluster-howto.html (simple how to)
/docs/config/cluster.html (reference documentation) -->
[color=red]
<!--取消注释开启session同步-->
<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>[/color]


<!-- 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"/>
</Host>
</Engine>

3.6修改JAVAEE应用中WebRoot/WEB-INF/web.xml文件


<?xml version="1.0" encoding="UTF-8"?>
<web-app id="xxx" version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">

<display-name>xxx</display-name>

<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
</welcome-file-list>
[color=red]
<!--开启分布式处理-->
<distributable/>
[/color]
</web-app>

[b]4.AIX重启时,apache自动启动[/b]

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


参考博文:[url]http://www.linuxidc.com/Linux/2011-01/31484.htm[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值