redis安装文档
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis安装文档相关的知识,希望对你有一定的参考价值。
1、官网下载最新的redis安装文档:我这里下载目前最新的5.0版本wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar -xvf redis-5.0.7.tar.gz
mv redis-5.0.7 redis
cd redis
可以使用gcc -v检查安装环境
然后在redis目录下编译安装
make
编译成功后,会在src目录下生成
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server redis-trib.rb 这几个启动文件
可以先建立一个bin目录,然后把这几个配置文件cp进去
redis目录下新建run、log、local目录
配置文件修改
vim redis.conf
bind 0.0.0.0
daemonize yes
pidfile /app/redis/run/redis_6379.pid
logfile "/app/redis/log/redis.log"
设置RDB保存位置
dir /app/redis/local/redis
开启AOF
appendonly yes
#设置密码
requirepass admin
启动方式:
/app/redis/bin/redis-server /app/redis/redis.conf &
也可以制作init启动脚本:
vim /etc/init.d/redis-server
#!/bin/bash
#
PATH=$PATH:/app/redis/bin
REDISPORT=6379
EXEC=/app/redis/bin/redis-server
REDIS_CLI=/app/redis/bin/redis-cli
PIDFILE=/app/redis/run/redis_6379.pid
CONF="/app/redis/redis.conf"
#make sure some dir exist
if [ ! -d /var/lib/redis ] ;then
mkdir -p /var/lib/redis
fi
case "$1" in
status)
ps -A|grep redis
;;
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
chmod o+x /etc/init.d/redis-server
service redis-server start
以上是关于redis安装文档的主要内容,如果未能解决你的问题,请参考以下文章