1. Preparation Middleware: Tomcat, Redis, Nginx Jar package: commons-pool2-2.4.2.jar, jedis-2.8.0.jar, tomcat-redis-session-manager-2.0.0.jar 2. Configure Tomcat Multiple Tomacats need to be configured with different port numbers /lib Store the jar package in this location /conf/server.xml
/conf/context.xml
host is the IP address of Redis, port is the port, and database is the database. Nginx /conf/nginx.conf
Upstream means the configuration server list. In this example, two tomcats are started, with ports 8080 and 9999 respectively. proxy_pass means to configure the proxy server. This configuration means listening to port 80 of the local (192.168.0.113) and forwarding requests to the Tomcat servers at 8080 and 9999 in a round-robin manner. Redis Redis does not require any special configuration, just start it. 3. Testing Start the Redis service, two tomcat servers, and the Nginx server one after another. Add a mark to the Tomcat startup page to check whether the sessionIds in the two servers are consistent. /webapps/ROOT/index.jsp:
IV. Results
If you cannot switch to the page corresponding to the port by pressing F5 to refresh the page, it may be due to the browser cache. Solution: Clear cache and refresh, alt+F5 At this point, you can see that multiple tomcat services are constantly polling, and the sessionId is consistent. Then use the Redis desktop management tool to view the information:
You can see that the session information has been handed over to Redis for management. Achieve success. 5. Disadvantages This method depends on the Tomcat container. If the middleware is replaced with Jetty or other, it will not work. There is also a better implementation method: Spring Session + Redis The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: MySQL uses aggregate functions to query a single table
>>: Detailed explanation of the use cases of Vue listeners
Today, this article has collected 30 excellent cas...
Table of contents 1. Basics 2. Problem Descriptio...
binlog is a binary log file that records all DML ...
Grammatical rules SELECT column_name(s) FROM tabl...
Table of contents After creating a container loca...
<br />Hello everyone! It’s my honor to chat ...
Table of contents Preface 1. Download a single fi...
Table of contents 1. Browser support 2. export ex...
background As the number of application systems c...
The img tag in XHTML is so-called self-closing, w...
How to solve the problem of being unable to acces...
If your computer is a Mac, using homebrew to inst...
Using padding-top percentage can achieve a fixed ...
1. Usage of instanceof instanceof operator is use...
Today, there is such a requirement. If the logged...