linux安装redis
down最新的redis
wget http://download.redis.io/releases/redis-5.0.6.tar.gz
tar zxf redis-5.0.6.tar.gz
cd redis-5.0.6 && make
mkdir -p /usr/local/redis/bin
cp redis.conf /usr/local/redis/bin
cp redis.conf /usr/local/bin
cp src/redis-cli /usr/local/redis/bin
cp src/redis-cli /usr/local/bin
cp src/redis-server /usr/local/redis/bin
cp src/redis-server /usr/local/bin
cp src/redis-benchmark /usr/local/redis/bin
cp src/redis-benchmark /usr/local/bin
vim /usr/bin/redis
启动文件
#!/bin/sh
#
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis/bin/redis.conf"
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 -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Please use start or stop or restart as first argument"
;;
esac
chmod 777 /usr/bin/redis #给上面文件的权限
配置文件
vim /usr/local/redis/bin/redis.conf
---------------------------------------------
# bind 127.0.0.1
protected-mode no
---------------------------------------------
窗口运行
screen redis start
ctrl+A+D跳出窗口
kill pid可以停止服务
或者redis stop
或者screen -r 对应窗口终止服务