Installation configuration
# install
yum install Epel-release (CentOS 7 can directly install Epel source)
Yum install Redis
# configuration
vi/etc/redis.conf
VI/ etc/redis-sentinel.conf
# start
redis-server/etc/redis.conf
redis-sentinel/etc/redis-sentinel.conf
redis.conf Common Settings
# bind 127.0.0.1
protected-mode no
port 6379
daemonize Yes
maxclients 10000 Requirepass
< password>
appendonly Yes
# slaveof and Masterauth only set
slaveof <masterip> <masterport> from node
Masterauth <master-password>
redis-sentinel.conf Common Settings
Protected-mode no
daemonize Yes
port 26397
Sentinel Monitor <master-name> <ip> < redis-port> <quorum>
Sentinel Auth-pass <master-name> <password>
Power-on Self-starter
# edit
VI/ETC/INIT.D/REDISD
# empower
chmod 755/ETC/INIT.D/REDISD
# try
/ETC/INIT.D/REDISD start
Service REDISD Start/stop/restart
# self-starter
chkconfig REDISD on
REDISD sample
#!/bin/sh # chkconfig:2345 Description:redis is a persistent key-value database # simple Redis INIT.D Script Co
Nceived to work on Linux systems # as it does the use of The/proc filesystem. redisport=6379 redispwd= ' 123456 ' exec=/usr/local/bin/redis-server cliexec=/usr/local/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 "Sta
Rting Redis server ... "$EXEC $CONF fi;;
STOP) if [! f $PIDFILE] then echo "$PIDFILE does not exist, process isn't running" Else pid=$ (cat $PIDFILE) echo "Stopping ..." $CLIEXEC-P $REDISPORT- A $REDISPWD shutdown while [-x/proc/${pid}] doing echo waiting for Re DiS to shutdown ... "Sleep 1 done echo" Redis stopped "fi
;;
restart|force-reload) ${0} stop ${0} start;;
*) echo "Please use start|stop|restart|force-reload as a argument";; Esac
Redis-sentineld sample
#!/bin/sh # chkconfig:2345 Description:redis Sentinel redisport=26379 exec=/usr/bin/redis-sentinel CLIEXEC=/us R/BIN/REDIS-CLI conf= "/etc/redis-sentinel.conf" name= "Redis Sentinel" pid=$ (netstat-lnopt | grep: $REDISPORT | awk '/re Dis-sentine/{gsub (/\/redis-sentine/, "", $);p rint $;} ' |
HEAD-1) Case "in Start" if [-Z ${pid}] then echo "Starting $NAME server ..."
$EXEC $CONF echo "start at Port: $REDISPORT" Else echo "$NAME server already start,pid: $PID"
fi;;
Stop) if [-Z ${pid}] then echo "not find $NAME server on port: $REDISPORT" Else
echo "Stopping ..." $CLIEXEC-p $REDISPORT shutdown while [-Z ${pid}]
Do echo ' Waiting for $NAME server to shutdown ... ' Sleep 1 done echo "$NAME server Stopped" FI;;
status if [-Z ${pid}] then echo "not find $NAME server on port: $REDISPORT" Else
echo "$NAME server is running,pid: $PID" FI;;
Restart) ${0} stop ${0} start;;
*) echo "Please use start|stop|restart|status as a argument";; Esac