windows 아래 nginx + tomcat 클 러 스 터, session 복사 공유 실현
1. apache tomcat 를 설치 합 니 다.
2. ng 을 설치 하고 압축 을 풀 어 ip1 에 설치 하 며 필요 에 따라 설정 파일 nginx. conf 를 수정 합 니 다.
4. 567913. 이때 tomcat 1, 2 가 시작 되면 사용 합 니 다.http://nginx.ip방문, ng 로 그 를 보면 ip1 서버 를 요청 할 때 도 있 고, ip2 를 요청 할 때 도 있 습 니 다.이것 은 이미 ng 부하 기능 에 이 르 렀 다.
windows nginx 명령:
닫 기: nginx. exe - s stop
시작: start nging. exe
nginx. exe 재 부팅 - s reload
주, 그러나 이때 tomcat 1, tomcat 2 가 같은 프로젝트 를 배치 하기 때문에 데이터 가 있 으 면 session 에 직접 쓰 고 사용 하 는 쿠키 가 아 닌 session 의 key (방문 주 소 는 ip 을 사용 하기 때문에 도 메 인 이름 이 적용 되 지 않 기 때문에 쿠키 를 사용 할 수 없습니다) 는 두 번 의 방문 session id 가 일치 하지 않 습 니 다.이 때 는 session 복사 나 공 유 를 해 야 합 니 다.다음 작업 이 필요 합 니 다:
3. tomcat 의 conf, server. xml 파일 수정 (두 tomcat 수정 일치):
tomcat 군집 주석 cluster 를 엽 니 다.
노드 < Engine name = "Catalina" defaultHost = "localhost" jvmRoute = "driver 1" > 을 수정 합 니 다.(tomcat 1 과 tomcat 2 가 지정 한 jvmRoute 이름 이 일치 합 니 다)
4. 프로젝트 코드 에 웹. xml 에 노드 < distributable / > 를 추가 하면 됩 니 다.
테스트:
index.jsp:
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream portal-driver{
server ip1:8081 max_fails=0;
server ip2:8082 max_fails=0;
}
server {
listen 80;
server_name localhost;
location /drive{
root html;
index index.html index.htm;
proxy_pass http://portal-driver;
proxy_redirect default;
}
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
여러 번 방문 하 다
Server Info 의 ip 와 포트 는 ip1, ip2 폴 링 에 있 습 니 다.하지만 아래 세 션 id 는 모두 같 습 니 다.됐다.
(채소 새 는 뿌리 지 마라.)
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.