Apache tomcat memcached整合.docx

上传人:b****6 文档编号:12579453 上传时间:2023-06-06 格式:DOCX 页数:13 大小:19.99KB
下载 相关 举报
Apache tomcat memcached整合.docx_第1页
第1页 / 共13页
Apache tomcat memcached整合.docx_第2页
第2页 / 共13页
Apache tomcat memcached整合.docx_第3页
第3页 / 共13页
Apache tomcat memcached整合.docx_第4页
第4页 / 共13页
Apache tomcat memcached整合.docx_第5页
第5页 / 共13页
Apache tomcat memcached整合.docx_第6页
第6页 / 共13页
Apache tomcat memcached整合.docx_第7页
第7页 / 共13页
Apache tomcat memcached整合.docx_第8页
第8页 / 共13页
Apache tomcat memcached整合.docx_第9页
第9页 / 共13页
Apache tomcat memcached整合.docx_第10页
第10页 / 共13页
Apache tomcat memcached整合.docx_第11页
第11页 / 共13页
Apache tomcat memcached整合.docx_第12页
第12页 / 共13页
Apache tomcat memcached整合.docx_第13页
第13页 / 共13页
亲,该文档总共13页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

Apache tomcat memcached整合.docx

《Apache tomcat memcached整合.docx》由会员分享,可在线阅读,更多相关《Apache tomcat memcached整合.docx(13页珍藏版)》请在冰点文库上搜索。

Apache tomcat memcached整合.docx

Apachetomcatmemcached整合

ApacheTomcatMemcached整合

一、Apache安装

1、下载Apache2.4及依赖包

Apache官网下载:

http:

//httpd.apache.org/download.cgi

由于Apache依赖于APR、APR-Util和PCRE,所以需要下载:

APR+APR-Util:

http:

//apr.apache.org/download.cgi

PCRE:

在此,笔者使用均为目前最新版本,Apache1.4.6,APR1.4.1,APR-Util2.4.1,Perl5.14.2,PCRE8.30

2、安装依赖

●安装APR及APR-Util

解压缩APR及APR-Util

shell>sudotarzxvfapr-1.4.6.tar.gz-C/opt/sources

shell>sudotarzxvfapr-util-1.4.1.tar.gz-C/opt/sources

创建安装目录并创建软链接

shell>sudomkdir/opt/software/develop/apr-1.4.6

shell>sudomkdir/opt/software/develop/apr-util-1.4.1

shell>sudoln-s/opt/software/develop/apr-1.4.6/usr/local/apr

shell>sudoln-s/opt/software/develop/apr-util-1.4.1/usr/local/apr-util

安装APR及APR-Util

shell>cd/opt/sources/apr-1.4.6

shell>sudo./configure--prefix=/usr/local/apr

shell>sudomake

shell>sudomakeinstall

shell>cd/opt/sources/apr-util-1.4.1

shell>sudo./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr

shell>sudomake

shell>sudomakeinstall

●安装PCRE

首先请确定系统安装了Perl,Perl在此不再赘述,如有需要请去官网查看安装细则:

http:

//www.cpan.org/src/README.html

解压缩PCRE

shell>sudotarzxvfpcre-8.30.tar.gz-C/opt/sources

创建PCRE安装目录及软链接

shell>sudomkdir/opt/software/develop/pcre-8.30

shell>sudoln-s/opt/software/develop/pcre-8.30/usr/local/pcre

安装PCRE

shell>cd/opt/sources/pcre-8.30

shell>sudo./configure--prefix=/usr/local/pcre

shell>sudomake

shell>sudomakeinstall

3、安装Apache2.4

解压缩Apache2.4

shell>sudotarzxvfhttpd-2.4.2.tar.gz-C/opt/sources

创建Apache安装目录及软链接

shell>sudomkdir/opt/software/develop/httpd-2.4.2

shell>sudoln-s/opt/software/develop/httpd-2.4.2/usr/local/apache2

安装Apache

shell>cd/opt/sources/httpd-2.4.2

#此处请根据自己要搭建的环境进行配置,我这里是为了配置PHP环境

