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

[经验分享] keepalived+httpd+tomcat实现高可用负载均衡

[复制链接]

尚未签到

发表于 2015-11-19 14:28:20 | 显示全部楼层 |阅读模式
  一、环境

centos 6.5

keepalived keepalived-1.2.19.tar.gz

httpd httpd-2.4.12.tar.gz

tomcat apache-tomcat-7.0.63.tar.gz

二、部署

安装 httpd


tar -zxvf httpd-2.4.12.tar.gz
cd httpd-2.4.12
./configure --prefix=/usr/local/apache2 --enable-mods-share=all
这里会报错提示:
configure: error: APR not found.  Please read the documentation.
解决办法如下:
到Apache官网下载缺少的软件包,下载地址http://apr.apache.org/download.cgi
下载
apr-1.5.2.tar.gz
apr-util-1.5.4.tar.gz
安装缺少的依赖的软件包
tar -zxvf apr-1.5.2.tar.gz
cd apr-1.5.2
./configure --prefix=/usr/local/apr
这里会提示没有gcc
提示内容如下
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/opt/httpd/apr-1.5.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
需要添加gcc支持
yum -y install gcc
yum -y install gcc-c++
完成之后我们接着安装apr
./configure --prefix=/usr/local/apr
make && make install
tar -zxvf apr-util-1.5.4.tar.gz
cd apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make && make install
然后接着配置httpd
./configure --prefix=/usr/local/apache2 --enable-mods-share=all
在这个后面添加
-with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
合起来之后是
./configure --prefix=/usr/local/apache2 --enable-mods-share=all -with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
好无语到了这里竟敢有提示缺少依赖包!!!
提示内容如下:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org
没办法我们接着添加依赖,wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.37
./configure --prefix=/usr/local/pcre
make && make install
然后,我们接着装httpd
./configure --prefix=/usr/local/apache2 --enable-mods-share=all -with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre/bin/pcre-config
终于完成配置了!
make && make install
  配置httpd


vim /usr/local/apache2/conf/httpd.conf
在其中添加
# Load mod_jk module
LoadModule jk_module modules/mod_jk.so
# Specify jk log file.
JkLogFile /log/httpd/mod_jk.log
JkShmFile /var/log/httpd/mod_jk.shm
# Specify jk log level [debug/error/info]
JkLogLevel info
# Specify workers.properties, this file tell jk:
# how many nodes and where they are.
JkWorkersFile /opt/tomcat/conf/workers.properties
# Specify which requests should handled by which node.
JkMount /* controller
并且放开
# Server-pool management (MPM specific)
Include conf/extra/httpd-mpm.conf
这里是配置httpd并发数,他有三种工作模式
Apache Prefork、Worker和Event!详细可参阅其他的文章
或者是参考官方文档(http://httpd.apache.org/docs/2.4/mod/mpm_common.html)
这里特别提醒如果想支持并发数超过400的需要添加
ServerLimit 256这个属性,这个支持最大并发数6400
如果还需要更大则需要从新编译httpd!
在启动httpd的时候发现没有成功可以到httpd的日志中查看原因!!!
  安装Apache Tomcat Connector(mod_jk)

tar -zxvf tomcat-connectors-1.2.40-src.tar.gz  

cd tomcat-connectors-1.2.40-src/native/

./buildconf.sh

这里会提示缺少autoconf

autoconf not found.  
You need autoconf version 2.59 or newer installed to build mod_jk from SVN.

yum -y install autoconf
  然后,我们继续./buildconf.sh

靠,还让不让人活啊,又缺少libtool  

libtool not found.
You need libtool version 1.4 or newer installed to build mod_jk from SVN.

yum -y install libtool
  接着./buildconf.sh

./configure –with-apxs=/usr/local/apache2/bin/apxs

make && make install

如果成功结束,你可以在/usr/local/apache2/modules/下找到mod_jk.so文件。

安装tomcat

需要修改配置文件server.xml,



在后添加如下内容

<Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"
channelSendOptions="8">
<Manager className="org.apache.catalina.ha.session.DeltaManager"
expireSessionsOnShutdown="false" notifyListenersOnReplication="true" />
<Channel className="org.apache.catalina.tribes.group.GroupChannel">
<Membership className="org.apache.catalina.tribes.membership.McastService"
address="228.0.0.4" port="45564" frequency="500" dropTime="3000" />
<Receiver className="org.apache.catalina.tribes.transport.nio.NioReceiver"
address="auto" port="4000" autoBind="100" selectorTimeout="5000"
maxThreads="6" />
<Sender
                        className="org.apache.catalina.tribes.transport.ReplicationTransmitter">
<Transport
                            className="org.apache.catalina.tribes.transport.nio.PooledParallelSender" />
</Sender>
<Interceptor
                        className="org.apache.catalina.tribes.group.interceptors.TcpFailureDetector" />
<Interceptor
                        className="org.apache.catalina.tribes.group.interceptors.MessageDispatch15Interceptor" />
</Channel>
<Valve className="org.apache.catalina.ha.tcp.ReplicationValve"
filter="" />
<Valve className="org.apache.catalina.ha.session.JvmRouteBinderValve" />
<Deployer className="org.apache.catalina.ha.deploy.FarmWarDeployer"
tempDir="/tmp/war-temp/" deployDir="/tmp/war-deploy/" watchDir="/tmp/war-listen/"
watchEnabled="false" />
<ClusterListener
                    className="org.apache.catalina.ha.session.JvmRouteSessionIDBinderListener" />
<ClusterListener
                    className="org.apache.catalina.ha.session.ClusterSessionListener" />
</Cluster>
版权声明:本文为博主原创文章,未经博主允许不得转载。

运维网声明 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-141223-1-1.html 上篇帖子: keepalived+nginx双机热备+负载均衡 下篇帖子: Nginx负载均衡+keepalived双机热备
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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