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

Redis configuration explanation

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

The installation of redis has been introduced earlier, and then the configuration parameters of redis are briefly introduced.

1.Redis Universal configuration

Daemonize no # by default, redis does not run as daemon. The running form of redis can be controlled through the daemonize configuration item.

Pidfile / path/to/redis.pid # when running as daemon, redis generates a pid file, which is generated by default in / var/run/redis.pid

Bind 192.168.1.2 10.8.4.2 # specifies the bound ip, which can have multiple

Port 6379 # specify listening port

Unixsocket / tmp/redis.sock # can also listen to socket

Unixsocketperm 755 # when listening to sockets, you can specify permissions of 755

Timeout 0 # when a redis-client has not sent a request to the server, then the server has the right to actively close the connection. You can set the "idle timeout" through timeout. 0 means never close.

The tcp-keepalive 0 # TCP connection survival policy can be set through the tcp-keepalive configuration item (in seconds). If it is set to 60 seconds, the server will issue an ACK request to the client whose connection is idle every 60 seconds to check whether the client has hung up, and the client that does not respond will close its connection. If set to 0, no survival test will be performed.

Loglevel notice # log level, there are four types of debug, verbose, notice, warning

Logfile "" # define log path

Syslog-identredis # if you want the log to be printed to syslog, you can control it through syslog-enabled. In addition, syslog-ident allows you to specify log flags in syslog.

Syslog-facility local0 # specifies the device of syslog, which can be USER or local0-local7

Databases 16 # sets the total number of databases

2.Redis snapshot configuration (rdb persistence)

Save 9001 # means that persistence is triggered every 15 minutes and at least one key change

Save 30010 # means that persistence is triggered every 5 minutes and at least 10 key changes

Save 60 10000 # means that at least 10000 key changes occur every 60 seconds, triggering a persistence

Save "" # this disables rdb persistence

Stop-writes-on-bgsave-error yes # rdb persistent writing to disk cannot avoid failure. By default, redis stops the write operation immediately if it fails. If you think it doesn't matter, you can use this option to turn off this feature.

Does rdbcompression yes # want to compress

Rdbchecksum yes # whether to perform data verification

Dbfilename dump.rdb # defines the name of the snapshot file

Dir. / # define snapshot file storage drive

3.Redis Security related configuration

Requirepassaminglinux # set the password for redis-server

Rename-command CONFIG aminglinux.config # renames the CONFIG command to aminglinux.config to avoid misoperation, but it is not recommended to enable this feature if AOF persistence is used

Rename-command CONFIG "" # can also be later defined as empty, thus disabling the CONFIG command

4.Redis restrictions related configuration

Maxclients 10000 # limit the maximum number of client connections

Maxmemory # sets the maximum memory usage (in byte)

Maxmemory-policy volatile-lru # specify memory removal rules

The maxmemory-samples 3 # LRU algorithm and the minimum TTL algorithm are not exact algorithms, but estimates. So you can set the sample size. If redis checks the three key by default and selects the one of the LRU, then you can change the number of key samples.

5.Redis AOF persistence related configuration

Appendonly no # if it is yes, enable aof persistence

Appendfilename "appendonly.aof" # specify the aof file name

Appendfsync everysec # specifies the fsync () invocation mode. There are three kinds of no (no fsync is called), always (fsync is called every time you write), and everysec (fsync is called once per second). The first is the fastest, the second is the most secure, but the performance is worse, and the third is this scheme, which defaults to the third.

No-appendfsync-on-rewrite no # sets yes to avoid disk io blocking when the write load is very large

Auto-aof-rewrite-percentage 10 # specifies when aof rewriting will be triggered. The value is a ratio, and 10 means that the rewriting mechanism will be triggered when the growth of the aof file reaches 10%.

Auto-aof-rewrite-min-size 64mb # rewriting will be subject to a condition that it cannot be lower than 64Mb

6.Redis slow log related configuration

For slow logs, you can set two parameters, one is the execution time, in milliseconds, and the other is the length of the slow log. When a new command is written to the log, the oldest one is removed from the command log queue.

Slowlog-log-slower-than 10000 # if slower than 10000ms, log

Slowlog-max-len 128 # Log length

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