I. Installing Redis to/usr/local/redis
Execute command:
1. Mkdir/usr/local/redis
2. Cd/usr/local/src
3. wget http://download.redis.io/releases/redis-3.2.4.tar.gz
4. Tar-xzf redis-2.6.14.tar.gz
5. Ln-s redis-2.6.14 Redis #建立一个链接
6. CD Redis
7. Make Prefix=/usr/local/redis Install #安装到指定目录中
* After installing Redis successfully, you will be able to see a bin directory in/usr/local/redis, which includes the following files:
# Redis-benchmark redis-check-aof redis-check-dump redis-cli redis-server
Two. Make Redis a service
Copy script to/etc/rc.d/init.d directory
PS: The script in the/etc/rc.d/init.d/directory is similar to the registry in Windows, and some of the specified scripts will be executed when the system is started.
When you install Redis as per the above steps, its service script is located at:
/usr/local/src/redis/utils/redis_init_script
It must be copied to the/ETC/RC.D/INIT.D directory:
Cp/usr/local/src/redis/utils/redis_init_script/etc/rc.d/init.d/redis
Copy the Redis_init_script to/etc/rc.d/init.d/and easily name Redis.
If you add a registration service at this point:
Chkconfig--add Redis
The following error will be reported:
Redis service does not support Chkconfig (Redis scripts need to be changed)
To change the Redis script, open the script using VI to view the script information:
- Vim/etc/rc.d/init.d/redis
- What you see is as follows (the following is a change of good information):
- #!/bin/sh
- #chkconfig: 2345 80 90
- # simple Redis INIT.D script conceived to work on Linux systems
- # as it does use of the/proc filesystem.
- redisport=6379
- Exec=/usr/local/redis/bin/redis-server
- Cliexec=/usr/local/redis/bin/redis-cli
- Pidfile=/var/run/redis_${redisport}.pid
- conf= "/etc/redis/${redisport}.conf"
- Case "$" in
- Start
- If [-F $PIDFILE]
- Then
- echo "$PIDFILE exists, process is already running or crashed"
- Else
- echo "Starting Redis server ..."
- $EXEC $CONF &
- Fi
- ;;
- Stop
- if [!-F $PIDFILE]
- Then
- echo "$PIDFILE does not exist, process was not running"
- Else
- pid=$ (Cat $PIDFILE)
- echo "Stopping ..."
- $CLIEXEC-P $REDISPORT shutdown
- While [-x/proc/${pid}]
- Do
- echo "Waiting for Redis to shutdown ..."
- Sleep 1
- Done
- echo "Redis stopped"
- Fi
- ;;
- *)
- echo "Please use Start or stop as first argument"
- ;;
- Esac
3. Copy the Redis configuration file to/etc/redis/${redisport}.conf
Mkdir/etc/redis
Cp/usr/local/src/redis/redis.conf/etc/redis/6379.conf
In this way, the conf specified by the Redis service script exists. By default, Redis does not have authentication enabled, and you can specify a verification password by turning on the requirepass of 6379.conf.
After the above operation is complete, you can register Yedis service: Chkconfig--add Redis
Start Redis Services: Service Redis start
4. Add the directory of the Redis command to the system parameter path
Modify Profile: Vi/etc/profile
Append in last line: Export path= "$PATH:/usr/local/redis/bin"
Then apply this file immediately:. /etc/profile
This makes it possible to invoke the REDIS-CLI command directly, as follows:
$ redis-cli
Redis 127.0.0.1:6379> Auth Superman
OK
This article is from the "7059211" blog, please be sure to keep this source http://7069211.blog.51cto.com/7059211/1864897
Installing Redis services under Linux