您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。