標籤:releases target blank style title
下載redis安裝檔案
wget http://download.redis.io/releases/redis-3.0.3.tar.gz
650) this.width=650;" title="clip_image002" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image002" src="http://s3.51cto.com/wyfs02/M02/70/03/wKioL1Wvg2-jiHiiAACmCL3gZs0300.jpg" width="604" height="444" />
解壓檔案 redis-3.0.3.tar.gz
tar xzf redis-3.0.3.tar.gz
650) this.width=650;" title="clip_image004" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image004" src="http://s3.51cto.com/wyfs02/M00/70/03/wKioL1Wvg3CRD5q5AAEKeynpnjU140.jpg" width="604" height="234" />
編譯源檔案
make
650) this.width=650;" title="clip_image006" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image006" src="http://s3.51cto.com/wyfs02/M01/70/03/wKioL1Wvg3CAU99DAAEktIaUKjw876.jpg" width="604" height="323" />
提示錯誤 gcc未找到
sudo yum -y intall gcc
650) this.width=650;" title="clip_image008" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image008" src="http://s3.51cto.com/wyfs02/M02/70/03/wKioL1Wvg3GA-K_SAAE2YjGs8DM805.jpg" width="604" height="324" />
然後刪除加壓檔案
rm -rf redis-3.0.3
650) this.width=650;" title="clip_image010" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image010" src="http://s3.51cto.com/wyfs02/M00/70/03/wKioL1Wvg3LALqWgAADRRLsuTiI836.jpg" width="604" height="403" />
tar xzf redis-3.0.3.tar.gz
cd redis-3.-0.3
make
650) this.width=650;" title="clip_image012" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image012" src="http://s3.51cto.com/wyfs02/M01/70/03/wKioL1Wvg3LRzPDxAADdivK9sug746.jpg" width="604" height="337" />
輸入./src/redis-server
啟動 redis
650) this.width=650;" title="clip_image014" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image014" src="http://s3.51cto.com/wyfs02/M02/70/03/wKioL1Wvg3PBeWOgAAFTorfgges021.jpg" width="604" height="336" />
新開一個終端輸入 sudo ./redis-3.0.3/src/redis-cli
輸入 set foo bar
輸入 get foo
測試正常安裝成功
650) this.width=650;" title="clip_image016" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image016" src="http://s3.51cto.com/wyfs02/M00/70/03/wKioL1Wvg3ST7xwFAACTJ46UiRo352.jpg" width="604" height="340" />
修改 redis-3.0.3下設定檔
vim ./redis-3.0.3/redis.conf
找到 daemonize no 這項修改為 yes
使服務端運行在後台
建立 redis service指令碼
sudo touch /etc/rc.d/init.d/redis
650) this.width=650;" title="clip_image018" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image018" src="http://s3.51cto.com/wyfs02/M01/70/03/wKioL1Wvg3TjnsOdAACnZwsPT0E072.jpg" width="604" height="337" />
編輯檔案
sudo vim /etc/rc.d/init.d/redis
輸入下面檔案
來源於網路
#!/bin/sh
#chkconfig: 2345 86 14
#description: Startup and shutdown script for Redis
PROGDIR=/opt/redis-3.0.3/src #安裝路徑
PROGNAME=redis-server
DAEMON=$PROGDIR/$PROGNAME
CONFIG=/opt/redis-3.0.3/redis.conf
PIDFILE=/var/run/redis.pid
DESC="redis daemon"
SCRIPTNAME=/etc/rc.d/init.d/redis
start()
{
if test -x $DAEMON
then
echo -e "Starting $DESC: $PROGNAME"
if $DAEMON $CONFIG
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "Couldn‘t find Redis Server ($DAEMON)"
fi
}
stop()
{
if test -e $PIDFILE
then
echo -e "Stopping $DESC: $PROGNAME"
if kill `cat $PIDFILE`
then
echo -e "OK"
else
echo -e "failed"
fi
else
echo -e "No Redis Server ($DAEMON) running"
fi
}
restart()
{
echo -e "Restarting $DESC: $PROGNAME"
stop
start
}
list()
{
ps aux | grep $PROGNAME
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
list)
list
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|list}" >&2
exit 1
;;
esac
exit 0
增加執行許可權
650) this.width=650;" title="clip_image020" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image020" src="http://s3.51cto.com/wyfs02/M02/70/03/wKioL1Wvg3WTEIk0AADRE00uXeo791.jpg" width="604" height="342" />
添加服務
sudo chkconfig --add redis
報錯
650) this.width=650;" title="clip_image022" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image022" src="http://s3.51cto.com/wyfs02/M00/70/03/wKioL1Wvg3biioIWAAFr7V0PI50926.jpg" width="604" height="439" />
修改/etc/rc.d/init.d/redis,檢查 #chkconfig: 2345 86 14 這行。
650) this.width=650;" title="clip_image024" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image024" src="http://s3.51cto.com/wyfs02/M00/70/06/wKiom1WvgZLiUhvEAAFOPDsYQ5k862.jpg" width="604" height="409" />
設定開機啟動
sudo chkconfig --level 2345 redis on
650) this.width=650;" title="clip_image026" style="border-left- 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; padding-top: 0px; padding-left: 0px; padding-right: 0px; border-top-width: 0px" border="0" alt="clip_image026" src="http://s3.51cto.com/wyfs02/M01/70/06/wKiom1WvgZOj2hR3AAEQMXyAKXY759.jpg" width="604" height="339" />
最後 sudo cp -r /home/william/redis-3.0.3 /opt/redis-3.0.3
啟動redis
sudo service redis start
關閉redis
sudo service redis stop
重啟redis
sudo service redis restart
Centos安裝redis3.0.3