Memcached and Redis Session servers

安装Memcached
[root@nginx ~]# yum -y install libevent memcached
User information such as the size specified, the working environment often designated size is typically 4 to 8G, the test using this information.
[root @ nginx ~] # memcached -u root -m 120M -n 10 -f 2 -d -vvv -c 120
 
Some of the options mean:
-h # view help
-p # specify the port number memcached is listening, 11211 default
user identity using the -l #memcached program is running must be root
-m # specify how much physical memory of the machine access the default data 64M
-c #memcached service maximum number of connections
-vvv # display detailed information about
the minimum space -n #chunk size of the unit is the number of bytes
-f #chunk size increase the size of a multiple of 1.25 times the default
-d # started in the background,
 
Installation for testing a software access a telnet memcached normal
[Nginx the root @ ~] # yum the install telnet -Y

[Nginx the root @ ~] # telnet 192.168.200.111 11211
the Trying 192.168.200.111 ...
<30 new new Auto-Negotiating Connection Client
Connected to 192.168.200.111.
the Escape Character iS '^]'.
SET username. 8 0 0
zhangsan
GET username
...
> 30 the END
of VALUE 0. 8 username
zhangsan
the END
quit
reading the stored name of the test, the operation state of memcached It should be normal
Then create a session folder into which the corresponding jar package into them, and the version of tomcat
Then restart the tomcat service, then test access. If you refresh the Tomcat server change occurs, sessionID does not change is successful Redis Session servers difference of Redis and Memcached














* Memory utilization: simply use the key-value (key-value pairs) are stored, then Memcached higher memory utilization, if employed Redis do hash key-value store configuration, due to its modular compression, which use the memory rate will be higher than Memcached.
* Performance Comparison: Since only Redis mononuclear, polynuclear and may be used Memcached, the average Redis on each of the cores is higher than Memcached performance when small data storage. In the above 100k data, Memcached performance than Redis, although Redis also recently optimize storage performance on large data, but compared to Memcached, or slightly less.
* Redis supports data persistence, data in memory can be kept on disk, restart time can be used again to load
* Redis supports backup data, namely data backup master-slave mode.
* Redis not only support simple key-Value type data, while also providing a storage list, set, zset, hash data structure like
mounting deployment Redis
[the root @ node1 ~] # XF Redis the tar-3.2.5.tar.gz -C / usr / the src /
[the root @ node1 ~] # CD /usr/src/redis-3.2.5/
[@ node1 the root-Redis 3.2.5] # the make
// If this error: tclsh8.5: not found found less tcl error, then install tcl
wget http://downloads.sourceforge.net/tcl/tcl8.5.9-src.tar.gz
cd /tcl8.5.9-src/unix
./configure
make && make the install //
then make no being given
[@ node1 the root-Redis 3.2.5] # mkdir -p / usr / local / Redis / {bin, etc, var}
[@ node1 the root-Redis 3.2 .5] # cd src /
these documents the role of the src directory as follows
* redis-server: daemon launcher Redis server
* redis-cli: Redis command line tool you can use telnet to operate in accordance with its plain-text protocol.
* Redis -benchmark: read and write performance Redis performance testing tools, test Redis in your system and a configuration of your
* redis-stat: Redis state detecting means may detect a current state parameter and delay Redis health
[root @ node1 src] # cp Benchmark-Check-Redis Redis-AOF-Redis Redis-CLI Server / usr / local / Redis / bin /
[@ node1 the root-Redis 3.2.5] CP # ../redis.conf / usr / local / Redis / etc
[ root @ node1 redis-3.2.5] # vim /usr/local/redis/etc/redis.conf // modify the configuration file
daemonize no change daemonize yes // whether to start redis-server in the background, the default is "No" . If changed to yes, generates a pid file
bind 127.0.0.1 instead bind 0.0.0.0 // host can access any
other point of view need to be modified
to close Redis:
[root @ node1 Redis-3.2.5] # killall -9 Redis-Server
start Redis:
[root @ node1 Redis -3.2.5] # / usr / local / redis / bin / redis-server /usr/local/redis/etc/redis.conf
see if the start:
[root @ node1 Redis-3.2.5] # netstat -anpt | grep Redis
TCP 0 0 77 526 0.0.0.0:6379 0.0.0.0:* the LISTEN / Redis-Server 
Monitoring redis share the session:
[root @ node1 redis-3.2.5] # / usr / local / redis / bin / redis-cli -p 6379 Monitor
1555299973.187326 [0 192.168.200.113:44980] "EXPIRE" "29C6E0F087C504F4C90BBEAE924F20DD" "1800"
......
the tomcat need to call redis jar package into tomcat / lib
[root @ node1 redis-3.2.5] # cp-tomcat-redis the Manage-tomcat7.jar the session-tomcat-juli.jar Commons-logging -1.1.3.jar commons-pool2-2.2.jar jedis-2.5.2.jar / usr / local / tomcat / lib
modified context.xml file to support calling Redis
[root @ node1 Redis-3.2.5] # vim / usr / local / tomcat / conf / context.xml
added in the following paragraph Context
<Context>
<Valve className = "com.orangefunction.tomcat.redissessions.RedisSessionHandlerValve" />
  <Manager className = "com.orangefunction.tomcat.  redissessions.RedisSessionManager" 
host = "192.168.200.112" // IP address of the redis
port = "6379" // Port of redis
Database = "0" 
maxInactiveInterval = "60" />
</ the Context>
restart tomcat Service
[root @ node1 ~] # / usr / local / Tomcat / bin / the shutdown.sh
[the root @ node1 ~] # /usr/local/tomcat/bin/startup.sh
 

Guess you like

Origin www.cnblogs.com/chenxi123/p/11627198.html