redis安装

2018-12-30  本文已影响0人  ZemelZhu

下载redis

1.https://redis.io/download 下载redis上传到 /usr/local下

安装

cd /usr/local/redis-4.0.2
make

提取配置文件

mkdir -p /usr/redis
cp /usr/local/redis-4.0.2/src/redis-server /usr/local/redis/
cp /usr/local/redis-4.0.2/src/redis-cli /usr/local/redis/
cp /usr/local/redis-4.0.2/redis.conf /usr/local/redis/

修改配置文件

vim /usr/local/redis/redis.conf

编辑redis开机启动redis脚本

!/bin/sh

chkconfig: 2345 80 90

description: Start and Stop redis

PATH=/usr/local/bin:/sbin:/usr/bin:/bin

REDISPORT=6379
EXEC=/usr/local/redis/redis-server
REDIS_CLI=/usr/local/redis/redis-cli
PIDFILE=/var/run/redis_6379.pid
CONF="/usr/local/redis/redis.conf"
AUTH="1234"

case "1" in start) if [ -fPIDFILE ]
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=(catPIDFILE)
echo "Stopping ..."
REDIS_CLI -aAUTH -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

添加开机启动服务

vim /etc/rc.local
最后加入
service redis start

设置权限

chmod 755 /etc/init.d/redis

注册系统服务

chkconfig --add redis

测试redis服务

service redis start
service redis stop

创建redis命令软连接

ln -s /usr/local/redis/redis-cli /usr/bin/redis

测试redis

redis

配置防火墙即可

上一篇下一篇

猜你喜欢

热点阅读