1.安裝jdk1.8
[root@sht-sgmhadoopdn-04 ~]# cd /usr/java/
[root@sht-sgmhadoopdn-04 java]# wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u111-b14/jdk- 8u111-linux-x64.tar.gz
[root@sht-sgmhadoopdn-04 java]# tar -zxvf jdk-8u111-linux-x64.tar.gz
[root@sht-sgmhadoopdn-04 java] # vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_111
export path=$JAVA_HOME/bin:$PATH
[root@sht-sgmhadoopdn-04 java] # source /etc/profile
[root@sht-sgmhadoopdn-04 java]# java -version
java 版本"1.8.0_111"
Java(TM) SE 執行時間環境(版本1.8.0_111- b14) )
Java HotSpot(TM) 64 位元伺服器虛擬機器(內部版本25.111-b14,混合模式)
[root@sht-sgmhadoopdn-04 java]
#2 .安裝redis 3.2.5
#2.1安裝編需要所需套件gcc,tcl
[root@sht-sgmhadoopdn-04 local]# yum install gcc
[ root@sht- sgmhadoopdn-04 local]# yum install tcl
2.2 下載redis-3.2.5##[root@sht-sgmhadoopdn-04 local]# wget http:/ /download.redis .io/releases/redis-3.2.5.tar.gz
--2016-11-12 20:16:40-- http://download.redis.io/releases/redis-3.2 .5.tar .gz
正在解析download.redis.io (download.redis.io)... 109.74.203.151
連接到download.redis.io (download.redis.io)|109.74.203.151 |:80.. .已連線。
HTTP 請求已傳送,正在等待回應... 200 OK
長度:1544040 (1.5M) [application/x-gzip]
儲存到:'redis -3.2.5.tar.gz '
##2.3 安裝redis [root@sht-sgmhadoopdn-04 local]# mkdir /usr/local/redis
[root@sht-sgmhadoopdn-04 local]# tar xzvf redis-3.2.5 .tar.gz
[root@sht -sgmhadoopdn-04 local]# cd redis-3.2.5
[root@sht-sgmhadoopdn-04 redis-3.2.5]# make PREFIX=/usr/local/ redis install
[root@sht-sgmhadoopdn -04 redis-3.2.5]# cd ../
[root@sht-sgmhadoopdn-04 redis-3.2.5]# ll /usr/local/redis/ bin/
total 15056
- rwxr-xr-x 1 根2431728 11 月12 日20:45 redis-benchmark
-rwxr-xr-x 1 根 25165 11 月12 日 redis -check-aof
-rwxr-xr-x 1 root root 5182191 11月12日20:45 redis-check-rdb
-rwxr-xr-x 1 root root 2584443 11月12日20:455 redis -cli
lrwxrwxrwx 1 root root 12月12日20:45 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 5182191 Nov 12 20:45 redis-server
2.4 設定redis為服務[root@server redis- 3.2.5]# cp utils/redis_init_script /etc/rc.d/init.d/redis
[root@server redis-3.2.5]# vi /etc/rc.d/init.d/redis
在第二行新增:#chkconfig: 2345 80 90
EXEC=/usr/local/bin/redis-server 修改成EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/ usr/local/bin/redis-cli 修改成CLIEXEC=/usr/local/redis/bin/redis-cli
CONF="/etc/redis/${REDISPORT}.conf" 修改成CONF="/usr /local/redis/conf/${REDISPORT}.conf"
$EXEC $CONF 修改成 $EXEC $CONF &
[root@server redis-3.2.5]# chkconfig --add redis
[root@server redis-3.2.5]# cp redis.conf /usr/local/redis/conf /6379.conf
[root@server redis-3.2.5]# vi /usr/local/redis/conf/6379.conf
daemonize yes
pidfile /var/run/redis_6379.pid
bind 172.16.101.66
[root@server redis-3.2.5]# cd ../redis[root@sht- sgmhadoopdn -04 redis]# service redis start
啟動Redis伺服器...
[root@sht-sgmhadoopdn-04 redis]# netstat -tnlp|grep redis##tcp 0 :* LISTEN 30032/redis-server
[root@sht-sgmhadoopdn-04 redis
##cgmpc ]# vi /etc/profile
export REDIS_HOME=/usr/local/redis
export PATH=$REDIS_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin :/ usr/bin:/root/bin
[root@sht-sgmhadoopdn-04 redis]# which redis-cli /usr /local/redis/bin/redis-cli#
2.7 測試與設定密碼(本實驗未設定密碼)
[root@sht-sgmhadoopdn-04 redis]# redis-cli -h sht-sgmhadoopdn-04
sht -sgmhadoopdn-04:6379>
sht-sgmhadoopdn-04:6379> set testkey testvalue
OK
sht-sgmhadoopdn-04:6379>value; get test
(nil)#o-sgm; -04:6379> get testkey
"testvalue"
sht-sgmhadoopdn-04:6379>
/*新增一個驗證密碼*/requirepass 123456
[root@sht-sgmhadoopdn-04 redis]# service redis stop
[ root@sht-sgmhadoopdn-04 redis]# service redis start
[root@sht-sgmhadoopdn-04 redis]# redis-cli -h sht-sgmhadoopdn-04
sht-sgmhadoopdn-04:6379> ; set key ss
(error) NOAUTH Authentication required.
[root@server redis-3.2.5]# redis-cli -h sht-sgmhadoopdn-04 -a 123456
sht-sgmhadoopdn-0oopdn-04 -a 123456
sht-sgmhadoopdn-04: 6379> set a b
OK
sht-sgmhadoopdn-04:6379> get a
"b"
sht-sgmhadoopdn-04:6379> exit;
[root@sht-sgmhadoopdn-04 redis]
以上是redis單節點實例分析的詳細內容。更多資訊請關注PHP中文網其他相關文章!