首先从redis官网下载tar文件,下载地址URL:http://download.redis.io/releases/redis-5.0.2.tar.gz
使用wget命令下载,如果没有安装wget,则通过yum install wget安装
wget http://download.redis.io/releases/redis-5.0.2.tar.gz
[root@localhost software]# ls
redis-5.0.2.tar.gz
使用tar命令解压:
tar zxvf redis-5.0.2.tar.gz
[root@localhost software]# tar zxvf redis-5.0.2.tar.gz
drwxrwxr-x. 6 root root 4096 Nov 22 05:26 redis-5.0.2
-rw-r--r--. 1 root root 1952989 Nov 22 05:30 redis-5.0.2.tar.gz
进入到cd redis-5.0.2,执行make && make test
安装过程中出现以下错误,需要安装:tcl
make[1]: Leaving directory `/usr/local/software/redis-5.0.2/src'
cd src && make test
make[1]: Entering directory `/usr/local/software/redis-5.0.2/src'
CC Makefile.dep
make[1]: Leaving directory `/usr/local/software/redis-5.0.2/src'
make[1]: Entering directory `/usr/local/software/redis-5.0.2/src'
You need tcl 8.5 or newer in order to run the Redis test
make[1]: *** [test] Error 1
make[1]: Leaving directory `/usr/local/software/redis-5.0.2/src'
make: *** [test] Error 2
进入到cd utils
执行:./install_server.sh
[root@localhost utils]# ./install_server.sh
Welcome to the redis service installer
This script will help you easily set up a running redis server
Please select the redis port for this instance: [6379]
Selecting default: 6379
Please select the redis config file name [/etc/redis/6379.conf]
Selected default - /etc/redis/6379.conf
Please select the redis log file name [/var/log/redis_6379.log]
Selected default - /var/log/redis_6379.log
Please select the data directory for this instance [/var/lib/redis/6379]
Selected default - /var/lib/redis/6379
Please select the redis executable path [/usr/local/bin/redis-server]
Selected config:
Port : 6379
Config file : /etc/redis/6379.conf
Log file : /var/log/redis_6379.log
Data dir : /var/lib/redis/6379
Executable : /usr/local/bin/redis-server
Cli Executable : /usr/local/bin/redis-cli
Is this ok? Then press ENTER to go on or Ctrl-C to abort.
Copied /tmp/6379.conf => /etc/init.d/redis_6379
Installing service...
Successfully added to chkconfig!
Successfully added to runlevels 345!
Starting Redis server...
Installation successful!
[root@localhost utils]#
出现以上提示,安装成功
执行etc/init.d/redis_6379 start,出现端口已经再运行
[root@localhost utils]# /etc/init.d/redis_6379 start
/var/run/redis_6379.pid exists, process is already running or crashed
重新执行 etc/init.d/redis_6379 restart
[root@localhost Desktop]# /etc/init.d/redis_6379 restart
Stopping ...
Redis stopped
Starting Redis server...
通过/usr/local/bin/redis-cli连接至redis服务器
[root@localhost init.d]# /usr/local/bin/redis-cli
127.0.0.1:6379>
简单测试
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379> set a 'a'
OK
127.0.0.1:6379> keys *
1) "a"
127.0.0.1:6379>
网友评论