shell>sudo./configure--prefix=/usr/local/apache2--enable-so--enable-rewrite=shared--enable-mods-shared=most--with-mpm=worker--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--with-pcre=/usr/local/pcre

shell>sudomake

shell>sudomakeinstall

4、启动Apache

通过apachectl启动Apach

shell>sudo/usr/local/apache2/bin/apachectlstart

检查是否有Apache进程

shell>psaux|grephttpd

如果有Apache的进程,则证明启动成功,浏览器地址栏输入http:

//localhost试试吧~

启动成功之后,可以将apachectl拷贝到/etc/init.d下,作为service启动。

shell>sudocp/usr/local/apache2/bin/apachectl/etc/init.d/httpd

shell>sudoservicehttpdstart

 

5、安装tomcat接口包(ajp1.3)

解压

tarzxvftomcat-connectors-1.2.32-src.tar.gz-C/tmp

cat/tmp/tomcat-connectors-1.2.32-src/BUILD.txt

cdnative

./configure--with-apxs=/usr/sbin/apxs

make&&makeinstall

cp../conf/httpd-jk.conf/etc/httpd/conf.d/jk.conf

编辑配置文件/etc/httpd/conf.d/jk.conf

在文件最后添加

JkMount/*.jspwlb

JkMount/manager/*wlb

JkMount/*.gifwlb

编辑/usr/local/apache2/conf/httpd.conf(与解压后目录一致,需保留解压后目录)文件,加载jk_module

在httpd.conf文件最后面写上

LoadModulejk_modulemodules/mod_jk.so

创建转向文件/etc/httpd/conf/workers.properties

worker.list=wlb

worker.wlb.type=lb

worker.wlb.balance_workers=tomcat1,tomcat2

worker.tomcat1.type=ajp13

worker.tomcat1.host=10.10.68.11

worker.tomcat1.port=8009

worker.tomcat1.lbfactor=2#权重调整负载

worker.tomcat2.type=ajp13

worker.tomcat2.host=10.10.68.12

worker.tomcat2.port=8009

worker.tomcat2.lbfactor=1

加载转向文件workers.properties

在/usr/local/apache2/conf/httpd.conf文件最后面写上

JkWorkersFile"/etc/httpd/conf/workers.properties"

JkLogLevelinfo

JkLogStampFormat"[%a%b%d%H:

%M:

%S%Y]"

JkRequestLogFormat"%w%V%T"

写VirtualHost

在httpd.conf文件最后面写上

80>

DocumentRoot/var/www/jsp

#目录主路径

ServerNamemarket

#虚拟主机名

DirectoryIndexindex.htmindex.htmlindex.jspdefault.htmldefautl.htmdefault.jsp

#设置默认文档

JkMount/*.jspmarket

#转向使用的文件后辍及条件

ErrorLoglogs/market-error_log

CustomLoglogs/market-access_logcommon

#日志记录,可不要

重启httpd服务

servicehttpdstart

如果更改ServerName等参数,需要在/usr/local/apache2/conf/httpd.conf、/opt/software/develop/httpd-2.4.2/conf/httpd.conf以及/etc/httpd/conf/httpd.conf中都做修改,事实上前两个目录是软链接关系

二、JDK安装

#chmoda+xjdk-6u4-linux-i586-rpm.bin

#./jdk-6u4-linux-i586-rpm.bin

JAVA环境变量设置:

#vi/etc/profile

在文件最后添加以下内容:

JAVA_HOME=/usr/java/jdk1.6.0_04

CLASSPATH=.:

$JAVA_HOME/lib/tools.jar:

$JAVA_HOME/lib/dt.jar

PATH=$JAVA_HOME/bin:

$PATH

CATALINA_HOME=/usr/local/tomcat

exportJAVA_HOMECLASSPATHPATHCATALINA_HOME

执行如下命令使环境变量生效:

source/etc/profile

测试配置是否成功:

java–version

三、Tomcat安装

1、下载Tomcat及依赖包

下载并安装tomcat

#wget

#tarzxvfapache-tomcat-6.0.16.tar.gz

#mvapache-tomcat-6.0.16/usr/local/tomcat

下载msm,以支持tomcat

将下载的msm,放入TOMCAT_HOME/lib/

2、Tomcat随机启动

#vi/etc/rc.local

添加以下内容:

/usr/local/tomcat/bin/startup.sh

3、tomcat6配置文件server.xml

--YoushouldsetjvmRoutetosupportload-balancingviaAJPie:

-->

改成

--YoushouldsetjvmRoutetosupportload-balancingviaAJPie:

-->

--

-->

说明:

第一台tomcat就把jvmRoute="tomcat1"

第二台tomcat就把jvmRoute="tomcat2"

--

-->

去掉注释变为

***群集详细配置***

channelSendOptions="8">

expireSessionsOnShutdown="false"

notifyListenersOnReplication="true"/>

address="228.0.0.4"

port="45564"

frequency="500"

dropTime="3000"/>

address="auto"

port="4000"

autoBind="100"

selectorTimeout="5000"

maxThreads="6"/>

filter=""/>

tempDir="/tmp/war-temp/"

deployDir="/tmp/war-deploy/"

watchDir="/tmp/war-listen/"

watchEnabled="false"/>

配置应用的web.xml:

在每个webapps应用中,修改配置文件web.xml文件添加元素

在web.xml文件中元素下增加以下内容:

--此应用将与群集服务器复制Session-->

具体修改如下:

修改前:

xmlversion="1.0"encoding="ISO-8859-1"?

>

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

version="2.5">

修改后:

xmlversion="1.0"encoding="ISO-8859-1"?

>

xmlns:

xsi="http:

//www.w3.org/2001/XMLSchema-instance"

xsi:

schemaLocation="

version="2.5">

--此应用将与群集服务器复制Session-->

4、tomcat6配置文件context.xml

添加如下内容:

memcachedNodes="n1:

192.168.1.144:

11211,n2:

192.168.1.244:

11211"

failoverNodes="n2"

requestUriIgnorePattern=".*\.(ico|png|gif|jpg|css|js)$"

/>

n1、n2分别代表安装memcached的节点,节点间有逗号隔开

5、tomcat清理缓存

删除TOMCAT_HOME\work\下及conf\Catalina\下的所有内容

四、Memcached安装

1、下载Memcached及依赖包

memcachelinux版本安装包下载

⏹memcache的linux安装程序(http:

//memcached.org/)

⏹memcache依赖包libevent

2、安装memcache

安装依赖包libevent

tarxvzflibevent-1.4.9-stable.tar.gz

cdlibevent-1.4.9-stable

./configure-prefix=/usr

make&makeinstall

注意:

最好在执行./configure命令时加prefix参数的值为/usr,否则会遇到启动memcache时找不到依赖库文件,memcache默认是在/usr/lib/下获取依赖库文件,如果遇到问题建立软连接解决。

安装memcache

tarxvzfmemcached-1.4.5.tar.gz

cdmemcached-1.4.5

./configure-with-libevent=/usr

make&makeinstall

启动memcache

/usr/local/bin/memcached-d-m64-uroot

3、启动memcached

memcached-d-m10-uroot–lip地址-p11211-c256-P/tmp/memcached.pid

4、Memcached命令参数

∙-p监听的端口

∙-l连接的IP地址,默认是本机

∙-dstart启动memcached服务

∙-drestart重起memcached服务

∙-dstop|shutdown关闭正在运行的memcached服务

∙-dinstall安装memcached服务

∙-duninstall卸载memcached服务

∙-u以的身份运行(仅在以root运行的时候有效)

∙-m最大内存使用,单位MB。

默认64MB

∙-M内存耗尽时返回错误,而不是删除项

∙-c最大同时连接数,默认是1024

∙-f块大小增长因子,默认是1.25

∙-n最小分配空间,key+value+flags默认是48

∙-h显示帮助

五、启动顺序

memcached→apache→tomcat

展开阅读全文
相关搜索
资源标签

当前位置:首页 > 外语学习 > 英语考试

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2