Rumah >pangkalan data >Redis >analisis contoh nod tunggal redis
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] # vi /etc/profile
eksport JAVA_HOME=/usr/java/jdk1.8.0_111
laluan eksport=$JAVA_HOME/bin:$PATH
[root@sht-sgmhadoopdn-04 java] # sumber /etc/profile
[root@sht-sgmhadoopdn-04 java]# java -version
versi java "1.8.0_111"
Java(TM) SE Runtime Environment (bina 1.8.0_111-b14 )
Java HotSpot(TM) 64-Bit Server VM (bina 25.111-b14, mod campuran)
[root@sht-sgmhadoopdn-04 java]#
2.安装 redis 3.2.5
2.1 安装编绎所需包gcc,tcl
[root@sht-sgmhadoopdn-04 local]# yum install gcc
-[root 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
Menyelesaikan muat turun.redis.io (muat turun.redis.io)... 109.74.203.151
Menyambung ke muat turun.redis.io (muat turun.redis.io)|109.74.203.151|:80.. . disambungkan.
Permintaan HTTP dihantar, menunggu jawapan... 200 OK
Panjang: 1544040 (1.5M) [application/x-gzip]
Menyimpan ke: 'redis-3.2.5.tar.gz '
100%[========================================== =================================================== =================================>] 1,544,040 221KB/s dalam 6.8s
2016- 11-12 20:16:47 (221 KB/s) - 'redis-3.2.5.tar.gz' disimpan [1544040/1544040]
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/
jumlah 15056
- rwxr-xr-x 1 akar punca 2431728 Nov 12 20:45 redis-penanda aras
-rwxr-xr-x 1 akar punca 25165 Nov 12 20:45 redis-check-aof
-rwxr-xr-x root root 5182191 Nov 12 20:45 redis-check-rdb
-rwxr-xr-x 1 root root 2584443 Nov 12 20:45 redis-cli
lrwxrwxrwx 1 root root 2 12 2 redis -> redis-server
-rwxr-xr-x 1 root root 5182191 Nov 12 20:45 redis-server
2.4 配置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
CLIEX=/> 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 ya
pidfile /var/run/redis_6379.pid
bind 172.16.101.66
2.5 启动redis[root@server redis-3.2.5]# cd ../redis
-[root@sht sgmhadoopdn-04 redis]# perkhidmatan redis mula
Memulakan pelayan Redis...
[root@sht-sgmhadoopdn-04 redis]# netstat -tnlp|grep redis
tcp 0 0 0 0 0 0 0 0 0 0 . 0 . 0 0 0 .0.0:* DENGAR 30032/redis-server
[root@sht-sgmhadoopdn-04 redis]#
2.62.6 添墏sht-sgmhadoopdn- 04 redis]# vi /etc/profileeksport REDIS_HOME=/usr/local/redis
eksport PATH=$REDIS_HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin :/usr/bin:/root/bin
[root@sht-sgmhadoopdn-04 redis]# sumber /etc/profile
[root@sht-sgmhadoopdn-04 redis]# yang redis-cli
/usr/local/redis/bin/redis-cli
2.7 Uji dan tetapkan kata laluan (tiada kata laluan ditetapkan dalam percubaan ini)
[root@sht-sgmhadoopdn-04 redis]# redis-cli -h sht-sgmhadoopdn-04
sht -sgmhadoopdn-04:6379>
sht-sgmhadoopdn-04:6379> sgmhadoopdn -04:6379> dapatkan kunci ujian
"nilai ujian"
sht-sgmhadoopdn-04:6379>
[root@sht-sgmhadoopdn-04/redis/lo] conf /6379.conf
/*Tambah kata laluan pengesahan*/
requirepass 123456
[root@sht-sgmhadoopdn-04 redis]# service redis stop [ root@sht-sgmhadoopdn-04 redis]# perkhidmatan redis mula
[root@sht-sgmhadoopdn-04 redis]# redis-cli -h sht-sgmhadoopdn-04
sht-sgmhadoopdn-04: 6379> ; set kunci ss
(ralat) Pengesahan NOAUTH diperlukan
[root@server redis-3.2.5]# redis-cli -h sht-sgmhadoopdn-04 -a 123456
sht : 6379> set a
OK
sht-sgmhadoopdn-04:6379> - 04 redis]#
Atas ialah kandungan terperinci analisis contoh nod tunggal redis. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!