您好,登錄后才能下訂單哦!
安裝環(huán)境:
CentOS 6.5
Redis redis-2.8.13
下載安裝:
1、切換至/usr/local/src/目錄下:
[root@node2 ~]# cd /usr/local/src
下載源碼包:
[root@node2 src]# wget http://download.redis.io/releases/redis-2.8.23.tar.gz
2、解壓:
[root@node2 src]# tar xf redis-2.8.23.tar.gz
3、切換至redis-2.8.23目錄下:
[root@node2 src]# cd redis-2.8.23
4、安裝redis至/usr/local/redis目錄:
[root@node2 redis-2.8.23]# make PREFIX=/usr/local/redis install
5、為redis提供SysV init腳本:
[root@node2 redis-2.8.23]# vim /etc/rc.d/init.d/redis
#!/bin/sh
# chkconfig: 2345 83 93
# Simple Redis init.d script conceived to work on Linuxsystems
# as it does use of the /proc filesystem.
#
# Simple Redis init.d script conceived to work on Linuxsystems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis/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
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
*)
echo "Please use startor stop as first argument"
;;
esac
6、給腳本賦予執(zhí)行權(quán)限:
[root@node2 redis-2.8.23]# chmod u+x /etc/rc.d/init.d/redis
7、添加至服務(wù)管理列表,并讓其開機(jī)自動啟動:
[root@node2 redis-2.8.23]# chkconfig --add /etc/rc.d/init.d/redis
[root@node2 redis-2.8.23]# chkconfig redis on
8、創(chuàng)建redis持久化文件存放目錄
mkdir -pv /var/redis/data
9、創(chuàng)建配置文件存放目錄
[root@node2 redis-2.8.23]# mkdir /etc/redis
10、提供配置文件
[root@node2 redis-2.8.23]# cp/usr/local/src/redis-2.8.23/redis.conf /etc/redis/
11、編輯配置文件更改以下選項為如下值
[root@node2 redis-2.8.23]# vim /etc/redis/redis.conf
daemonizeyes #使Redis以守護(hù)進(jìn)程模式運行
dir/var/redis/data #設(shè)置持久化文件存放位置,路徑可自定義
12、啟動服務(wù)
[root@node2 redis-2.8.23]# service redis start
13、檢查服務(wù)端口
[root@node2 redis-2.8.23]# netstat -tunl | grep 6379
tcp 0 00.0.0.0:6379 0.0.0.0:* LISTEN
14、修改PATH環(huán)境變量,讓系統(tǒng)可以直接使用redis的相關(guān)命令:
[root@node2 ~]# echo 'exportPATH=/usr/local/redis/bin:$PATH' > /etc/profile.d/redis.sh
[root@node2 ~]# source /etc/profile.d/redis.sh
15、使用redis客戶端工具連上redis進(jìn)行測試:
[root@node2 ~]# redis-cli
127.0.0.1:6379> set hello world
OK
127.0.0.1:6379>
127.0.0.1:6379> get hello
"world"
127.0.0.1:6379> quit
[root@node2 ~]#
到此Redis的安裝測試已經(jīng)完成。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。