安装
wget http://download.redis.io/releases/redis-5.0.0.tar.gz
tar xvf redis-5.0.0.tar.gz
# 进入到redis的目录, 执行指令make
okamideMBP:softwear root# cd redis-5.0.0
okamideMBP:redis-5.0.0 root# make
vi redis.conf
启动
# 进入到redis的src目录
cd /usr/local/softwear/redis/bin
# 执行脚本redis-server
redis-server
redis-server ../redis.conf
# 1.修改redis.conf,将daemonize 设置为yes
vi redis.conf
daemonize yes
- 3.开机启动
- 在redis的安装目录redis-5.0.0/utils下,存在一个脚本redis_init_script, 内容如下
#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
#redis服务器监听的端口
REDISPORT=6379
#服务端所处位置
EXEC=/usr/local/bin/redis-server
#客户端位置
CLIEXEC=/usr/local/bin/redis-cli
#redis的PID文件位置,需要修改
PIDFILE=/var/run/redis_${REDISPORT}.pid
#redis的配置文件位置,需将${REDISPORT}修改为文件名
CONF="/etc/redis/${REDISPORT}.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
;;
*)
echo "Please use start or stop as first argument"
;;
esac
- 在/etc下创建redis目录,并把redis的脚本redis_init_script拷贝到/etc/init.d/redisd,拷贝redis的配置文件到/etc/redis/
mkdir /etc/redis
cp redis.conf /etc/redis/6379.conf
cp redis_init_script /etc/init.d/redisd
- 然后就可以直接使用service redisd start启动
#打开服务
service redisd start
#关闭服务
service redisd stop
#设置为开机自启动服务器
chkconfig redisd on
网友评论