It is advantageous to use the redis server to store sessions. First, it is a nosql data, and second, it is easy to expand and use.
The following installation method clearly guides you to use redis cache as a session storage system. The procedure is as follows:
1. Download redis and use the following command to compile and install it:
wget http://download.redis.io/redis-stable.tar.gz tar xvzf redis-stable.tar.gz cd redis-stable make
2. Run the following command to start redis:
cd RedisDirectory/src./redis-server --port 6379
3. download the latest Tomcat 7. download the latest Jedis (A redis Java client), Tomcat redis Session Manager and Apache commons pool 5. copy all the jar packages above to the lib directory under the Tomcat 7 installation directory 6. in the conf/context. add the following content to the XML file (or in the server. add in the context block of XML ):
<Valve classname = "com. radiadesign. Catalina. session. redissessionhandlervalve"/> <manager classname = "com. radiadesign. Catalina. session. redissessionmanager" host = "localhost" <! -- Optional. The default value is "localhost" --> Port = "6379" <! -- Optional. The default value is "6379" --> database = "0" <! -- Optional. The default value is "0" --> maxinactiveinterval = "60" <! -- Optional; default value: 60 (unit: seconds) -->/>
7. Restart Tomcat 7. Now you can see that the session content is created in redis.
Now, the session of Tomcat 7 is saved to redis, and it also maintains different aspects of the session.
Components:
Redis:http://redis.io/JRedis: https://github.com/xetorthio/jedisTomcat Redis Session Manager :https://github.com/jcoleman/tomcat-redis-session-manager/downloadsApache Commons Pool :http://commons.apache.org/proper/commons-pool/download_pool.cgi
Apsaradb for redis is used to save the session on tomat7.