## download wget https://download.redis.io/releases/redis-6.2.5.tar.gz tar -xzvf redis-6.2.5.tar.gz -C /usr/local cd /usr/local mv redis-4.0.11 redis cd redis make make PREFIX=/usr/local/redis installenv path
在/etc/profile文件尾部增加redis环境变量,并执行 export REDIS_HOME=/usr/local/redis export PATH=$PATH:$REDIS_HOME/src 最后执行source /etc/profile使之生效
masterauth mypwd requirepass mypwd protected-mode yes bind 192.168.5.116 #局域网ip或者外网ip daemonize yes logfile /codeyuguo/redis/redis.log appendonly yes dir /codeyuguo/redis
sentinel monitor mymaster 192.168.5.116 6379 1 sentinel auth-pass mymaster mypwd sentinel down-after-milliseconds mymaster 15000 sentinel parallel-syncs mymaster 1 sentinel failover-timeout mymaster 80000 bind 192.168.5.116 protected-mode yes daemonize yes logfile /codeyuguo/redis/sentinel.log appendonly yes dir /codeyuguo/redis
masterauth mypwd requirepass mypwd protected-mode yes bind 192.168.6.49 slaveof 192.168.5.116 6379 daemonize yes logfile /codeyuguo/redis/redis.log
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
source /etc/init.d/functions
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/alidata/redis-6.2.5/redis.conf"
AUTH="Jh****"
BIND_IP=‘192.168.5.116‘
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 ..."
$CLIEXEC -h $BIND_IP -a $AUTH -p $REDISPORT SHUTDOWN 2>/dev/null
sleep 1
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
}
restart(){
stop
start
}
status(){
ps -ef|grep redis-server|grep -v grep >/dev/null 2>&1
if [ $? -eq 0 ];then
echo "redis server is running"
else
echo "redis server is stopped"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|status|start}" >&2
exit 1
esac
原文:https://www.cnblogs.com/lkj371/p/15193840.html