1. Put the downloaded compressed package into the/usr/local directory
# tar Xzf redis-3.0.2.tar.gz
# cd redis-3.0.2
# Make
Prompt error Make:cc:Command not found make: * * * [ADLIST.O] Error 127
GCC is not installed, you need to install GCC
# yum Install gcc
Check if installation is successful after installation
# RPM-QA |grep gcc
And then make it again.
2. After compiling, in the SRC directory, there are four executable files Redis-server, Redis-benchmark, REDIS-CLI, and redis.conf copy them to a directory.
# Mkdir/usr/redis
# cp redis-server /usr/redis
# cp Redis-benchmark/usr/redis
# CP redis-cli/ usr /redis
# cp redis.conf /usr/redis
# Cd/usr/redis
3. Start Service
# Redis-server redis.conf
Prompt error-bash:redis-server:command not found
Establish a soft connection
# ln-s/usr/redis/redis-server/usr/bin/redis-server
# ln-s/USR/REDIS/REDIS-CLI/USR/BIN/REDIS-CLI
Reboot
# redis-server/usr/redis/redis.conf
Start successful
4. Set power-on self-starter
(1) Set the redis.conf daemonize to Yes to ensure that the daemon is turned on.
(2) write the boot from the start script
# Vi/etc/init.d/redis
Path=/usr/local/bin:/sbin:/usr/bin:/bin redisport=6379 Exec=/usr/redis/redis-server REDIS_CLI=/USR/REDIS/REDIS-CL
I pidfile=/var/run/redis.pid conf= "/usr/redis/redis.conf" auth= "1234" case "$" in start) If [f $PIDFILE] then echo $PIDFILE exists, process is already
Running or crashed. "
else echo "Starting Redis server ..." $EXEC $CONF fi If ["$?"
= "0"] then echo "Redis is running ..." fi
;; STOP) if [!-F $PIDFILE] then echo "$PIDFILE exists, PR
Ocess is not running. "
Else pid=$ (cat $PIDFILE) echo "Stopping ..." $REDIS _cli-p $REDISPORT SHUTDOWN sleep 2 While [-X $PIDFILE]
Do echo ' Waiting for Redis to shutdown ... ' sleep 1
Done echo "Redis stopped" FI;
restart|force-reload) ${0} stop ${0} start;; *) echo "Usage:/etc/init.d/redis {start|stop|restart|force-reload}" >&2 Exi T 1 Esac
Note: Redis set auth command
Redis 127.0.0.1:6379> AUTH PASSWORD
(Error) ERR Client sent AUTH, but no PASSWORD is set
Redis 127.0.0.1:6379&G T CONFIG SET requirepass "1234"
OK
redis 127.0.0.1:6379> AUTH 1234
OK
(3) Set permissions
# chmod 755 Redis
(4) Start
#/etc/init.d/redis Start
Prompt error/etc/init.d/redis:permission denied
# chmod A+x/etc/init.d/redis
A+x is to add executable permissions to everyone, including owners, groups, and others
o+x just add executable permissions to other people
Display after reboot
Redis is running ...
(5) Set up the boot from start
# Chkconfig Redis on
Prompt for error service Redis does not support Chkconfig
Put the following two lines of comments in the front of the/etc/init.d/redis file:
# chkconfig:2345 90 10
# Description:redis is a persistent key-value database
(6) Shutdown restart test