Sinsing Brief analysis of configuration files in Redis

Source: Internet
Author: User
Tags password protection strong password

The main configuration items in Redis are as follows:

(1) Daemonize Yes it indicates whether it is running in the background, if it is written as Yes, then runs in the background, if no, it is not running in the background.

(2) Pidfile/var/run/redis.pid when Redis is running in the background, Redis defaults to placing the PID file in/var/run/redis.pid, and we can also specify different PID files and ports when running multiple Redis services

(3) port 6379 specifies the ports that the Redis runs on, default is 6379

(4) 127.0.0.1 usually has #bind before it, which indicates that Redis only receives requests from that IP address, and if not set, all requests are processed, which is best set in a production environment.

(5) Timeout 0 It is the time-out period when the client connection is set, in seconds, when the client does not issue any instructions during that time, the connection is closed and if 0 indicates that the setting is turned off.

(6) LogLevel Debug It specifies the logging level for the log, and Redis supports four levels: Debug, verbose, notice, warning. The default is verbose. Where debug records a lot of information for development and testing, and verbose will be relatively less, while the notice can be understood as ordinary verbose, common language production environment, and warning is very important or serious information will be recorded to the log.

(7) StdOut Logfile/var/log/redis/redis.log It is the log file address, the default value is stdout, which is the standard output, if the background output will be output to/dev/null.

(8) Database 16 It is the number of databases available, the default value is 16, the default database is 0, and the database range is from 0 to (database-1).

(9) Save 900 1 is 900 seconds, at least 1 key has been changed, it is to indicate in how many times, how many times the update operation, the data is synchronized to the data file Rdb, the equivalent of the condition to trigger the capture snapshot, it can be multiple conditions match, that is, the command to write multiple, each of the format is save & Lt;seconds> < changes>

(Ten) Rdbcompression Yes when storing to the local database, that is, when persisting to the Rdb file, whether the data is compressed, the default is Yes

(one) Dbfilename Dump.rdb local Persistent database file name, default is Dump.rdb

Dir./It is the working directory, that is, the database image backup file placement path, where the path and file name is configured separately because Redis in the backup, the state of the database is written to a temporary file, and so on after the backup is complete, and then replace the temporary file with the file specified above, The temporary files here and the backup files configured above will be placed in the specified path. The AoF file is also placed in this directory, note that it must be a directory instead of a file.

(13) Home Server IP master server port here is the database that is set up for other databases, it is set when the native is slave, the IP address of the master is set and the port, when Redis boots, it automatically synchronizes data from master. It is usually written under the #slaveof.

Masterauth password when the master server has password protection set, use Requirepass to establish a password, using the slave server to connect to the master password.

Slave-server-stale-data Yes it is when the connection from the library to the host city or the replication is in progress, there are two ways to run from the library, if yes, the request from the library will continue to respond to the client, if no, Any request other than the info and slaveof commands will return an error.

(+) Repl-ping-slave-period 10 It is a ping that is sent from the library to the main library at a time interval, which is 10 seconds by default.

Repl-timeout 60 It is to set the main library bulk data transfer time or ping reply interval, the default is 60 seconds, it must be larger than repl-ping-slave-period.

Requirepass Password It sets the password that needs to be used before any other specified client connection is made. Because Redis is very fast, it is possible for an external user to try the password 150K in a second, under a better server, which means we need to specify a very strong password to prevent brute force.

(+) MaxClients 128 It means setting the maximum number of client connections at the same time, the default is unlimited, the number of client connections that Redis can open concurrently is the maximum number of file descriptors that the Redis process can open, and if set to 0 means unrestricted, when the client connection reaches the limit, Redis closes the new link and returns max number of clients to the client.

(+) MaxMemory <bytes> It specifies the maximum memory limit for Redis, which is loaded into memory when Redis starts, and Redis tries to understand the key that has expired or is about to expire when it reaches the maximum memory. The empty list object is also removed, and after Redis implements the VM mechanism, it puts the key into memory and puts the value in virtual memory. Without this mechanism, if the maximum memory limit is reached, no further write operations can be made, but the read operation is still possible. This setting is more suitable for using Redis as a cache for memcached, rather than a database, and when we use Redis as a real database, memory usage is a very big overhead.

(+) Maxmemory-policy Volatile-lru It is the method used by Redis to delete data when the memory reaches its maximum, there are five ways to choose: ①volatile-lru, It is the use of the LRU algorithm to remove the set expiration time of the key, the so-called LRU is least recently Used②allkeys-lur, which uses the LRU algorithm to remove any key③volatile-random it removes the set expired time of the random key ④volatile-ttl it removes the expiring Key⑤ does not remove any key, just returns a write error.

AppendOnly No by default, Redis backs up database mirroring to disk asynchronously in the background, but the backup is time-consuming, and backups are not frequent, and if a sudden power outage results in a large range of data loss, So Redis provides another, more efficient database backup and disaster recovery approach. When we open the appendonly mode, Redis will append each write to the appendonly.aof, and when the Redis restarts, the previous state will be recovered from the file, and if the appendonly.aof file is too large, we can use bgrewriteaof to re- Finishing.

Appendfilename appendonly.aof It is the name of the AoF file, which is appendonly.aof by default.

Appendfsync everysec It is a Redis supported synchronization aof file policy, if no means no synchronization, that is, the system to operate, if the everysec is the accumulation of write operations, synchronization per second, Always indicates that each time a write operation is synchronized.

Auto-aof-rewrite-percentage 100 or Auto-aof-rewrite-min-size 64MB it is when the aof file grows to a certain size that Redis can call bgrewriteaof to the log file To rewrite it, it works like this: Redis remembers the size of the file when it was last written, and if the current size is larger than the specified percentage of the base size, then the rewrite function will automatically open, and we will typically specify a minimum size for aof overrides. It is used to prevent cases where the file is small but has a large growth rate to rewrite the aof file. If we set percentage to 0, this feature is turned off. If the rewrite has not been made since the boot, the log size is determined at boot time.

(+) Slowlog-log-slower-than 10000 Here the unit is subtle, we use slow log to record more than a certain time of the command, note that the execution time here does not include such as connection to the client, return results and other times, it said only the execution time, It is here that the unit is subtle.

Slowlog-max-len 1024 It is when a new command is recorded, the oldest command is removed from the queue, it has no limit on the length of the log, but it consumes memory, and we can reclaim the memory consumed by the slow log by Slowlog reset.





























Sinsing Brief analysis of configuration files in Redis

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.