下載redis
1.https://redis.io/download 下載redis上傳到 /usr/local下
安裝
cd /usr/local/redis-4.0.2
make
提取配置文件
mkdir -p /usr/redis
cp /usr/local/redis-4.0.2/src/redis-server /usr/local/redis/
cp /usr/local/redis-4.0.2/src/redis-cli /usr/local/redis/
cp /usr/local/redis-4.0.2/redis.conf /usr/local/redis/
修改配置文件
vim /usr/local/redis/redis.conf
- 在bind 127.0.0.1前加“#”將其注釋掉
- 默認(rèn)為保護(hù)模式冬念,把 protected-mode yes 改為 protected-mode no
- 默認(rèn)為不守護(hù)進(jìn)程模式就漾,把daemonize no 改為daemonize yes
- 將 requirepass foobared前的“#”去掉,密碼改為你想要設(shè)置的密碼
編輯redis開機(jī)啟動(dòng)redis腳本
!/bin/sh
chkconfig: 2345 80 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_6379.pid
CONF="/usr/local/redis/redis.conf"
AUTH="1234"
case "PIDFILE ]
then
echo "EXEC ?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f PIDFILE does not exist, process is not running"
else
PID=PIDFILE)
echo "Stopping ..."
AUTH -p {PIDFILE} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
{0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
添加開機(jī)啟動(dòng)服務(wù)
vim /etc/rc.local
最后加入
service redis start
設(shè)置權(quán)限
chmod 755 /etc/init.d/redis
注冊系統(tǒng)服務(wù)
chkconfig --add redis
測試redis服務(wù)
service redis start
service redis stop
創(chuàng)建redis命令軟連接
ln -s /usr/local/redis/redis-cli /usr/bin/redis
測試redis
redis