Redis has been linux-only since the beginning, and while there are teams working on Windows versions, I recommend you install Linux.

 

Preparations VMware and Xshell

https://redis.io/

 

Redis official installation tutorial, but relatively simple, not suitable for production environment installation and deployment;

Let’s be more specific,

 

Step 1: Install GCC

GCC compiles c, because redis is written in C, so we first install GCC

yum install gcc-c++

 

Step 2: Download the Redis package by wGET, decompress it, and compile it

download

Wget HTTP: / / http://download.redis.io/releases/redis-3.2.9.tar.gz

Unpack the

The tar – ZXVF redis – 3.2.9. Tar. Gz

 

[root@localhost ~]# ll

The total amount of 1548

-rw——-. 1 root root 1261 June 27 19:54 anaconda-ks.cfg

-rw-r–r–. 1 root root 25680 4月 27 18:45 mysql57-community-release-el7-11.noarch. RPM

Drwxrwxr-x. 6 root root 4096 May 17 23:39 redis-3.2.9

-rw-r–r–. 1 root root 1547695 May 17 23:40 redis-3.2.9.tar.gz

[root@localhost ~]# 

So there is redis in /root/

 

Compile:

CD redis – 3.2.9

Go to the directory,

make

compile

 

Step 3: Install Redis

make PREFIX=/usr/local/redis install

Installed in/usr/local/redis /

 

There has been a redis

[root@localhost local]# cd redis/

[root@localhost redis]# ll

The total dosage of 0

Drwxr-xr-x. 2 root root 134 July 2 16:44 bin

[root@localhost redis]# 

 

There’s a bin in redis

[root@localhost redis]# cd bin/

[root@localhost bin]# ll

The total amount of 15060

-rwxr-xr-x. 1 root root 2431832 7月   2 16:44 redis-benchmark

-rwxr-xr-x. 1 root root 25168 July 2 16:44 redis-check-aof

-rwxr-xr-x. 1 root root 5181840 July 2 16:44 redis-check-rdb

-rwxr-xr-x. 1 root root 2584848 July 2 16:44 redis-cli

Lrwxrwxrwx. 1 root root 12 7月 2 16:44 redis-sentinel -> redis-server

-rwxr-xr-x. 1 root root 5181840 July 2 16:44 redis-server

[root@localhost bin]# 

There are some tools in bin

 

CD back to root, we need to copy a configuration file to redis for background startup

[root@localhost redis-3.2.9]# cp redis.conf /usr/local/redis/

[root @ localhost redis – 3.2.9] # ll/usr/local/redis /

The total amount of 48

Drwxr-xr-x. 2 root root 134 July 2 16:44 bin

-rw-r–r–. 1 root root 46695 July 2 16:49 redis

[root @ localhost redis – 3.2.9] #

 

Step 4: Start and close the Redis service

To start redis, run the redis-server command in bin in redis

Go to the redis directory and execute

[root @ localhost redis – 3.2.9] # CD/usr/local/redis /

[root@localhost redis]# bin/redis-server

If this icon is displayed, the startup is successful.

 

However, this kind of start is front-end or foreground start, if exits the program terminates or exits.

So this kind of service program, you have to run it back end;

 

We do this by modifying the configuration file redis.conf

 

Operation,

CTRL + C exits the current program;

Vi redis. Conf vi/usr/local/redis/redis. Conf

find

Change no to yes

Esc to exit! Wq preservation;

 

Then enter the redis directory, and then load the configuration file to run;

[root@localhost ~]# cd /usr/local/redis/

[root@localhost redis]# ./bin/redis-server ./redis.conf 

 

We through the ps – ef | grep -i redis redis command to search service

[root@localhost redis]# ps -ef | grep -i redis

root       8692      1  0 16:52 ?        00:00:19 bin/redis-server *:6379

root       8954   8930  0 20:30 pts/0    00:00:00 grep –color=auto -i redi

[root@localhost redis]# 

 

We use the shutdown command to stop the Redis service

[root@localhost redis]# ./bin/redis-cli shutdown

[root@localhost redis]# ps -ef | grep -i redis

root       8959   8930  0 20:35 pts/0    00:00:00 grep –color=auto -i redi

[root@localhost redis]# 

 

 

Step 5: Basic use of Redis

The previous step has been closed, so restart the following:

[root@localhost redis]# ./bin/redis-server ./redis.conf 

[root@localhost redis]# ./bin/redis-cli

127.0.0.1:6379 >

Accessing the Client

We store name:java1234

Key: value format

127.0.0.1:6379 > set name java1234

OK

 

127.0.0.1:6379 > get the name

“java1234”

Set by set and get by GET

 

127.0.0.1:6379 > keys *

1) “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 >

 

Delete keys by del,keys * displays all keys