/etc/redis_6379.conf 文件配置
port 6379
daemonize yes
dir "/data/redis/6379/"
logfile "6379.log"
dbfilename "dump-6379.rdb"
启动redis
redis-server /etc/redis_6379.conf &
或者使用 /etc/init.d 的方式,创建下面文件
#/bin/sh
#Configurations injected by install_server below....
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/etc/redis_6379.conf"
REDISPORT="6379"
#password="chengce243"
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 -a $password -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
status)
if [ ! -f $PIDFILE ]
then
echo 'Redis is not running'
else
echo "Redis is running ($(<$PIDFILE))"
fi
;;
restart)
$0 stop
$0 start
;;
*)
echo "Please use start, stop, restart or status as first argument"
;;
esac
关闭redis
redis-cli -p 6379 shutdown
或者
/etc/init.d/redis_6379 stop