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-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Bind 0.0.0.0 # binds the redis server network card IP. The default is 127.0.0.1, that is, the local loopback address. In this way, access to the redis service can only be through a local client connection, not through a remote connection. If the bind option is empty, all connections from available network interfaces are accepted.

Setting protected-mode no # to yes means that the specified Redis starts as a daemon (background startup). The default value is no

Port 7007

Tcp-backlog 511

Timeout 0 # sets the timeout for client connections in seconds. When the client does not issue any instructions during this period, then close the connection. The default value is 0, which means that it is not turned off.

Tcp-keepalive 300 # unit is seconds, which means that SO_KEEPALIVE will be used periodically to check whether the client is still in a healthy state to prevent the server from blocking all the time. The official recommended value is 300s. If set to 0, it will not be detected periodically.

Whether daemonize yes # runs in the background and yes runs in the background; no does not run in the background

Supervised no

Pidfile "/ u01/redis/7007/pid/redis_7007.pid" # redis process file path

Loglevel warning # loglevel: defines the log level. The default value is notice, and the following four values are available:

Debug (record a large amount of log information, suitable for development and testing phases)

Verbose (more log information)

Notice (appropriate amount of log information, used in production environment)

Warning (only some important and critical information will be recorded)

Logfile "/ u01/redis/7007/log/redis_7007.log" # redis log file path

Masterauth "ysBhqkYHDifB" #

Requirepass "ysBhqkYHDifB" #

Databases 16 # sets the number of databases. The default database is DB 0, and you can use the select command to select a different database on each connection. Dbid is a value between 0 and databases-1. The default value is 16, which means that the default Redis has 16 databases.

Stop-writes-on-bgsave-error yes # defaults to yes. Whether Redis stops receiving data when RDB is enabled and the last time the data is saved in the background fails. This will make the user realize that the data is not correctly persisted to disk, otherwise no one will notice that a disaster has occurred. If Redis is restarted, you can start receiving data again.

Rdbcompression yes # defaults to yes. For snapshots stored on disk, you can set whether to compress storage. If so, redis uses the LZF algorithm for compression. If you don't want to consume CPU for compression, you can set this feature to off, but the snapshots stored on disk will be larger.

Rdbchecksum yes # defaults to yes. "after storing the snapshot, we can also have redis use the CRC64 algorithm for data validation, but doing so increases performance consumption by about 10%, which can be turned off if you want to get the maximum performance improvement."

Dbfilename "redis_7007_dump.rdb" # sets the file name of the snapshot. Default is dump.rdb.

Dir "/ u01/redis/7007/data" # sets the path where snapshot files are stored. This configuration item must be a directory, not a file name. Use the above dbfilename as the saved file name.

Slave-serve-stale-data yes # defaults to yes. When a slave loses contact with master, or when replication is in progress, slave may behave in two ways:

1) if yes, slave will still answer the client request, but the data returned may be outdated, or the data may be empty at the time of the first synchronization

2) if no, slave will return a "SYNC with master in progress" error when you execute any command other than info he salveof

Slave-read-only yes # configures whether the Slave instance of Redis accepts write operations, that is, whether Slave is read-only Redis. The default is yes.

Whether repl-diskless-sync no # master-slave data replication uses no hard disk replication function. The default is no.

Repl-diskless-sync-delay 5 # when no hard disk backup is enabled, the server waits for a period of time before sending RDB files to the slave through the socket. This wait time is configurable. This is important because once the transmission starts, it is no longer possible to serve a newly arrived slave station. The slave station is queued for the next RDB transmission. So the server waits for a period of time to expect more slave stations to arrive. The delay time is in seconds, and the default is 5 seconds. To turn off this feature, simply set it to 0 seconds and the transfer will start immediately. The default value is 5.

Whether to disable TCP_NODELAY on the slave station after repl-disable-tcp-nodelay no # synchronization if you choose yes,redis, you will use less TCP packets and bandwidth to send data to the slave station. But this will lead to a little bit of data delay in the slave station. The delay is up to 40 milliseconds in the default configuration of the Linux kernel. If you choose no, the data latency of the slave station will be less, but the backup will require relatively more bandwidth. We optimize the potential factor by default, but it's a good idea to switch it to yes under high load or when both master and slave stations jump. The default is no.

Slave-priority 100 #

Min-slaves-to-write 0

Min-slaves-max-lag 10

Maxmemory 2gb # sets the maximum number of concurrent client connections. By default, there is no limit. The number of client connections that Redis can open at the same time is the maximum number of files that can be opened by the Redis process. Number of descriptors-32 (some will be used by redis server itself), if maxclients is set to 0. Means there are no restrictions. When the number of client connections reaches the limit, Redis closes the new connection and returns a max number of clients reached error message to the client.

Maxmemory-policy volatile-lru # clear policy used by redis when memory usage reaches its maximum. There are several options:

1) volatile-lru uses the LRU algorithm to remove the key that sets the expiration time (LRU: recently used Least Recently Used)

2) allkeys-lru uses LRU algorithm to remove any key

3) volatile-random removes the random key that sets the expiration time

4) allkeys-random removes random ke

5) volatile-ttl removes the expired key (minor TTL)

