.安装tcl支持
yum install tcl
下载安装:redis
wget http://download.redis.io/releases/redis-2.8.9.tar.gz $ tar xzf redis-2.8.9.tar.gz $ cd redis-2.8.9 $ make $ make test $ make install
测试通过后安装,安装后会自动把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump复制到/usr/local/bin目录下。
编辑redis.conf文件
修改daemonize no改成yes。
我们手动复制redis.conf到/etc/redis(新建redis目录)目录下
cp redis.conf /etc
编写自init.d脚本
########################### #chkconfig: 2345 10 90 #description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 //自己设置为准 EXEC=/usr/local/bin/redis-server //根据 redis安装 配置 REDIS_CLI=/usr/local/bin/redis-cli //根据 redis安装 配置 PIDFILE=/var/run/redis.pid CONF="/etc/redis/redis.conf" //根据 redis安装 配置 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 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 +x /etc/init.d/redis chkconfig --add redis chkconfig --level 345 redis on
启动redis服务
redis-server redis-server /etc/redis/redis.conf & service redis start
查看redis服务监听的地址和端口
# netstat -tnlp |grep redis tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 25350/redis-server