一、首先安裝memcached(A主機(jī)、B主機(jī)都需要安裝)
我們注重客戶提出的每個(gè)要求,我們充分考慮每一個(gè)細(xì)節(jié),我們積極的做好網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)服務(wù),我們努力開(kāi)拓更好的視野,通過(guò)不懈的努力,創(chuàng)新互聯(lián)贏得了業(yè)內(nèi)的良好聲譽(yù),這一切,也不斷的激勵(lì)著我們更好的服務(wù)客戶。 主要業(yè)務(wù):網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)站設(shè)計(jì),小程序開(kāi)發(fā),網(wǎng)站開(kāi)發(fā),技術(shù)開(kāi)發(fā)實(shí)力,DIV+CSS,PHP及ASP,ASP.Net,SQL數(shù)據(jù)庫(kù)的技術(shù)開(kāi)發(fā)工程師。下載地址:http://download.csdn.net/detail/ttyyadd/9414586
下載完成后解壓到本地磁盤(pán)。
打開(kāi)cmd命令窗口進(jìn)行到memcached.exe所在目錄,然后執(zhí)行下面命令進(jìn)行安裝
memcached.exe -d install
安裝后并沒(méi)有啟動(dòng)需要到服務(wù)管理里面找到memached服務(wù)將它啟動(dòng)。
二、下面開(kāi)始配置tomcat6
1、首先下載所需要jar
將下載的jar放到tomcat目錄下的lib文件夾下面
http://download.csdn.net/detail/ttyyadd/9414529
2、開(kāi)始配置(A主機(jī):192.168.7.100)context.xml
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:192.168.7.100:11211,n2:192.168.7.101:11211"
failoverNodes="n2"
requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" />
開(kāi)始配置(B主機(jī):192.168.7.101)context.xml
<Manager className="de.javakaffee.web.msm.MemcachedBackupSessionManager"
memcachedNodes="n1:192.168.7.100:11211,n2:192.168.7.101:11211"
failoverNodes="n1"
requestUriIgnorePattern=".*.(ico|png|gif|jpg|css|js)$"
transcoderFactoryClass="de.javakaffee.web.msm.serializer.kryo.KryoTranscoderFactory" />
這里要注意的是failoverNodes屬性,該屬性值要指向(非本機(jī)的)另外一臺(tái)主機(jī)。
3、新建一個(gè)test.jsp頁(yè)面,分別放到A主機(jī)和B主機(jī)的Tomcat 下的ROOT目錄
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<html><head><title></title></head>
<body>
<%
System.out.println(session.getId());
out.println("<br> HostA HostB, SESSION ID:" + session.getId()+"<br>");
%>
</body>
</html>
三、配置nginx
1、首先下載 nginx安裝包
http://nginx.org/
2、開(kāi)始配置nginx
打開(kāi)安裝目錄的nginx.conf。我的安裝目錄為(D: ginx-1.9.9conf ginx.conf)
#user nobody;
worker_processes1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main'$remote_addr - $remote_user [$time_local] "$request"'
#'$status $body_bytes_sent "$http_referer"'
#'"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout0;
keepalive_timeout65;
#gzip on;
upstream mysvr {
#weigth參數(shù)表示權(quán)值,權(quán)值越高被分配到的幾率越大
#1.down 表示單前的server暫時(shí)不參與負(fù)載
#2.weight 默認(rèn)為1.weight越大,負(fù)載的權(quán)重就越大。
#3.backup: 其它所有的非backup機(jī)器down或者忙的時(shí)候,請(qǐng)求backup機(jī)器。所以這臺(tái)機(jī)器壓力會(huì)最輕。
#server 192.168.1.116 down;
#server 192.168.1.116 backup;
server 192.168.7.100:8080 weight=1;
server 192.168.7.101:8080 weight=1;
}
server {
listen80;
server_name192.168.7.100; #charset koi8-r;
#access_log logs/host.access.log main;
location/ {
proxy_pass http://mysvr;
proxy_connect_timeout 5s;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#禁用緩存
proxy_buffering off;
}
#error_page404 /404.html;
# redirect server error pages to thestatic page /50x.html
#
error_page500 502 503 504 /50x.html;
location= /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on127.0.0.1:80
#
#location~ .php$ {
# proxy_pass http://127.0.0.1; #}
# pass the PHP scripts to FastCGI server listening on127.0.0.1:9000
#
#location~ .php$ {
# root html;
# fastcgi_pass127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME/scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files,if Apache's document root # concurs with nginx's one #
#location~ /.ht {
# deny all;
#}
}
# anothervirtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location/ {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location/ {
# root html;
# index index.html index.htm;
# }
#}
}
保存并關(guān)閉。nginx.conf 文件內(nèi)容比較多,其實(shí)只需要修改紅色字體部分
然后在cmd窗口進(jìn)入安裝目錄啟動(dòng)nginx命令是:
start nginx
nginx其它相關(guān)命令:
1) 啟動(dòng)Nginx:start nginx
2) 停止Nginx:nginx -s stop
3) 修改配置后重啟:nginx -s reload
到現(xiàn)在已經(jīng)配置完成
開(kāi)始訪問(wèn):http://192.168.7.100/test.jsp
可以看到session id不會(huì)改變。
分享標(biāo)題:分布式網(wǎng)站部署-創(chuàng)新互聯(lián)
文章出自:http://jinyejixie.com/article40/dpsdho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站改版、品牌網(wǎng)站制作、品牌網(wǎng)站設(shè)計(jì)、搜索引擎優(yōu)化、商城網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容