1, Install dependency package and prepare environment.
yum install -y gcc
Depending on the package, you can install it according to the prompts at compile time. But gcc must be installed.
2, 1. Download the tar package, install and start it.
wget http://source.goyun.org:8000/source/Redis/redis-3.2.9.tar.gz
--2018-01-12 19:15:07-- http://source.goyun.org:8000/source/Redis/redis-3.2.9.tar.gz
Resolving source.goyun.org... 59.110.136.26
Connecting to source.goyun.org|59.110.136.26|:8000... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1547695 (1.5M) [application/x-gzip]
Saving to: "redis-3.2.9.tar.gz.1"
100%[===================================================================================================================>] 1,547,695 73.8K/s in 42s
2018-01-12 19:15:49 (36.4 KB/s) - "redis-3.2.9.tar.gz.1" saved [1547695/1547695]
It is downloaded in the current directory by default,
2. Unzip:
tar zxvf redis-3.2.9.tar.gz
[root@localhost ~]# ll
drwxrwxr-x 6 root root 4096 May 17 2017 redis-3.2.9
-rw-r--r-- 1 root root 1547695 Jan 12 15:07 redis-3.2.9.tar.gz
A redis-3.2.9 directory will be generated under the current directory.
3. Go to the directory and make:
[root@localhost ~]# cd redis-3.2.9
[root@localhost redis-3.2.9]# ll
total 208
-rw-rw-r-- 1 root root 87407 May 17 2017 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 May 17 2017 BUGS
-rw-rw-r-- 1 root root 1805 May 17 2017 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 May 17 2017 COPYING
drwxrwxr-x 7 root root 4096 May 17 2017 deps
-rw-rw-r-- 1 root root 11 May 17 2017 INSTALL
-rw-rw-r-- 1 root root 151 May 17 2017 Makefile
-rw-rw-r-- 1 root root 4223 May 17 2017 MANIFESTO
-rw-rw-r-- 1 root root 6834 May 17 2017 README.md
-rw-rw-r-- 1 root root 46695 May 17 2017 redis.conf
-rwxrwxr-x 1 root root 271 May 17 2017 runtest
-rwxrwxr-x 1 root root 280 May 17 2017 runtest-cluster
-rwxrwxr-x 1 root root 281 May 17 2017 runtest-sentinel
-rw-rw-r-- 1 root root 7606 May 17 2017 sentinel.conf
drwxrwxr-x 2 root root 4096 May 17 2017 src
drwxrwxr-x 10 root root 4096 May 17 2017 tests
drwxrwxr-x 7 root root 4096 May 17 2017 utils
[root@localhost redis-3.2.9]# make
4. Enter the unzipped Directory:
[root@localhost redis-3.2.9]# cd src/
[root@localhost src]# pwd
/root/redis-3.2.9/src
[root@localhost src]#make test
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
Note that there is an error. The solution: Download and install TCL
[root@localhost src]#cd
[root@localhost ~]#wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz
[root@localhost ~]# ll
drwxrwxr-x 6 root root 4096 May 17 2017 redis-3.2.9
-rw-r--r-- 1 root root 1547695 Jan 12 15:07 redis-3.2.9.tar.gz
-rw-r--r-- 1 root root 229376 Jan 12 19:25 tcl8.6.1-src.tar.gz
[root@localhost ~]# tar zxvf tcl8.6.1-src.tar.gz
[root@localhost ~]# ll
drwxrwxr-x 6 root root 4096 May 17 2017 redis-3.2.9
-rw-r--r-- 1 root root 1547695 Jan 12 15:07 redis-3.2.9.tar.gz
-rw-r--r-- 1 root root 229376 Jan 12 19:25 tcl8.6.1-src.tar.gz
drwxr-xr-x 4 15399 19249 4096 Sep 20 2013 tcl8.6.1
[root@localhost Desktop]# cd tcl8.6.1/
[root@localhost tcl8.6.1]# cd unix/
[root@localhost unix]# ./configure
[root@localhost unix]# make && make install
5. Go back to Redis's denture directory and make test again
[root@localhost src]# pwd
/root/redis-3.2.9/src
Show All tests passed without errors!
The test is successful!
It's ready to install.
6. Installation:
[root@localhost src]# make PREFIX=/usr/local/redis install
[root@loalhost redis]# cd /usr/local/redis
[root@loalhost redis]# ll
total 56
drwxr-xr-x 2 root root 4096 Jan 12 15:52 bin
-rw-r--r-- 1 root root 90 Jan 12 16:34 dump.rdb
[root@loalhost redis]# cd bin/
[root@loalhost bin]# ls
dump.rdb redis-check-aof redis-cli redis-server
redis-benchmark redis-check-rdb redis-sentinel
7. Copy the redis.conf file under the uncompressed redis path to the installation path
[root@localhost ~]# cd redis-3.2.9
[root@localhost redis-3.2.9]# ll
total 208
-rw-rw-r-- 1 root root 87407 May 17 2017 00-RELEASENOTES
-rw-rw-r-- 1 root root 53 May 17 2017 BUGS
-rw-rw-r-- 1 root root 1805 May 17 2017 CONTRIBUTING
-rw-rw-r-- 1 root root 1487 May 17 2017 COPYING
drwxrwxr-x 7 root root 4096 Jan 12 19:21 deps
-rw-rw-r-- 1 root root 11 May 17 2017 INSTALL
-rw-rw-r-- 1 root root 151 May 17 2017 Makefile
-rw-rw-r-- 1 root root 4223 May 17 2017 MANIFESTO
-rw-rw-r-- 1 root root 6834 May 17 2017 README.md
-rw-rw-r-- 1 root root 46695 May 17 2017 redis.conf
-rwxrwxr-x 1 root root 271 May 17 2017 runtest
-rwxrwxr-x 1 root root 280 May 17 2017 runtest-cluster
-rwxrwxr-x 1 root root 281 May 17 2017 runtest-sentinel
-rw-rw-r-- 1 root root 7606 May 17 2017 sentinel.conf
drwxrwxr-x 2 root root 4096 Jan 12 19:22 src
drwxrwxr-x 10 root root 4096 May 17 2017 tests
drwxrwxr-x 7 root root 4096 May 17 2017 utils
[root@localhost redis-3.2.9]# cp redis.conf /usr/local/redis
[root@localhost local]# cd /usr/local/redis
[root@localhost redis]# ll
total 56
drwxr-xr-x 2 root root 4096 Jan 12 15:52 bin
-rw-r--r-- 1 root root 90 Jan 12 16:34 dump.rdb
-rw-r--r-- 1 root root 46696 Jan 12 15:53 redis.conf
[root@localhost redis]# cd bin/
[root@localhost bin]# ls
dump.rdb redis-check-aof redis-cli redis-server
redis-benchmark redis-check-rdb redis-sentinel
8. Start Redis
The first method:
[root@localhost bin]# ./redis-server
The following is displayed:
In fact, it has been started successfully, but it belongs to front-end startup. After starting redis, our console can't perform any operations. Start can only be stopped by ctrl+c.
The second method:
Backend start
First edit redis.conf
[root@localhost redis]# vim redis.conf
Find daemonize no and change it to yes
Restart
[root@localhost redis]# ./bin/redis-server ./redis.conf
//Load configuration file here
80167:C 30 Jul 16:01:58.145 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
80167:C 30 Jul 16:01:58.145 # Redis version=4.0.1, bits=64, commit=00000000, modified=0, pid=80167, just started
80167:C 30 Jul 16:01:58.145 # Configuration loaded
You can view processes:
[root@localhost bin]# ps -ef | grep -i redis
root 130477 1 0 19:51 ? 00:00:00 ./bin/redis-server 127.0.0.1:6379
root 130559 130412 0 19:58 pts/0 00:00:00 grep -i redis
Description started.
Command to close Redis:
[root@localhost redis]# ./bin/redis-cli shutdown
3, Simple use:
[root@localhost redis]# ./bin/redis-cli
//Check if the network can
127.0.0.1:6379> ping
PONG
//Set a key value pair
127.0.0.1:6379> set name xiaoyao
OK
//Get the key value pair just set
127.0.0.1:6379> get name
"xiaoyao"
//View all keys
127.0.0.1:6379> keys *
1) "name"
//Delete name
127.0.0.1:6379> del name
(integer) 1
127.0.0.1:6379> keys *
(empty list or set)
127.0.0.1:6379>
Now you have completed the installation and startup of Redis.