Redis configuration file

Source: Internet
Author: User
Tags password protection strong password

http://blog.csdn.net/tonysz126/article/details/8280696/

2.1Redis configuration file in order to have a direct understanding of the REDIS system implementation, let's first look at what the main parameters are defined in the Redis configuration file and what these parameters do. 1) daemonize No by default, Redis is not running in the background. If you need to run in the background, change the value of the item to Yes;2) Pidfile/var/run/redis.pid when Redis is running in the background, Redis defaults to putting the PID filevar/run/Redis.pid, you can configure to a different address. When running multiple Redis services, you need to specify a different PID file and port;3Port 6379 Specifies the ports on which Redis runs, by default, 6379;4) bind127.0.0.1Specifies that Redis receives only requests from that IP address, and if not set, all requests are processed. It is best to set the item in a production environment;5loglevel Debug Specifies the logging level, where Redis supports a total of four levels: Debug, verbose, notice, warning, default = verbose. Debug means logging a lot of information for development and testing. Verbose indicates that useful information is logged, but not as much as the debug record. Notice represents common verbose and is commonly used in production environments. Warning indicates that only very important or critical information will be recorded in the log;6) LogFile/var/log/redis/redis.log Configuration log file address, default value is stdout. If the background mode is output to/dev/NULL;7) databases -The number of databases available, the default value is 16, the default database is 0, and the database range is 0-(database-1) between;8) Save the1 Save data to disk, format save <seconds> <changes&gt, and indicate how many times the update operation is synchronized to the data file RDB. The equivalent condition triggers the fetch snapshot, which can be combined with multiple conditions. Save the1 means that at least 1 keys in 900 seconds are changed to save data to disk;9rdbcompression Yes to compress the data when it is stored to the local database (persisted to the Rdb file), the default is yes;Ten) dbfilename Dump.rdb Local Persistent database file name, default value is Dump.rdb; One) dir./working directory, the path to the file placement of the database mirroring backup. The path is configured separately from the file name because Redis writes the state of the current database to a temporary file when it is being backed up, and then replaces the temporary file with the file specified above when the backup is complete. The temporary files here and the backup files configured above are placed in the specified path, and the aof file is stored under this directory. Note that you must specify a directory instead of a file; A) slaveof <masterip> <masterport>master-slave replication, which sets the database for other databases from the database. Set the IP address and port of the master service when this machine is a slave service. When Redis starts, it automatically synchronizes data from master; -) Masterauth <master-password>slave The password of the service connection master when the master service has password protection set (password with requirepass); -Slave-serve-stale-data Yes when the connection is lost from the library to the host or the replication is in progress, there are two ways to run from the hangar: if the slave-serve-stale-data is set to Yes (the default), the request from the library continues for the corresponding client. If slave-serve-stale-data refers to no, any request except for the info and SLAVOF commands will return an error"SYNC with Master in progress"; the) Repl-ping-slave-period 10 from the library, pings are sent to the main library at a time interval, and can be repl-ping-slave-period Set this time interval, default is 10 seconds; -) repl-timeout -Set the main library bulk data transfer time or ping reply interval, the default value is 60 seconds, make sure that repl-timeout is greater than repl-ping-slave-period; -requirepass foobared Sets the password to be used before any other specified client connection is made. Because Redis is quite fast, an external user can make a 150K password attempt in a second on a better server, which means you need to specify a very strong password to prevent brute force; -) Rename-command CONFIG""Command Rename, in a shared environment can be renamed relative dangerous commands, such as the name of CONFIG is not easy to guess the character: # Rename-command CONFIG B840fc02d524045429941cc15f59e41cb7be6c52. If you want to delete a command, rename it directly to a null character""Can: Rename-command CONFIG""; +) maxclients 128 Sets the maximum number of client connections at the same time, with no default limit. The number of client connections that Redis can open at the same time is the maximum number of file descriptors that the Redis process can open. If you set maxclients0, which means no restrictions. When the number of client connections reaches the limit, Redis closes the new connection and returns the max number of clients reached error message to the client; -) MaxMemory <bytes>Specifies the Redis maximum memory limit. Redis will load the data into memory when it starts up, and when it reaches the maximum memory, Redis will attempt to clear the expired or expiring Key,redis and remove the empty list object. When this method is processed, the maximum memory setting is still reached and the write operation is no longer available, but the read operation is still possible. Note: Redis's new VM mechanism will store the key in memory, and value will be stored in the swap area; +) Maxmemory-policyvolatile-LRU What data does Redis choose to delete when the memory reaches its maximum value? There are five different ways to choose:volatileThe-LRU represents the use of the LRU algorithm to remove the key (LRU: The most recently used Least recently used) that set the expiration time, and ALLKEYS-LRU represents the use of the LRU algorithm to remove any key,volatile-random represents the removal of a random key from a random key,allkeys_random that has set an expiration time.volatile-The TTL represents the removal of the expiring key (minor TTL), and the Noeviction representative does not remove any key, but returns a write error. Note: For the above policy, if no appropriate key can be removed, the Redis will return an error when writing; A) appendonly No by default, Redis backs up database mirroring to disk asynchronously in the background, but the backup is time-consuming and cannot be backed up very often. If a situation such as power cuts, pull plugs, and so on occurs, resulting in a wide range of data loss, Redis provides another more efficient way of database backup and disaster recovery. When append only mode is turned on, Redis appends each write request that is received to the Appendonly.aof file. When Redis restarts, the previous state is recovered from the file, but this causes the appendonly.aof file to be too large, so Redis also supports the bgrewriteaof instruction to rearrange the appendonly.aof. You can open asynchronous dumps and AOF at the same time; at) appendfilename appendonly.aof aof file name, default is"appendonly.aof"; -Appendfsync Everysec Redis supports three different strategies for synchronizing aof files: No means no synchronization, the system goes to action, always represents each write operation is synchronized, the everysec represents the accumulation of write operations, synchronization per second, the default is"everysec", which is best in terms of speed and safety.  -) Slowlog-log-slower-than10000Records commands that exceed a specific execution time. The execution time does not include I/O calculations, such as connecting clients, returning results, etc., just the command execution time. You can set slow log with two parameters: one is to tell Redis how much time is logged for the execution of the parameter slowlog-log-slower-than (subtle), the other is the length of the slow log. When a new command is recorded, the oldest command is removed from the queue, and the following time is in subtle micro-units, so 1000000 represents a minute. Note A negative number will turn off slow logging, and setting to 0 will force each command to be logged; -) hash-max-zipmap-entries +&& Hash-max-zipmap-value -When a hash contains more than the specified number of elements and the largest element does not exceed the critical value, the hash will be stored in a special encoding method (greatly reducing memory usage), where these two thresholds can be set. Redis hash corresponds to value inside is actually a hashmap, there will actually be 2 different implementations. This hash of the members is relatively young redis in order to save memory will be similar to a one-dimensional array of compact storage, rather than the real hashmap structure, the corresponding value Redisobject encoding is zipmap. When the number of members increases, it automatically turns into a real hashmap, at which time encoding is HT; -) list-max-ziplist-entries +The list data type How many nodes below will use the compact storage format of the pointer; -) list-max-ziplist-Value 64 data type node values smaller than how many bytes will be in a compact storage format; in)Set-max-intset-entries +Set Data type internal data if all are numeric, and the number of nodes contained below will be stored in a compact format; -) zset-max-ziplist-entries -zsort data Type How many nodes below will use a compact storage format for pointers; to) Zset-max-ziplist-value -Zsort Data Type node value size is less than how many bytes are in a compact storage format.  +activerehashing Yes Redis will use 1 milliseconds of CPU time every 100 milliseconds to hash the Redis hash table to reduce memory usage. When you have a very strict real-time requirement in your usage scenario, you cannot accept Redis's occasional 2 millisecond delay on requests, and configure this as No. If you do not have such strict real-time requirements, you can set it to Yes so that you can free up memory as quickly as possible;

Redis configuration file

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.