Keepalived+nginx+redis主從+tomcat一機多例項實現會話共享
1
2
3
|
``` cpp yum install nginx -y ``` |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
``` cpp [root@redis ~]# sed -e 's@ @@g;/^$/d;/^#/d' /etc/nginx/nginx.conf worker_processes1; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-stream; sendfileon; keepalive_timeout65; upstreammycluser { server192.168.58.30:8080; server192.168.58.30:8081; server192.168.58.10:8080; server192.168.58.10:8081; } server{ listen80; server_namelocalhost; location/{ roothtml; indexindex.htmlindex.htmindex.jsp; proxy_passhttp://mycluser; proxy_set_headerX-Real-IP$remote_addr; proxy_set_headerHost$host; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; proxy_redirectoff; } error_page500502503504/50x.html; location=/50x.html{ roothtml; } } } ``` |
1
2
3
|
``` cpp yum install redis -y ``` |
1
2
3
4
5
|
``` cpp [root@mongo1 tmp]# sed -n '/^slaveof/p' /etc/redis.conf slaveof 192.168.58.30 6379 [root@mongo1 tmp]# ``` |
1
2
3
4
5
6
7
8
|
``` cpp [root@redis ~]# redis-cli -h 192.168.58.30 redis 192.168.58.30:6379> set name zhuima OK redis 192.168.58.30:6379> get name "zhuima" redis 192.168.58.30:6379> ``` |
1
2
3
4
5
6
7
|
``` cpp [root@mongo1 webapps]# redis-cli -h 192.168.58.10 redis 192.168.58.10:6379> get name "zhuima" redis 192.168.58.10:6379> redis 192.168.58.10:6379> ``` |
1
2
3
|
``` cpp [root@redis tmp]# tar xf jdk-7u60-linux-x64.gz -C /usr/local ``` |
1
2
3
4
5
6
7
8
9
10
11
12
|
``` cpp [root@redis local]# cat /etc/profile.d/java.sh export JAVA_HOME=/usr/local/jdk1.7.0_60 export PATH=$PATH:$JAVA_HOME/bin export JRE_HOME=$JAVA_HOME/jre [root@redis local]# source /etc/profile.d/java.sh [root@redis local]# java -version java version "1.7.0_60" Java(TM) SE Runtime Environment (build 1.7.0_60-b19) Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode) [root@redis local]# ``` |
1
2
3
4
5
|
``` cpp [root@redis local]# tar xf apache-tomcat-7.0.54.tar.gz -C /usr/local/ [root@redis local]# mv apache-tomcat-7.0.54/ tomcat1 [root@redis local]# cp -Rf tomcat1 tomcat2 ``` |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
``` cpp [root@www conf]# cat context.xml <? xml version = '1.0' encoding = 'utf-8' ?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- The contents of this file will be loaded for each web application --> < Context > <!-- Default set of monitored resources --> < WatchedResource >WEB-INF/web.xml</ WatchedResource > < Valve className = "com.radiadesign.catalina.session.RedisSessionHandlerValve" /> < Manager className = "com.radiadesign.catalina.session.RedisSessionManager" host = "192.168.58.30" port = "6379" database = "0" maxInactiveInterval = "60" /> <!-- Uncomment this to disable session persistence across Tomcat restarts --> <!-- <Manager pathname="" /> --> <!-- Uncomment this to enable Comet connection tacking (provides events on session expiration as well as webapp lifecycle) --> <!-- <Valve className="org.apache.catalina.valves.CometConnectionManagerValve" /> --> </ Context > ``` |
1
2
3
4
|
``` cpp [root@redis conf]# yes | cp context.xml /usr/local/tomcat2/conf/ cp: overwrite `/usr/local/tomcat2/conf/context.xml'? [root@redis conf]# ``` |
1
2
3
4
5
6
7
8
|
``` cpp [root@redis conf]# for x in tomcat{1,2};do scp context.xml 192.168.58.10:/usr/local/$x/conf/;done root@192.168.58.10's password: context.xml 100% 1678 1.6KB/s 00:00 root@192.168.58.10's password: context.xml 100% 1678 1.6KB/s 00:00 [root@redis conf]# ``` |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
``` cpp [root@redis webapps]# cat index.jsp <%@ page language="java" %> < html > < head >< title >TomcatB</ title ></ head > < body > < h1 >< font color = "blue" >192.168.58.30:8081 Tomcat2 </ h1 > < table align = "centre" border = "1" > < tr > < td >Session ID</ td > <% session.setAttribute("abc","abc"); %> < td ><%= session.getId() %></ td > </ tr > < tr > < td >Created on</ td > < td ><%= session.getCreationTime() %></ td > </ tr > </ table > </ body > </ html > ``` |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
``` cpp <%@ page language="java" %> < html > < head >< title >TomcatB</ title ></ head > < body > < h1 >< font color = "red" >192.168.58.10:8080 Tomcat1 </ h1 > < table align = "centre" border = "1" > < tr > < td >Session ID</ td > <% session.setAttribute("abc","abc"); %> < td ><%= session.getId() %></ td > </ tr > < tr > < td >Created on</ td > < td ><%= session.getCreationTime() %></ td > </ tr > </ table > </ body > </ html > ``` |
1
2
3
4
5
6
7
8
9
|
``` cpp [root@redis conf]# ps -ef | egrep "[r]edis|[j]ava|[n]ginx" root 5814 1 1 10:34 pts/0 00:00:41 /usr/local/jdk1.7.0_60/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat1/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat1/endorsed -classpath /usr/local/tomcat1/bin/bootstrap.jar:/usr/local/tomcat1/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat1 -Dcatalina.home=/usr/local/tomcat1 -Djava.io.tmpdir=/usr/local/tomcat1/temp org.apache.catalina.startup.Bootstrap start root 5830 1 1 10:35 pts/0 00:00:41 /usr/local/jdk1.7.0_60/jre/bin/java -Djava.util.logging.config.file=/usr/local/tomcat2/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/usr/local/tomcat2/endorsed -classpath /usr/local/tomcat2/bin/bootstrap.jar:/usr/local/tomcat2/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat2 -Dcatalina.home=/usr/local/tomcat2 -Djava.io.tmpdir=/usr/local/tomcat2/temp org.apache.catalina.startup.Bootstrap start redis 5921 1 0 11:07 ? 00:00:02 /usr/sbin/redis-server /etc/redis.conf root 5989 1 0 11:19 ? 00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf nginx 5991 5989 0 11:19 ? 00:00:00 nginx: worker process [root@redis conf]# ``` |
相關文章
- MySQL 5.6同一物理主機配置多例項MySql
- MySQL單機多例項安裝並配置主從複製MySql
- Redis多例項及主從複製環境搭建Redis
- 配置nginx多例項(不同於虛擬主機)Nginx
- 同一Tomcat下不同Web應用之間共享Session會話TomcatWebSession會話
- SpringSession+Redis實現叢集會話共享SpringGseSessionRedis會話
- Tomcat通過自帶的Cluster方式實現Session會話共享環境操作記錄TomcatSession會話
- 採用linux cgroup控制redis主從多例項資源LinuxRedis
- Tomcat多例項單應用部署方案Tomcat
- Mysql實現主從複製(一主雙從)MySql
- flutter 多例項實戰Flutter
- MySQL單機多例項配置MySql
- 一臺伺服器多例項mysql做主從複製伺服器MySql
- VirtualBox中實現與主機檔案的共享
- 使用PostgreSQL_Notify實現多例項快取同步SQL快取
- 快速實現 Tomcat 叢集 Session 共享TomcatSession
- MySQL多主一從的實現MySql
- nginx通過https方式反向代理多例項tomcatNginxHTTPTomcat
- #Tomcat學習(3)#Tomcat多例項配置和反向代理叢集配置Tomcat
- js實現從陣列中取出一個隨機項JS陣列隨機
- MySQL一主一從架構的實現MySql架構
- Android Flutter 多例項實踐AndroidFlutter
- MySQL叢集之 主從複製 主主複製 一主多從 多主一叢 實現方式MySql
- Linux實現MySql資料庫的主從複製(一主一從)LinuxMySql資料庫
- Linux終端會話實時共享(kibitz)Linux會話
- redission-tomcat:快速實現從單機部署到多機部署RedisTomcat
- 利用mysqld_multi配置單機多例項MySql
- Linux下MySQL配置單機多例項LinuxMySql
- Tomcat利用MSM實現Session共享方案解說TomcatSession
- 從動物森友會聊主機遊戲聯機機制遊戲
- mysql多例項部署MySql
- MySQL多例項配置MySql
- 基於mysqld_multi實現MySQL 5.7.24多例項多程式配置MySql
- 單機多例項執行 percona server 5.7Server
- MySQL 5.5.35 單機多例項配置詳解MySql
- 【MySQL】MySQL多例項開機自動重啟MySql
- Shiro+Redis實現tomcat叢集session共享RedisTomcatSession
- 配置tomcat,使得一臺主機執行多個tomcat容器Tomcat