CentOS 6.5 installation Redis-2.8.23
Installation environment:
CentOS 1, 6.5
Redisredis-2.8.23
Download and install:
1. Switch to the/usr/local/src/directory:
[Root @ node2 ~] # Cd/usr/local/src
Download the source code package:
[Root @ node2 src] # wgethttp: // download. redis. io/releases/redis-2.8.23.tar.gz
2. decompress the package:
[Root @ node2 src] # tar xf redis-2.8.23.tar.gz
3, switch to the redis-2.8.23 directory:
[Root @ node2 src] # cd redis-2.8.23
4. Install redis to the/usr/local/redis directory:
[Root @ node2 redis-2.8.23] # make PREFIX =/usr/local/redis install
5. Provide the SysV init script for redis:
[Root @ node2 redis-2.8.23] # vim/etc/rc. d/init. d/redis
#! /Bin/sh
# Chkconfig: 2345 83 93
# Simple Redis init. d script conceived to work on Linux systems
# As it does use of the/proc filesystem.
#
# 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. pid
CONF = "/etc/redis. conf"
Case "$1" 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 is 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
6. Grant the execution permission to the script:
[Root @ node2 redis-2.8.23] # chmod u + x/etc/rc. d/init. d/redis
7. Add it to the Service Management list and enable it to automatically start upon startup:
[Root @ node2 redis-2.8.23] # chkconfig -- add/etc/rc. d/init. d/redis
[Root @ node2 redis-2.8.23] # chkconfig redis on
8. Create a directory for storing redis persistent files
Mkdir-pv/var/redis/data
9. Create a directory for storing configuration files
[Root @ node2 redis-2.8.23] # mkdir/etc/redis
10. Provide configuration files
[Root @ node2 redis-2.8.23] # cp/usr/local/src/redis-2.8.23/redis. conf/etc/redis/
11. Edit the configuration file to change the following options:
[Root @ node2 redis-2.8.23] # vim/etc/redis. conf
Daemonize yes # Run Redis in daemon mode
Dir/var/redis/data # Set the storage location of persistent files. The path can be customized.
12. Start the service
[Root @ node2 redis-2.8.23] # service redis start
13. Check the service port
[Root @ node2 redis-2.8.23] # netstat-tunl | grep 6379
Tcp 0 0 0.0.0.0: 6379 0.0.0.0: * LISTEN
14. Modify the PATH environment variable so that the system can directly use redis commands:
[Root @ node2 ~] # Echo 'export PATH =/usr/local/redis/bin: $ path'>/etc/profile. d/redis. sh
[Root @ node2 ~] # Source/etc/profile. d/redis. sh
15. Use the redis client tool to connect to redis for testing:
[Root @ node2 ~] # Redis-cli
127.0.0.1: 6379> set hello world
OK
Wagner. 0.0.1: 6379>
127.0.0.1: 6379> get hello
"World"
127.0.0.1: 6379> quit
[Root @ node2 ~] #
By now, the installation and testing of Redis have been completed.