配置自启动:
如果配置成自启动,那相关的权限会变成root权限,请慎重考虑。下面给出自启动的脚本,仅供参考。
在/etc/init.d下编写脚本redis6379,并给+x权限,然后配置启动级别
chkconfig --add redis6379
chkconfig --level 345 redis6379 on
脚本如下:
cat /etc/init.d/redis6379 
#!/bin/bash 
#chkconfig:345 61 61 
  
PATH=/usr/local/bin:/sbin:/usr/bin:/bin  
       
REDISPORT=6379   
EXEC=/usr/local/bin/redis-server  
REDIS_CLI=/usr/local/bin/redis-cli  
       
PIDFILE=/usr/local/webapp/redis6379/redis_6379.pid  
CONF="/usr/local/webapp/redis6379/redis-6379.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  
        if [ "$?"="0" ]    
        then  
              echo "Redis is running..."  
        fi  
        ;;   
    stop)   
        if [ ! -f $PIDFILE ]   
        then  
                echo "$PIDFILE does not exist, process is not running"  
        else  
                PID=$(cat $PIDFILE)   
                echo "Stopping ..."  
                $REDIS_CLI -p $REDISPORT SHUTDOWN   
                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   
        exit 1   
esac  
##############################
redis的配置文件如下:
bind 172.16.25.220 
protected-mode yes
port 6379 
cluster-enabled yes
cluster-config-file nodes.conf 
cluster-node-timeout 5000 
tcp-backlog 511 
timeout 0 
tcp-keepalive 300 
daemonize yes
supervised no 
pidfile /usr/local/webapp/redis6379/redis_6379.pid 
loglevel notice 
logfile /usr/local/webapp/redis6379/redis_6379.log 
databases 16 
save 900 1 
save 300 10 
save 60 10000 
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb 
dir /usr/local/webapp/redis6379
slave-serve-stale-data yes
slave-read-only yes
repl-diskless-sync no 
repl-diskless-sync-delay 5 
repl-disable-tcp-nodelay no 
slave-priority 100 
appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec 
no-appendfsync-on-rewrite no 
auto-aof-rewrite-percentage 100 
auto-aof-rewrite-min-size 64mb 
aof-load-truncated yes
lua-time-limit 5000 
slowlog-log-slower-than 10000 
slowlog-max-len 128 
latency-monitor-threshold 0 
notify-keyspace-events ""
hash-max-ziplist-entries 512 
hash-max-ziplist-value 64 
list-max-ziplist-size -2 
list-compress-depth 0 
set-max-intset-entries 512 
zset-max-ziplist-entries 128 
zset-max-ziplist-value 64 
hll-sparse-max-bytes 3000 
activerehashing yes
client-output-buffer-limit normal 0 0 0 
client-output-buffer-limit slave 256mb 64mb 60 
client-output-buffer-limit pubsub 32mb 8mb 60 
hz 10 
aof-rewrite-incremental-fsync yes
requirepass "mypasswd"
masterauth "mypasswd"
下面关于Redis的文章您也可能喜欢,不妨参考下:

