In depth understanding of the building of Redis single machine environment of Redis series

Preface

In the process of actual development projects, if we want to use cache, the first thing we think about is Redis. But why most people choose Redis is not able to understand or think about it. They only know that it can be used as cache, which is faster than the database. I happen to be such a person. So when I want to write an introduction to Redis, I can't even talk about it. This is also true For the reason that Redis and the mainstream memory database are not familiar with each other; however, in the future, we must increase our thinking and in-depth understanding of the framework, so that we can settle down on the technical road behind. I hope that when someone asks me to briefly introduce Redis in the future, I won't be unable to talk about it. Maybe that's the purpose of writing Redis series blog!

I. Redis environment construction

Download redis stable

curl -o redis.tar.gz http://download.redis.io/releases/redis-stable.tar.gz

Extract redis package

tar -zxvf redis-stable.tar.gz -C ./ // This command means unpacking the tar.gz package to the current directory

Compile and install redis

Enter the directory of the extracted Redis, and use the following command to compile and install Redis

sudo make && make install PREFIX=/usr/local/redis

Edit configuration Redis profile

sudo cp redis.conf /usr/local/redis/conf/

Start Redis service

./redis-server ../conf/redis.conf  & //Running in the background at startup

Start output log:

45894:C 02 Nov 2018 22:11:19.922 # Redis version=5.0.0, bits=64, commit=00000000, modified=0, pid=45894, just started
45894:C 02 Nov 2018 22:11:19.922 # Configuration loaded
45894:M 02 Nov 2018 22:11:19.924 * Increased maximum number of open files to 10032 (it was originally set to 256).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 5.0.0 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 45894
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

45894:M 02 Nov 2018 22:11:19.933 # Server initialized
45894:M 02 Nov 2018 22:11:19.933 * Ready to accept connections

Verify Redis service

Using telnet to verify

terrydeMacBook-Air:bin terrylmay$ telnet 127.0.0.1 6379
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.

Use system process ps authentication

terrydeMacBook-Air:bin terrylmay$ ps -ef | grep redis
  501 45894 44430   0 10:11 Afternoon ttys000    0:00.04 ./redis-server 127.0.0.1:6379 //One is Redis service
  501 45897 44430   0 10:11 Afternoon ttys000    0:00.00 grep redis //ps query process itself

Here, a stand-alone version of Redis service is built!

II. Use Redis to store data

Redis CLI connects to redis service

terrydeMacBook-Air:bin terrylmay$ ./redis-cli
127.0.0.1:6379> 
127.0.0.1:6379> set name terrylmay
OK
127.0.0.1:6379> get name 
"terrylmay"
127.0.0.1:6379> 

Now, we can use Redis system to store data string data

Keywords: Database Redis sudo curl

Added by craig1978 on Wed, 11 Dec 2019 17:53:23 +0200