1:安裝wget: yum install wget
2:安裝pip:
1:sudo yum -y install epel-release
2:sudo yum -y install python-pip
3:安裝redis:
1:wget --no-check-certificate http://download.redis.io/releases/redis-3.2.3.tar.gz
2:tar xzf redis-3.2.3.tar.gz
3:mv redis-3.2.3 usr/local/redis-3.2.3
4:cd usr/loacl/redis-3.2.3
5:make
6:設置開機自啟:
1:設置redis.conf中daemonize為yes
2:設置redis.conf中logfile為"/var/log/redis.log"
2:編寫開機自啟動腳本
vi /etc/init.d/redis
redis content is:
"""
# chkconfig: 2345 10 90
# description: Start and Stop redis
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/redis-3.2.3/src/redis-server
REDIS_CLI=/usr/local/redis-3.2.3/src/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/usr/local/redis-3.2.3/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
sleep 2
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
"""
4:chmod +x /etc/init.d/redis
5:/etc/init.d/redis start
6:設置開機自啟:sudo chkconfig redis on
http://xxxxxx/Linuxjc/1152138.html TechArticle