wget http://download.redis.io/releases/redis-3.2.6.tar.gz
tar -zxvf redis-3.2.6.tar.gz
cd redis-3.2.6
make//編譯,生成src、redis.conf文件
cd src
cp redis-cli redis-server /usr/local/redis/
cd redis-3.2.6
cp redis.conf /usr/local/redis/
//redis下開啓前臺服務
./redis-server
//redis下開啓後臺服務,修改redis.conf 文件,將daemonize no 改成daemonize yes
vi redis.conf
//殺掉rdis進程,而後再次打開redis服務,沒有killall命令就yum安裝,yum install psmisc -y(centos7下)
killall redis-server
//開啓服務
./redis-server redis.conf
//查看開啓的服務
pstree
//後臺運行成功之後,用redis-cli本地客戶端鏈接redis。若是是鏈接網絡機器 :./redis-cli IP 端口號,IP地址和端口號能夠不寫,不寫的話,默認鏈接本機redis
./redis-cli
//配置開機自啓
mkdir /etc/init.d/redisredis
vi /etc/init.d/rediscentos
#!/bin/bash #chkconfig: 2345 10 90 # description: Start and Stop redis PATH=/usr/local/bin:/sbin:/usr/bin:/bin REDISPORT=6379 EXEC=/usr/local/redis/redis-server REDIS_CLI=/usr/local/redis/redis-cli PIDFILE=/var/run/redis.pid CONF="/usr/local/redis/redis.conf" AUTH="1234" 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
///etc/init.d/redis下設置權限
chmod 755 redis
//啓動測試
/etc/init.d/redis start
//返回,Starting Redis server... Redis is running...
//執行腳本,開機自啓,
chkconfig redis onbash