redis 怎么都启动不了的问题

由于做slb,直接复制了个镜像,复制完redis怎么都启动不了,

看了下log

[18423] 16 Nov 18:34:53.771 # Creating Server TCP listening socket 10.168.64.12:6379: bind: Cannot assign requested address

看到没  10.168.64.12:6379 bind失败了,复制过来没把bind的内网地址改成当前机器的就傻逼了。

改成自己的内我地址就OK了

redis 添加自启动

lnmp这个系统装了redis后没有设置自启动

那就让我们加下吧!

1.修改redis.conf,打开后台运行选项:

daemonize yes

2.编写脚本,vim /etc/init.d/redis:

# description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/bin

REDISPORT=6379 #实际环境而定
EXEC=/usr/local/redis/bin/redis-server #实际环境而定
REDIS_CLI=/usr/local/redis/bin/redis-cli #实际环境而定

PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis/etc/redis.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
 if [ "$?"="0" ]
 then
 echo "Redis is running..."
 fi
 ;;
 stop)
 if [ ! -f $PIDFILE ]
 then
 echo "$PIDFILE exists, 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

3.添加可执行权限

chmod +x /etc/init.d/redis

4.测试开关

service redis restart

5.开启自启动

chkconfig redis on

参考:

http://lnmp.org/install.html

http://my.oschina.net/indestiny/blog/197272

http://linux.51yip.com/search/chkconfig