设为首页 收藏本站
查看: 279|回复: 0

[经验分享] aix6安装apche2及配置负载+tomcat群集

[复制链接]

尚未签到

发表于 2017-2-7 08:55:12 | 显示全部楼层 |阅读模式
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

<!--取消注释,配置后台监控-->
Include conf/extra/httpd-info.conf

# Virtual hosts

<!--取消注释,配置apche虚拟主机-->
Include conf/extra/httpd-vhosts.conf

# 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>

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


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
  
    <!--修改为all,允许所有IP访问. 默认为.localhost只允许localhost访问-->  
    Allow from all
  

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

</Location>

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


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"
   
    <!--配置负载均衡节点balancer://gycluster-->
    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>
<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 port="8055" protocol="AJP/1.3"   
                URIEncoding="UTF-8"  
                redirectPort="8443" />

3.5.2开启Session唯一,粘性会话
    <Engine defaultHost="localhost" name="Catalina" jvmRoute="gis55">
      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->

     <!--取消注释开启session同步-->
     <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>


      <!-- 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 &quot;%r&quot; %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>
  
     <!--开启分布式处理-->  
     <distributable/>
  

</web-app>
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

参考博文:http://www.iyunv.com/Linux/2011-01/31484.htm

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-338559-1-1.html 上篇帖子: 解读Tomcat(四):请求处理解析Part_2 下篇帖子: How tomcat work连载二:简易的Servlet容器
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表