One, install Redis on Linux
1) Install a single instance of Redis
Two, environment preparation
1) Installing Redis requires make, so you need to install the content
Yum Install GCC
Yum Install gcc-c++
Yum Install wget
Yum Install vim
third, download Redis
1)wget http://download.redis.io/releases/redis-2.8.17.tar.gz
2) tar xzf redis-2.8. 17.tar. GZ
3) MV to your software placement location for example: Usr/local/redis
Four, make
1) Enter the extracted file
2) Run make
3) After make is finished, you can see the SRC folder appears in the directory.
4) CP redis.conf SRC Copy one copies to SRC for starting Redis
5) Enter SRC, vim redis.conf Modify Configuration
6) Turn on sprite process
Five, start
1) Enter in the SCR directory to start the service
./redis-server redis.conf--raw
2) Enter in SCR directory, connect Redis
./REDIS-CLI--raw
3) Ping test service starts normally
Six, the external network needs to access, need to open 6379 ports
1) vi/etc/sysconfig/iptables
2) yy P I shift+: Wq
Seven, MAVEN project integration
1) Reliance
<!--Redis Client - <Dependency> <groupId>Redis.clients</groupId> <Artifactid>Jedis</Artifactid> <version>2.7.2</version> </Dependency>
2) configuration file
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/beans"Xmlns:context= "Http://www.springframework.org/schema/context"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd " > <!--Connection Pool Configuration - <BeanID= "Jedispoolconfig"class= "Redis.clients.jedis.JedisPoolConfig"> <!--Maximum number of connections - < Propertyname= "Maxtotal"value= "+" /> <!--Maximum number of idle connections - < Propertyname= "Maxidle"value= "Ten" /> <!--maximum number of connections per release - < Propertyname= "Numtestsperevictionrun"value= "5" /> <!--scan interval for free connections (MS) - < Propertyname= "Timebetweenevictionrunsmillis"value= "30000" /> <!--Connect minimum idle time - < Propertyname= "Minevictableidletimemillis"value= "1800000" /> <!--How long the connection is free and released when idle time > This value and free connections > maximum idle connections are released directly - < Propertyname= "Softminevictableidletimemillis"value= "10000" /> <!--maximum wait milliseconds to get a connection, less than 0: blocking indeterminate time, default-1 - < Propertyname= "Maxwaitmillis"value= " the" /> <!--check validity when getting a connection, default false - < Propertyname= "Testonborrow"value= "true" /> <!--check validity on idle, default false - < Propertyname= "Testwhileidle"value= "true" /> <!--If the connection is exhausted, false to report an exception, ture block until timeout, default true - < Propertyname= "blockwhenexhausted"value= "false" /> </Bean> <!--Jedis Client Stand-alone version - <BeanID= "Redisclient"class= "Redis.clients.jedis.JedisPool"> <Constructor-argname= "Host"value= "47.93.27.**"></Constructor-arg> <Constructor-argname= "Port"value= "6379"></Constructor-arg> <Constructor-argname= "Poolconfig"ref= "Jedispoolconfig"></Constructor-arg> </Bean></Beans>
3) Testing
@Autowired private jedispool Jedispool; @RequestMapping ("Tesrredis") public Void Set () { Jedis Jedis = Jedispool.getresource (); String string = Jedis.set ("User2", "Zhang Three"); Jedis.close (); System.out.println (string); }
Installing Redis on Linux