1.将下载好的压缩包放到/usr/local目录下 提示错误 make: cc: Command not found make: *** [adlist.o] Error 127
# yum install gcc
# rpm -qa |grep gcc
# mkdir /usr/redis # cp redis-server /usr/redis # cp redis-benchmark /usr/redis # cp redis-cli /usr/redis # cp redis.conf /usr/redis # cd /usr/redis # ./redis-server redis.conf
启动成功 4.设置开机自启动 (1)先将redis.conf中daemonize设置为yes,确保守护进程开启。 (2)编写开机自启动脚本 # vi /etc/init.d/redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/redis/redis-server
REDIS_CLI=/usr/redis/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/redis/redis.conf"
AUTH="1234"
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 exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep 2
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设置AUTH命令
redis 127.0.0.1:6379> AUTH PASSWORD
(error) ERR Client sent AUTH, but no password is set
redis 127.0.0.1:6379> CONFIG SET requirepass "1234"
OK
redis 127.0.0.1:6379> AUTH 1234
Ok
# chmod 755 redis (4)启动
# /etc/init.d/redis start 提示错误 /etc/init.d/redis:permission denied # chkconfig: 2345 90 10 # description: Redis is a persistent key-value database (6)关机重启测试 5.设置启动redis为后台启动 平时我们启动是这样的: 如果按ctrl+c退出后,则关闭了. 如果要设置redis后台启动,则需要修改redis.config文件,修改这里 英文大概意思默认情况下复述,不作为守护进程运行。如果你需要使用“是”。 再次启动OK
|
|