Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Detailed explanation of redis- configuration file

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

1. Basic configuration

Whether daemonize no is started as a background process

Number of database created by databases 16 (database 0 is selected by default)

When save 9001 # refreshes the snapshot to the hard drive, both requirements must be met before it will be triggered, that is, at least 1 keyword will change after 900 seconds.

Save 30010 # must be at least 10 keywords changed after 300 seconds.

Save 60 10000 # must be at least 10000 keywords changed after 60 seconds.

Stop-writes-on-bgsave-error yes # background storage error stops writing.

Rdbcompression yes # uses LZF to compress rdb files.

Rdbchecksum yes # verifies when storing and loading rdb files.

Dbfilename dump.rdb # sets the rdb file name.

Dir. / # sets the working directory to which the rdb file is written.

two。 Master-slave configuration

Slaveof is set as a slave server for a machine

Password for masterauth to connect to the primary server

Slave-serve-stale-data yes # whether the slave server answers when the master / slave is disconnected or is in the process of replication

Slave-read-only yes # read-only from the server

Time interval between repl-ping-slave-period 10 # slave ping master (in seconds)

Repl-timeout 60 # master-slave timeout (the timeout is considered to be disconnected), which is larger than period

Slave-priority 100 # if master can no longer work properly, the slave with the lowest priority value will be selected among multiple slave to be promoted to master, and a priority value of 0 means that it cannot be promoted to master.

Whether the master end of repl-disable-tcp-nodelay no # merges data or not, send large chunks to slave

Slave-priority 100s from the priority of the server, when the master server dies, it will automatically pick the one with the smallest slave priority as the master server

3. Safety

Requirepass foobared # requires a password

Rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52 # if you have a public environment, you can rename some sensitive commands such as config

5. Limit

Maxclients 10000 # maximum connections

Maxmemory # maximum memory usage

Maxmemory-policy volatile-lru # memory processing after reaching the limit

Volatile-lru-> LRU algorithm deletes expired key

Allkeys-lru-> LRU algorithm deletes key (does not distinguish or expire)

Volatile-random-> randomly delete expired key

Allkeys-random-> randomly delete key (indistinguishable and non-expired)

Volatile-ttl-> Delete a key that is about to expire

Noeviction-> do not delete, error message is returned

# explain that LRU ttl are all approximate algorithms. You can choose N, and then compare the data that are most suitable for T kick.

Maxmemory-samples 3

6. Log mode

Appendonly no # whether only logs are required

Appendfsync no # system buffering, unified writing, high speed

Appendfsync always # system does not buffer, direct write, slow, less data loss

Appendfsync everysec # compromise, write once per second

If no-appendfsync-on-rewrite no # is yes, the data of other threads will be stored in memory and written together (faster and easier to lose)

Auto-AOF-rewrite-percentage 100th current aof file is overridden when the last override is large N%

At least the size of auto-AOF-rewrite-min-size 64mb aof rewriting

7. Slow query

Slowlog-log-slower-than 10000 # records slow queries with response time greater than 10000 microseconds

Slowlog-max-len 128 # record up to 128 entries

8. Server command

Time returns timestamp + microsecond

The number of key returned by dbsize

Bgrewriteaof rewrites aof

Bgsave background starts child process dump data

Save blocking process dump data

Lastsave

Slaveof host port acts as a slave server for host port (data emptying, copying new master content)

Slaveof no one becomes the master server (the original data is not lost, which is usually used after the failure of the main server)

Flushdb clears all data in the current database

Flushall clears all data from all databases (what if misused?)

Shutdown [save/nosave] shut down the server, save data, and modify AOF (if set)

Slowlog get acquires slow query log

Slowlog len acquires the number of slow query log entries

Slowlog reset empties slow query

Info []

Config get option (supports * wildcards)

Config set option valu

Config rewrite writes values to the configuration file

Config restart updates information for the info command

Debug object key # debugging options, depending on a key

Debug segfault # impersonation segment error, causing the server to crash

Object key (refcount | encoding | idletime)

Monitor # Open the console and observe the commands (for debugging)

Client list # lists all connections

Client kill # kills a connection CLIENT KILL 127.0.0.1 43501

Client getname # get the name of the connection default nil

Client setname "name" # sets the connection name for debugging

9. Connection command =

Auth password # password login (if there is a password)

Ping # Test whether the server is available

Echo "some content" # Test whether the server interacts properly

Select 0/1/2... # Select a database

Quit # exit the connection

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report