yum install gcc tcl
tar -zvxf redis-3.2.8.tar.gz
make PREFIX=/usr/local/redis/redis install MALLOC=libc
#將原有的綁定到127.0.0.1註釋掉換成ip地址,否則遠程沒法鏈接 #bind 127.0.0.1 bind 192.168.213.210
./redis-server 6379.conf
複製「/usr/local/redis/redis-3.2.8/utils」目錄下的「redis_init_script 」文件到「/usr/local/redis/redis/bin」目錄下,並命名爲redis 修改文件內容以下redis
#!/bin/sh # # 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/redis/bin/redis-server CLIEXEC=/usr/local/redis/redis/bin/redis-cli PIDFILE=/var/run/redis_${REDISPORT}.pid CONF="/usr/local/redis/redis/bin/${REDISPORT}.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
daemonize yes
#設置權限 chmod 755 redis #設置開機啓動 #修改/etc/下的rc.local添加以下命令 su - root -c '/usr/local/redis/redis/bin/redis start'