6) noeviction noeviction does not remove any key, but returns a write error. The default option is

Appendonly no # default redis uses rdb persistence, which is sufficient in many applications. However, if the redis goes down midway, it may result in a few minutes of data loss. Persistence is based on save strategy. Append Only File is another persistence method, which can provide better persistence characteristics. Redis will write the data written each time into the appendonly.aof file after receiving. Every time Redis starts, it will read the data of this file into memory and ignore the RDB file first. The default is no.

Appendfilename "appendonly.aof" # aof file name, default is "appendonly.aof"

Appendfsync everysec # aof persistence policy configuration; no: do not execute fsync, and the operating system ensures that data is synchronized to disk, which is the fastest; always: execute fsync every write to ensure data synchronization to disk; everysec: execute fsync once per second, which may result in the loss of 1s of data

No-appendfsync-on-rewrite no # executes a large number of IO when aof is rewritten or written to a rdb file. For aof modes of everysec and always, executing fsync causes blocking for too long, and the no-appendfsync-on-rewrite field is set to no by default. For applications with high latency requirements, this field can be set to yes, otherwise it can be set to no, which is a more secure option for persistence features. Set to yes means that the new write operation is not fsync during rewrite and is temporarily stored in memory until the rewrite is completed. Default is no. Yes is recommended. The default fsync policy for Linux is 30 seconds. Data may be lost for 30 seconds. The default is no.

The default value for auto-aof-rewrite-percentage 100 is 100. Aof automatically rewrites the configuration, when the current aof file size exceeds how many percent of the last rewritten aof file size, that is, when the aof file grows to a certain size, Redis can call bgrewriteaof to rewrite the log file. When the current AOF file size is twice the size of the AOF file obtained from the last log rewrite (set to 100), a new log rewrite process is automatically started.

Auto-aof-rewrite-min-size 64mb # sets the minimum aof file size that is allowed to be rewritten, avoiding rewriting when the agreed percentage is reached but the size is still very small.

The aof-load-truncated yes # aof file may be incomplete at the end, and when redis starts, the data from the aof file is loaded into memory. Restart may occur after the operating system of the host where the redis is located goes down, especially if the ext4 file system does not add the data=ordered option. If the redis goes down or terminates abnormally, it will not cause tail incompleteness. You can choose to let redis exit or import as much data as possible. If yes is selected, when the truncated aof file is imported, a log is automatically published to the client and then load. In the case of no, the user must manually redis-check-aof to repair the AOF file. The default is yes.

Lua-time-limit 5000 # the maximum time in ms for the execution of a lua script. The default value is 5000.

Cluster-enabled yes # cluster switch. Cluster mode is not enabled by default.

Cluster-config-file "nodes-7007.conf" # the name of the cluster configuration file. Each node has a cluster-related configuration file that persists the cluster information. This file does not need to be manually configured, this configuration file is generated and updated by Redis, and each Redis cluster node requires a separate configuration file. Make sure that the name of the configuration file does not conflict with the system on which the instance is running. The default configuration is nodes-6379.conf.

Cluster-node-timeout 15000 # can be configured with a value of 15000. Threshold of node interconnection timeout, number of cluster node timeout milliseconds

Slowlog-log-slower-than 10000 #

Slowlog-max-len 128

Latency-monitor-threshold 0

Notify-keyspace-events ""

Hash-max-ziplist-entries 512

Hash-max-ziplist-value 64

List-max-ziplist-size-2

List-compress-depth 0

Set-max-intset-entries 512

Zset-max-ziplist-entries 128

Zset-max-ziplist-value 64

Hll-sparse-max-bytes 3000

Activerehashing yes

Client-output-buffer-limit normal 0 0 0

Client-output-buffer-limit slave 0 0 0

Client-output-buffer-limit pubsub 32mb 8mb 60

Hz 10

Aof-rewrite-incremental-fsync yes

# Generated by CONFIG REWRITE

Cluster-require-full-coverage no # by default, the node is responsible for all the slot of the cluster, and the cluster status is ok before services can be provided. Set to no to provide services when the slot is not fully allocated. It is not recommended to open this configuration, as this will cause the master of a small partition to accept write requests all the time, resulting in data inconsistency for a long time.

# # LAZYFREE

Lazyfree-lazy-eviction yes

Lazyfree-lazy-expire yes

Lazyfree-lazy-server-del yes

Repl-timeout 600

Cluster-migration-barrier 0 # can be configured with a value of 1. Only when the number of slave of master is greater than this value can slave be migrated to other isolated master. For example, if this parameter is set to 2, only if a master node has two working slave nodes, one of its slave nodes will try to migrate.

Cluster-slave-validity-factor 600 # can be configured with a value of 10. During a failover, all slave requests to be master, but some slave may be disconnected from master for some time, resulting in data that is too stale and such slave should not be promoted to master. This parameter is used to determine whether the disconnection between the slave node and the master is too long. The judgment method is: compare the slave disconnection time with (node-timeout * slave-validity-factor) + repl-ping-slave-period if the node timeout time is 30 seconds and slave-validity-factor is 10, assume that the default repl-ping-slave-period is 10 seconds, that is, if it exceeds 310 seconds, slave will not attempt to fail over

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