In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you how to achieve redission-tomcat from stand-alone deployment to multi-machine deployment, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Brief introduction
Redisson is a redis client similar to jedis, and its features are a little richer than jedis. Redission-tomcat is a redis-based tomcat session Manager project, project address. Compared with other implementations, the storage of this project is more efficient and the write operation is more optimized. Each session parameter is written to redis when HttpSession.setAttribute is called, while other scenarios generally write the entire session after serialization each time.
Use
1. Download two jar packages of redisson-all-3.11.0.jar,redisson-tomcat-8-3.11.0.jar (for tomcat8, other versions can be found on the above project address page) and put them in tomcat's lib directory.
two。 Add the following configuration to the context.xml file in the tomcat conf directory
Among them
ConfigPath: point to Redisson's configuration file in json or yaml format, given in step 3.
The read mode of the readMode:session property. Take a value of 1. MEMORY, which saves the session attribute to both the local tomcat session and the redis, and subsequent session updates are propagated to the local tomcat session;2. REDIS through the redis event, saving only the session attribute to the redis. The default is REDIS.
The update mode for the updateMode:session property. Available values: 1. The DEFAULT,session attribute is saved to redis only through the setAttribute method; 2. AFTER_REQUEST, after each request, save all session attributes to redis. The default is DEFAULT.
BroadcastSessionEvents: if set to true, the sessionCreated and sessionDestroyed events will be broadcast to all tomcat instances and all registered HttpSessionListeners listeners will be triggered. The default is false.
3. Add a new configuration file redisson.conf under the tomcat conf directory, as follows
{"singleServerConfig": {"idleConnectionTimeout": 10000, "connectTimeout": 10000, "timeout": 3000, "retryAttempts": 3, "retryInterval": 1500, "password": "123456", "subscriptionsPerConnection": 5, "clientName": null, "address": "redis://127.0.0.1:6379", "subscriptionConnectionMinimumIdleSize": 1, "subscriptionConnectionPoolSize": 50, "connectionMinimumIdleSize": 24, "connectionPoolSize": 64, "database": 0, "dnsMonitoringInterval": 5000}, "threads": 16, "nettyThreads": 32 "codec": {"class": "org.redisson.codec.FstCodec"}, "transportMode": "NIO"}
The above is the configuration of the stand-alone mode redis environment, where password,address is modified to its own value. If it is in cluster mode, the configuration file is
{"sentinelServersConfig": {"idleConnectionTimeout": 10000, "connectTimeout": 10000, "timeout": 3000, "retryAttempts": 3, "retryInterval": 1500, "failedSlaveReconnectionInterval": 3000, "failedSlaveCheckInterval": 60000, "password": null, "subscriptionsPerConnection": 5, "clientName": null, "loadBalancer": {"class": "org.redisson.connection.balancer.RoundRobinLoadBalancer"}, "subscriptionConnectionMinimumIdleSize": 1, "subscriptionConnectionPoolSize": 50, "slaveConnectionMinimumIdleSize": 24, "slaveConnectionPoolSize": 64, "masterConnectionMinimumIdleSize": 24, "masterConnectionPoolSize": 64, "readMode": "SLAVE" SubscriptionMode: "SLAVE", "sentinelAddresses": ["redis://127.0.0.1:26379", "redis://127.0.0.1:26389"], "masterName": "mymaster", "database": 0}, "threads": 16, "nettyThreads": 32, "codec": {"class": "org.redisson.codec.FstCodec"}, "transportMode": "NIO"}
We can use nginx to achieve load balancing, refer to the configuration
Upstream cnserver {server 127.0.0.1 weight=2 fail_timeout=10s max_fails=1;server 127.0.0.1 weight=2 fail_timeout=10s max_fails=1;} server {listen 8010 serveraccounname localhost;index index.html index.htm;location / rest/ {index index.html;proxy_pass http://cnserver/rest/;}}
These are all the contents of the article "how to deploy redission-tomcat from a single machine to a multi-machine deployment". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.