The previous company in the development phase of the Redis has been the formal environment, the recent boss let me in a local area network for the development phase of the Redis connection use, build process also encountered some problems, fortunately has been solved, recorded here.
The first is to build Redis, this is relatively simple.
1, check the installation of dependent programs
Yum install gcc-c++
yum install-y tcl Yum install
2. Get installation files
wget http://download.redis.io/releases/
There are many versions, you choose the download you need
3, Extract files
Create a new directory of your own to extract redis into the inside
TAR-ZXVF redis-3.2.01.tar.gz
MV Redis-3.2.01/usr/local/redis
4, enter the catalogue
Cd/usr/local/redis
5. Compile and install
Make make
Install
6, set the configuration file path
Mkdir-p/etc/redis
CP Redis.conf/etc/redis
7, modify the configuration file
Redis.conf is the Redis configuration file, redis.conf in the Redis source directory.
Notice that the port is modified as the ports of the Redis process, with port default 6379. If you need to build a redis cluster, don't forget to modify the port number.
Redis There are two ways to start, the direct run Bin/redis-server will start in front mode, front-end mode startup is the disadvantage of the SSH command window is closed then the Redis-server program end, it is not recommended to use this method. The following figure:
Back-end mode startup
Modify the redis.conf configuration file, daemonize Yes to start after the end mode. recommended.
Open redis.conf and use the command:/daemonize to quickly find daemonize and then modify it.
Vi/etc/redis/redis.conf
modified only: daemonize Yes (No-->yes)
8, start
/usr/local/bin/redis-server/etc/redis/redis.conf
9. View Startup
Ps-ef | grep Redis
10, using the client
REDIS-CLI
>set name David
OK
>get name
"David"
11. Close the Client
REDIS-CLI shutdown
12, Boot Configuration
echo "/usr/local/bin/redis-server/etc/redis/redis.conf &" >>/etc/rc.local
Boot to be configured in the rc.local, and/etc/profile files, to have a user logged in, will be executed.
13, set the password
Because this is for many people in the local area network, it is necessary to set an access password.
Modify redis.conf File Configuration
Use the command:/Requirepass quickly find the # Requirepass foobared and then remove the comment, which is changed to its own password. Then Wq save.
14, restart Redis
sudo service Redis Restart this time to try to login Redis, found can be boarded, but the implementation of the specific command is prompted to operate does not allow Redis-cli-h 127.0.0.1-p 6379 Redis 127.0.0.1:6379> ; Redis 127.0.0.1:6379> Keys * (Error) ERR operation not permitted
Try to log in with a password and perform a specific command to see the successful execution of redis-cli-h 127.0.0.1-p 6379-a password Redis 127.0.0.1:6379> keys * 1) "MySet" 2) "Mysort Set "Redis 127.0.0.1:6379> Select 1 OK
If the use of their own on this machine is now available, because I this is the LAN provided for everyone to use, so also need the final configuration.
After modifying the developed configuration file, the startup Project complains.
Org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is redis.clients.jedis.exceptions.JedisConnectionException:could not get a resource from the pool
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:162) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:251) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:58) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection (redisconnectionutils.java:128) ~[ Spring-data-redis-1.5.0.release.jar:1.5.0.release]
Open cmd and then use the Telnet IP port to ping the configured Redis (to ensure that the Redis is started), you will not be able to ping it.
This is because there is a configuration in the redis.conf bind 127.0.0.1 This is the default only native access, this comment out of the good, note later view the Redis process becomes the following:
[Root@localhost redis]# Ps-ef | grep Redis
Root 5655 1 0 11:40? 00:00:23 ./redis-server *:6379
Root 21184 18040 0 17:33 pts/1 00:00:00 grep--color=auto Redis
This * number means that other users are allowed to access it. Then you can ping it by using the Telnet IP port of cmd, which opens the computer.