In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you what the role of Redis configuration items, I believe that most people do not know much, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Today we will see what the Redis.conf configuration items do. If you want to make good use of a tool, configuration content is the foundation.
Daemonize no
Redis does not run as a daemon by default. You can use this configuration item to enable the daemon using yes (no is not supported by Windows)
Pidfile / var/run/redis.pid
When Redis runs as a daemon, Redis writes pid to the / var/run/redis.pid file by default, which can be specified through pidfile
Port 6379
Specify the Redis listening port, and the default port is 6379. In a blog post, the author explains why 6379 is chosen as the default port, because 6379 has the number corresponding to MERZ on the phone button, and MERZ is named after Italian singer Alessia Merz.
Bind 127.0.0.1
Bound host address
Timeout 300
When the client is idle for how many seconds, the connection is closed. If specified as 0, the function is turned off.
Loglevel notice
Specifies the logging level. Redis supports a total of four levels: debug, verbose, notice, and warning. The default is notice.
Logfile stdout
The logging method defaults to standard output. If Redis is configured to run in daemon mode, and the logging mode is configured here as standard output, the log will be sent to / dev/null (representing an empty device file, which is equivalent to a write-only file, and all contents written to it will be lost forever. If you try to read from it, you can't read anything.)
Databases 16
Set the number of databases. The default database is 0. You can use the SELECT command to specify the database id on the connection.
Save
< seconds > < changes >Specify how long and how many update operations will synchronize the data to the data file, which can be matched by multiple conditions.
Three conditions are provided in the Redis default configuration file:
Save 9001 means 1 change in 900 seconds (15 minutes)
Save 30010 means 10 changes in 300 seconds (5 minutes)
Save 60 10000 means 10000 changes in 60 seconds
Rdbcompression yes
Specify whether to compress data when stored in the local database. The default is that yes,Redis uses LZF compression. If you want to save CPU time, you can turn this option off, but it will cause the database file to become huge.
Dbfilename dump.rdb
Specifies the local database file name, which defaults to dump.rdb
Dir. /
Specify the local database storage directory
Slaveof
< masterip > < masterport >Set the IP address and port of the master service when the machine is a slave service. When Redis starts, it automatically synchronizes data from master.
Masterauth
< master-password >When the master service is password protected, the password of the slave service connection master
Requirepass foobared
Set the Redis connection password. If the connection password is configured, the client needs to connect through AUTH when connecting to Redis.
< password >Command provides the password, which is turned off by default
Maxclients 128
Set the maximum number of client connections at a 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 Redis processes. 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
< bytes >Specify the maximum memory limit of Redis. Redis will load data into memory at startup. After reaching the maximum memory, Redis will first try to clear the expired or expiring Key. When this method is processed, the maximum memory setting will still be reached, and the write operation will no longer be performed, but the read operation can still be performed. Redis's new vm mechanism stores Key in memory and Value in swap area.
Appendonly no
Specifies whether to log after each update operation. Redis writes data to disk asynchronously by default. If it is not enabled, it may result in data loss for a period of time in the event of a power outage. Because redis itself synchronizes data files according to the above save conditions, some data will only exist in memory for a period of time. Default is no
Appendfilename appendonly.aof
Specify the update log file name. Default is appendonly.aof.
Appendfsync everysec
Specify the update log condition. There are 3 optional values:
No: indicates that the operating system synchronizes the data cache to disk (fast)
Always: means to manually call fsync () after each update operation to write data to disk (slow, secure)
Everysec: indicates synchronization once per second (eclectic, default)
Vm-enabled no
Specify whether to enable the virtual memory mechanism. The default is no. In a brief introduction, the VM mechanism stores the data in pages. Redis will swap the cold data on the disk, which is less visited, and the visited pages will be automatically swapped out to memory by the disk (I will carefully analyze the VM mechanism of Redis in a later article)
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
All data larger than vm-max-memory is stored in virtual memory, no matter how small the vm-max-memory setting is, all index data is stored in memory (Redis's index data is keys), that is, when vm-max-memory is set to 0, all value actually exists on disk. Default value is 0
Vm-page-size 32
Redis swap files are divided into many page. An object can be stored on multiple page, but a page cannot be shared by multiple objects. Vm-page-size should be set according to the size of stored data. The author suggests that if many small objects are stored, the page size should be set to 32 or 64bytes. If you store a lot of large objects, you can use a larger page. If you are not sure, use the default value.
Vm-pages 134217728
Set the number of page in the swap file, because the page table (a bitmap that indicates that the page is idle or used) is placed in memory, every 8 pages on disk will consume the memory of 1byte
Vm-max-threads 4
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, which may cause a long delay. The default value is 4
Glueoutputbuf yes
Sets whether to merge smaller packets into a single packet when replying to the client. Default is on.
Hash-max-zipmap-entries 64 hash-max-zipmap-value 512
Specifies that a special hash algorithm is used when the number of elements exceeds a certain number or the largest element exceeds a critical value.
Activerehashing yes
Specifies whether to activate the reset hash. Default is on.
Include / path/to/local.conf
Specify to include other profiles that can use the same profile between multiple Redis instances on the same host, while each instance has its own specific profile
The above is all the content of the article "what is the purpose of Redis configuration items". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.