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

03 redis profile interpretation

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

Share

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

# General configuration

Whether daemonize no # runs as a daemon, default is no, change to yes will generate a pid file. Pidfile / var/lib/redis.pid # if running as a background process, you need to specify a pid, which defaults to / var/run/redis.pid. Bind 127.0.0.1 # bind host IP. Default is 127.0.0.1. You can have multiple port 6379 # redis default listening ports unixsocket / tmp/redis.sock # or you can listen to socket unixsocketperm 755 # when listening to sockets, you can specify permissions of 755 timeout 300 # after the client is idle for how many seconds, the link is disconnected. Default is 300 seconds. If 0 means to disable the function, never turn off the tcp-keepalive 0 # TCP connection survival policy, you can set it through the tcp-keepalive configuration item (in seconds). If it is set to 60 seconds, the server side will launch an ACK request to the client # whose connection is idle every 60 seconds to check whether the client has hung up. For unresponsive clients, it will close its connection. If set to 0, it will close its connection. No survival test will be carried out. Loglevel verbose # logging level, with 4 optional values, debug,verbose (default), notice,warning. Logfile stdout # specifies the file name of the log output, which defaults to standard output stdout, or can be set to / dev/null mask log syslog-ident redis # if you want the log to be printed to syslog, it can be controlled by 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 database 16 # available database. The default value is 16, the default database is 0 maxclients select database, and 0-15 maxclients 128 # sets the maximum number of client connections at the same time. By default, there is no limit. The number of client connections that Redis can open at the same time # is the maximum number of file descriptors that can be opened by the Redis process. If you set maxclients 0, there is no limit. 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 # specifies the maximum memory limit of Redis. Redis will load the data into memory at startup. After reaching the maximum memory #, Redis will first try to clear the expired or expiring Key. After this method is processed, the maximum memory setting will still be reached, and the write operation can no longer be performed, but the read operation can still be performed. Redis's new vm mechanism stores Key in memory, and Value is stored in swap area slowlog-log-slower-than 10000 # unit: microseconds (microsecond,1 seconds = 1000000 microseconds) client-output-buffer-limit slave 256mb 64mb 60 # time when sending rdb to slave, buffer limit. Client-output-buffer-limit pubsub 32mb 8mb 60 # time, buffer limit when sending data to subscribers.

# persistence-RDB

Save 9001 # means that every 900s and at least one key change triggers a persistence

Save 30010 # means that every 300 seconds and at least 10 key changes, a persistence is triggered

Save 60 10000 # means that persistence is triggered every 60 seconds and at least 10000 key changes

Save "" # this disables rdb persistence

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

Rdbcompression yes # specifies whether to compress data when stored in the local database. By default, yes,redis uses LZF compression, if

# to save CPU time, you can turn off the change option, but it will cause the database file to become huge.

Rdbchecksum yes # whether to perform data verification

Dbfilename dump.rdb # specifies the file name of the local database. The default value is dump.rdb. It is best to add an absolute path. If you do not add

# is in the home directory of the startup user.

Dir / var/lib/redis/ # Local database storage path. Default is. /

# persistence-AOF

Appendonly no # specifies whether to log after each update operation, and Redis writes data asynchronously by default

# disk, if not opened, may result in data loss for a period of time during a power outage. Because redis itself synchronizes data files by pressing

# the above save conditions are synchronized, so some data will only exist in memory for a period of time. The default is no.

Appendfilename "appendonly.aof" # specifies the aof update log file name, which is saved in the directory specified by the dir parameter

Appendfsync everysec # specify update log conditions (no: indicates that operating systems such as data cache are synchronized to disk (fast)

# always: means to manually call fsync () after each update operation to write data to disk (slow, secure)

# everysec: synchronizes once per second (eclectic, default).

No-appendfsync-on-rewrite no # uses no 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 indicates 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

# replication configuration of replication-redis

Slave of # set the IP and port of the master server of the master-slave server

Masterauth # set the link password of the master server when the machine is a slave service

# AUTH command provides the password, which is turned off by default

Slave-read-only yes / / make slave read-only

