Redis installation, startup, and basic use

Redis installation, startup, and basic use

Redis overview

What is it

  1. Redis: REmote DIctionary Server (remote dictionary server)

  2. It is completely open source and free, written in C language, and complies with the BSD protocol. It is a high-performance (key/value) distributed memory database. It is a NoSQL database that runs on memory and supports persistence. It is currently one of the most popular NoSql databases. One, also known as data structure server

  3. Redis and other key-value caching products have the following three characteristics

    • Redis supports data persistence, which can keep the data in the memory on the disk, and load it again for use when restarting
    • Redis not only supports simple key-value data, but also provides storage for list, set, zset, hash and other data structures
    • Redis supports data backup, that is, data backup in master-slave mode

What can you do

  1. Memory storage and persistence: redis supports asynchronous writing of data in memory to the hard disk without affecting the continued service
  2. The operation of fetching the latest N data, such as: you can put the IDs of the latest 10 comments in the Redis List collection
  3. Simulate a function similar to HttpSession that needs to set the expiration time
  4. Publish and subscribe message system
  5. Timer, counter

Where to go

  1. Http://redis.io/

  2. Http://www.redis.cn/

How to play

  1. Data type, basic operation and configuration

  2. Persistence and replication, RDB/AOF

  3. Transaction control

  4. copy

Redis installation and basic use

Redis is commonly used on Linux systems, and the virtual machine needs to be set up before installation.

Therefore, only the Linux version is used here.

Use redis3.0 version

  1. After downloading and obtaining redis-3.0.4.tar.gz, put it into our Linux directory /opt (upload via xftp)

  2. In the /opt directory, decompress the command: tar -zxvf redis-3.0.4.tar.gz

  3. After the decompression is complete, a folder appears: redis-3.0.4

    Insert picture description here

  4. Enter the directory: cd redis-3.0.4

    Insert picture description here

  5. Execute the make command in the redis-3.0.4 directory

    Analysis of deliberate errors when running the make command:

    1. Need to install gcc, my mirror is centos6.8, install gcc refer to my previous install gcc blog.

    2. Secondary make

    3. Jemalloc/jemalloc.h appears: there is no such file or directory

      Solution: run make distclean and then make

    4. Redis Test (can not be executed) (It is better not to execute, waste time, useless!)

  6. If make is completed, continue to execute make install

    Insert picture description here

View the default installation directory: usr/local/bin

  1. Redis-benchmark: performance testing tool, you can run it in your own notebook to see how your own notebook performs

    Note: need to be executed after the service is started

start up

  1. Modify the redis.conf file to change the daemonize no to yes, and let the service start in the background

  2. Copy the default redis.conf to a path defined by yourself, such as /myredis,

  3. start up

    Insert picture description here

  4. test

    Insert picture description here

  5. Run redis-server in the /usr/local/bin directory, run to copy the redis.conf file in the directory where the custom conf file is stored

Helloworld forever

Insert picture description here

shut down

SHUTDOWN
Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_43215322/article/details/109477908
Recommended