Introduction to Redis and detailed configuration files

1. Introduction to Redis

1. Redis is completely open source and free. It complies with the BSD protocol and is a high-performance (NOSQL) key-value database. Redis is an open source log type that is written in ANSI C language, supports the network, and can be based on memory and can be persisted. , Key-Value database, and provide APIs in multiple languages.

NoSQL, generally refers to non-relational databases.
NoSQL databases were created to solve the challenges brought by multiple data types in large-scale data collections, especially the problems of big data applications.

2. Four categories of NoSQL databases
Key-Value storage database
Column storage database
Document database
Graph database

3. Redis and other key-value caching products have the following three features.
Redis supports data persistence. The data in the memory can be saved in the disk, and it can be loaded again for use when restarting.
Redis not only supports simple key-value type data, but also provides storage for list, set, zset, hash and other data structures.
Redis supports high availability functions such as data backup and clustering.

Redis features:
extremely high performance-Redis can read at 110,000 times/s and write at 81,000 times/s.
Rich data types-Redis supports String, List, Hash, Set and Ordered Set data type operations.
Atomic-All Redis operations are atomic, which means that they either succeed or fail at all. A single operation is atomic. Multiple operations also support transactions, that is, atomicity, packaged by MULTI and EXEC instructions.
Rich features-Redis also supports publish/subscribe, notification, key expiration and other features.

Redis is a simple, efficient, distributed, memory-based caching tool.

Redis summarizes
redis single key is stored in 512M size
redis supports multiple types of data structures (string, list, hash.set.zset)
redis is a single-threaded atomic
redis can be persistent because it uses RDB and AOF mechanisms
redis supports clusters and redis Support library (0-15) 16 libraries
redis can also be used as message queue such as chat room IM

Redis advantages and disadvantages:
advantages:
(1) rich data structure
(2) high-speed read and write, redis uses its own implementation of the separator, the amount of code is very short, no lock (MySQL), so the efficiency is very high.

Disadvantages:
(1) Persistence. Redis directly stores data in memory. To save data to disk, Redis can implement the persistence process in two ways. Timed snapshot (snapshot): The entire database is written to disk at regular intervals, and all data is written each time, which is very costly. The second method is based on statement addition (aof): only track the changed data, but the added log may be too large, and all operations are executed again, and the response speed is slow.
(2) Memory consumption, which is too high.

ps -ef | grep -i redis View the service started by redis

Redis configuration and redis.conf configuration file detailed explanation

The configuration file of Redis is redis.conf in the decompressed file

Introduction to redis.conf configuration items

(1) Redis default is no, change to yes to enable
daemonize no
(2) Specify the Redis listening port, the default port is 6379
port 6379
(3) The bound host address
bind 127.0.0.1
(4) When the client is idle a lot Close the connection after a long time. If 0 is specified, it means the function is closed.
timeout 300

(5) Specify how long and how many update operations to synchronize the data to the data file. Multiple conditions can be matched with the
save
Redis default configuration file. Three conditions are provided:
save 900 1
save 300 10
save 60 10000
It means that there are 1 change in 900 seconds (15 minutes), 10 changes in 300 seconds (5 minutes), and 10,000 changes in 60 seconds.

(6) Set the Redis connection password, and
requirepass foobared is closed by default

(7) Specify the local database file name, the default value is dump.rdb
dbfilename dump.rdb

(8) Specify the local database storage directory
dir ./

Guess you like

Origin blog.csdn.net/qq_42524288/article/details/105485862