Repl-ping-slave-period 10 / / sets the frequency at which slave initiates ping to master, once every 10 seconds

Repl-timeout 60 / / time out after setting slave ping to disable master for how many seconds

Repl-disable-tcp-nodelay no / / whether to enable tcp_nodelay. When enabled, less bandwidth will be used, but there will be delay, so it is recommended to disable it.

The length of the repl-backlog-size 1mb / / synchronization queue. Backlog is a buffer of master. After the master and slave are disconnected, master will first write the data to the buffer, and salve will synchronize the data from the buffer after connecting again.

Repl-backlog-ttl 3600 / / the validity period of the buffer after master-slave disconnection. Default is 1 hour.

Slave-priority 100 / / multiple slave can be set priority. The smaller the value, the higher the priority. It can be used in the cluster. Salve can be switched to master, and the highest priority will be switched.

Min-slaves-to-write 3 / / is used in conjunction with the following, which means that master finds that there are more than 3 slave with a delay of more than 10s, then master temporarily stops writing. If either of these two values is 0, the feature is turned off. The default first value is 0.

Min-slaves-max-lag 10

# redis security configuration

Requirepass foobared # sets the redis connection password. If the connection password is configured, the client needs to connect to redis.

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.

# virtual memory virtual memory

Vm-enabled no # specifies whether the virtual memory mechanism is enabled. The default value is no,VM mechanism for paging data storage, and Redis for traffic.

# fewer pages, that is, cold data, swap to disk, and pages with more visits are automatically swapped out to memory by disk (I will analyze them in detail in the following article

# VM mechanism of Redis)

Vm-swap-file / tmp/redis.swap # Virtual memory file path. Default is / tmp/redis.swap, which cannot be shared by multiple Redis instances.

Vm-max-memory 0 # stores all data larger than vm-max-memory in virtual memory, no matter how small the vm-max-memory setting

# Index data is stored in memory (Redis's index data is keys), that is, when vm-max-memory is set to 0, it is actually

# all value exist on disk. The default value is 0.

Vm-page-size 32 # Redis swap file is divided into many page. An object can be saved on multiple page, but on one page.

# cannot be shared by multiple objects. Vm-page-size should be set according to the size of the stored data. The author suggests that if many small objects are stored

# page size is best set to 32 or 64 bytes; if you store large objects, you can use a larger page, if you are not sure

# use the default value.

Vm-pages 134217728 # sets the number of page in the swap file, because the page table (a bitmap that indicates that the page is idle or used)

# is in memory, and every 8 pages on disk will consume 1byte's memory

Vm-max-threads 4 # sets the number of threads accessing swap files. It is best not to exceed the number of cores of the machine. If set to 0, then all

# all operations on swap files are serial, which may cause a long delay. The default value is 4

Note: the official Redis documentation makes some recommendations for the use of VM:

When your key is small and your value is large, the effect of using VM is better. Because the memory saved in this way is larger.

When your key is not small, consider using some unusual methods to turn a large key into a large value. For example, you can consider combining key,value into a new value.

It is best to use linux ext3 and other file systems that support sparse files to save your swap files.

Vm-max-threads this parameter, you can set the number of threads to access the swap file, it is best not to exceed the number of cores of the machine. If set to 0, then all operations on the swap file are serial. It may cause a long delay, but there is a good guarantee for data integrity.

# slow log

For slow logs, you can set two parameters, one is the execution time, the unit is subtle, 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

# Master / Slave configuration

# advanced config

Glueoutbuf yes # sets whether to merge smaller packets into a single packet when replying to the client. Default is on.

Hash-max-zipmap-entries 64 # specifies that a special hash algorithm is used when more than a certain number

Hash-max-zipmap-value 512 # specifies a special hashing algorithm when the largest element exceeds a certain critical value.

Whether activerehashing yes # resets the Hash table and specifies whether to activate the reset hash. Default is on (Redis is described later.

The hash algorithm of # is introduced.

Include / path/to/local.conf # specifies that it contains additional configuration files that can be used between multiple Redis instances on the same host

# use the same profile, while each instance has its own specific profile

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