安装
1013 2016-07-21 22:27:46 wget http://download.redis.io/releases/redis-3.2.1.tar.gz 1021 2016-07-21 22:31:31 tar xzf redis-3.2.1.tar.gz 1023 2016-07-21 22:32:37 cd redis-3.2.1 1025 2016-07-21 22:33:11 make PREFIX=/home/users/youname/local/redis-3.2.1 install 1034 2016-07-21 22:39:14 vim run.sh 1037 2016-07-21 22:41:03 mkdir conf pids 1040 2016-07-21 22:41:20 mv redis.conf* conf/ 1046 2016-07-21 22:41:43 sh run.sh start 1048 2016-07-21 22:42:15 mv conf/redis.conf conf/9527.conf 1049 2016-07-21 22:42:18 sh run.sh start 1050 2016-07-21 22:42:34 netstat -tunpl |grep 9527
编写启动脚本
#!/bin/sh #chkconfig: 2345 80 90 # Simple Redis init.d script conceived to work on Linux systems # as it does use of the /proc filesystem. REDISPORT=9527 EXEC=/home/users/youname/local/redis-3.2.1/bin/redis-server CLIEXEC=/home/users/youname/local/redis-3.2.1/bin/redis-cli PIDFILE=/home/users/youname/local/redis-3.2.1/pids/redis_${REDISPORT}.pid CONF="/home/users/youname/local/redis-3.2.1/conf/${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 ;; 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
配置文件修改
port 9527 # By default Redis does not run as a daemon. Use 'yes' if you need it. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized. daemonize yes pidfile /home/users/v_haowenzhi/local/redis-3.2.1/pids/redis_9527.pid
简单测试
redis-3.2.1]$ bin/redis-cli -p 9527 127.0.0.1:9527> set pwd asdasd OK 127.0.0.1:9527> get pwd "asdasd"