首页 > 在Ubuntu 14.04 64bit上安装redis 3.0.3

在Ubuntu 14.04 64bit上安装redis 3.0.3

1.下载安装:

cd /tmp

wget http://download.redis.io/releases/redis-3.0.3.tar.gz

tar -zxf redis-3.0.3.tar.gz

cd redis-3.0.3

make

sudo make install



2.下载配置文件和init启动脚本:

wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server

wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf

sudo mv redis-server /etc/init.d/redis-server

sudo chmod +x /etc/init.d/redis-server

sudo mv redis.conf /etc/redis.conf

为保险起见,再将init脚本redis-server再贴一遍

#! /bin/sh
### BEGIN INIT INFO
# Provides:		redis-server
# Required-Start:	$syslog
# Required-Stop:	$syslog
# Should-Start:		$local_fs
# Should-Stop:		$local_fs
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6
# Short-Description:	redis-server - Persistent key-value db
# Description:		redis-server - Persistent key-value db
### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/bin/redis-server
DAEMON_ARGS=/etc/redis.conf
NAME=redis-server
DESC=redis-server
PIDFILE=/var/run/redis.pidtest -x $DAEMON || exit 0
test -x $DAEMONBOOTSTRAP || exit 0set -ecase "$1" instart)echo -n "Starting $DESC: "touch $PIDFILEchown redis:redis $PIDFILEif start-stop-daemon --start --quiet --umask 007 --pidfile $PIDFILE --chuid redis:redis --exec $DAEMON --background -- $DAEMON_ARGSthenecho "$NAME."elseecho "failed"fi;;stop)echo -n "Stopping $DESC: "if start-stop-daemon --stop --retry 10 --quiet --oknodo --pidfile $PIDFILE --exec $DAEMONthenecho "$NAME."elseecho "failed"firm -f $PIDFILE;;restart|force-reload)${0} stop${0} start;;*)echo "Usage: /etc/init.d/$NAME {start|stop|restart|force-reload}" >&2exit 1;;
esacexit 0



3.初始化用户和日志路径

第一次启动Redis前,建议为Redis单独建立一个用户,并新建data和日志文件夹

sudo useradd redis

sudo mkdir -p /var/lib/redis

sudo mkdir -p /var/log/redis

sudo chown redis.redis /var/lib/redis

sudo chown redis.redis /var/log/redis



4.设置开机自动启动,关机自动关闭

sudo update-rc.d redis-server defaults



5.启动Redis:

sudo /etc/init.d/redis-server start



6.启动client客户端连接:

$ redis-cli

redis> set foo bar

OK

redis> get foo

"bar"



参考文献

[1].http://rubyer.me/blog/638/

更多相关: