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"
dir /app/redis/local/redis
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
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。