Go to redis configuration file

Source: Internet
Author: User
Tags allkeys rehash password protection redis server

Configuration and features

1. In redis, valid "size units" are case-insensitive.

  # 1k => 1000 bytes  # 1kb => 1024 bytes  # 1m => 1000000 bytes  # 1mb => 1024*1024 bytes  # 1g => 1000000000 bytes  # 1gb => 1024*1024*1024 bytes


2. Run redis in the form of a later process. The default value is "no"

  daemonize no

If "daemonize yes", the process ID information will be written to the file. Note: The user who starts the redis process must have the permission to write to this directory.

# Pidfile ~ /Redis. pid # command operation:./redis. Server -- daemonize yes -- pidfile ~ /Redis. PID
  Pidfile/Var/run/redis. PID


3. Specify the client connection port that the server needs to listen to. the client and the server perform TCP communication on this port.

  port 6379


4. If your physical server has multiple network interfaces, bind the server socket to the specified IP address.

 # bind 127.0.0.1


5. Specify the idle time (seconds) for the socket connection. If the connection times out, the connection will be closed (TCP socket option). If the value is 0, the connection will never time out.

  timeout 0

  

6. specifies whether the TCP connection is a persistent connection. The "detective" signal is maintained by the server. The persistent connection will increase the cost of the server (TCP socket option). The default value is 0. if the value is not 0, the "persistent connection" is enabled. When the "detective" signal is sent at intervals determined by the Linux system, if the Peer (client socket) still does not reply, the connection will be closed; otherwise, the connection will be enabled. The client socket can also enable "persistent connection" by configuring the keepalive option (unit: seconds)

  tcp-keepalive 0


7. server log level. Valid values: Debug, verbose, notice, and warning. The default value is notice.
Debug is suitable for the development environment, and logs are output for client operation information.
Verbose outputs some useful information, but the current effect is unknown
Notice is suitable for production environments
Warning exception information

  loglevel notice


8. Specify the redis log file directory. The default value is stdout.

  ##logfile ~/redislog.log  logfile stdout

  

9. Set the maximum "DB cluster" allowed by redis. The default value is 16. The client can use the "select" command to specify the "DB cluster" index number. The default value is 0. In redis's top-level data structure, all K-V potentially includes the "DB cluster" index number, and any key will belong to a "DB ". Any data retrieval will only overwrite the specified "DB". For example, if the data is inserted into "DB 10", get in "DB 1, the return value is null. Classifying data into different dB clusters can help us to meet specific requirements, such as specifying different dB index numbers based on different client connections.

  databases 16


10. persistent snapshot configuration and save <seconds> <changes> are used to describe "How many change operations are performed in seconds" to trigger snapshot ## snapshot will generate a new dump. RDB file, save "is used to disable the snapshot function. The following indicates at least one key change within 12 hours, triggering Snapshot

  save 43200 1


11. If an error occurs during the snapshot process, that is, data persistence fails, whether to terminate all client write requests. This option is difficult. "Yes" indicates termination. If snapshot fails, the server is a read-only service;

If it is "no", the snapshot will fail, but the next snapshot will not be affected. However, if it fails, the data can only be restored to the "latest success point ".

  stop-writes-on-bgsave-error yes


12. whether to enable RDB File compression. The default value is yes. compression may require additional CPU fees, but this can effectively reduce the size of RDB files and facilitate storage, backup, transmission, and data recovery.

  rdbcompression yes


13. whether to use the crc64 checksum for the RDB file. The default value is "yes". The CRC checksum will be appended to the end of each RDB file. Other third-party verification tools can easily detect file integrity.

  rdbchecksum yes

14. Specify the RDB file name

  dbfilename dump.rdb

  

15. Specify the directory location of the Rdb/AOF File

  dir ./


16. Use the current server as the slave and specify the master information for it.

  slaveof <masterip> <masterport>

  

17. the authorization password of the current server. Before any client or slave interacts with this server, you need to submit the password. The masterauth configuration of other servers is consistent with the value of this parameter. The password should be complex enough (64 bytes)

  requirepass <foobared>


18. connect to the master using authentication. if "password protection" is used in the master, slave must deliver the correct authorization password to connect successfully. The "requirepas" configuration item specifies the password of the current server. The <master-Password> value in this configuration item must be consistent with the "requirepas" of the master machine. This parameter is configured on the slave side.

  masterauth <master-password>


19. If the current server is slave, if slave and master lose communication, whether to continue to provide services for the client, "yes" means to continue, "no" means to terminate. # In the case of "yes", slave continues to provide read-only services to the client, and the data may have expired. # In the case of "no", any data request service (including the client and the server's slave) sent to this server will be notified of "error ".

  slave-serve-stale-data yes


20. Whether the slave is "read-only". We strongly recommend that you set it to "yes.

  slave-read-only yes


21. The interval (in seconds) When slave sends Ping messages to the specified master. The default value is 10.

  repl-ping-slave-period 10


22. The maximum idle time in the communication between slave and master is 60 seconds by default. Timeout will cause the connection to close.

 repl-timeout 60


23. Whether to disable the TCP nodelay option for the connection between slave and master. "Yes" indicates disabled. Data in socket communication will be sent in Packet Mode (the packet size is limited by socket buffer), which can improve the efficiency of socket communication (the number of TCP interactions ), however, small data will be cached and not immediately sent. There may be latency for the recipient. "No" indicates that the TCP nodelay option is enabled, and any data will be sent immediately. The timeliness is good, but the efficiency is low # we recommend that you set this parameter to "no ".

  repl-disable-tcp-nodelay no


24. Applicable to Sentinel modules (unstable, M-S cluster management and monitoring) that require additional profile support. Slave weight, 100 by default. when the master node fails, Sentinel finds the slave with the lowest weight (> 0) from the slave list and promotes it to the master node. If the weight is 0, indicates that this slave is "Observer" and does not participate in master election.

 slave-priority 100

  
25. rename commands. commands related to "server" control may not be used by remote clients (non-administrator users, # rename these commands as other strings that are "hard to read.
For example, commands such as "slaveof" "Config" "bgrewriteaof" "bgrewrite" "flushall" must be restricted.

# Configuration item format: Rename-command <command> <newcommand> rename-command config 3ed984507a5dcd722aeade310065ce5d (method: MD5 ('config ^! '))


26. The number of client connections allowed. The default value is 10000. This value cannot be set to too large, because each socket connection will be opened by the system in the form of "file descriptor", it is limited by the system "Number of opened files", if this value is exceeded, the server rejects the connection.

  maxclients 10000


27. the maximum memory (bytes) That redis-Cache can use. The default value is 0, indicating "unlimited". It is determined by the OS physical memory size (if the physical memory is insufficient, swap may be used ). If the value is too small (for example, 32 bytes), the server cannot be used directly. This value should not exceed the physical memory size of the machine. In terms of performance and implementation, the physical memory can be 3/4. This configuration must be used with "maxmemory-Policy". When the memory data in redis reaches maxmemory, the "clearing policy" is triggered ". If you still cannot get enough memory to store new data after the "clearing policy" is used, the write client will receive the "error OOM .." message, and the server is read-only. When "memory is insufficient", any write operations (such as set and lpush) will trigger the execution of the "clearing policy. In the actual environment, it is recommended that the hardware configurations of all the physical machines in redis be consistent (the memory is consistent), and the "maxmemory" "policy" configurations in the Master/Slave are consistent.

  maxmemory <bytes>



# When "memory is insufficient", the data clearing policy is set to "volatile-LRU" by default"
# Volatile-LRU-> use the LRU (least recently used) algorithm for data in "expired sets. if you use the "expire" command to specify the expiration time for the key, the key will be added to the "Expiration set.
# Remove expired/LRU data first. If all expired sets cannot meet the memory requirements, set oom.
# Allkeys-LRU-> use the LRU Algorithm for all data
# Volatile-random-> take the "select" algorithm for the data in the "expired set" and remove the selected K-V until "memory is enough.
# If you still cannot remove all expired collections
# Allkeys-random-> for all data, take the "select" algorithm and remove the selected K-V until "memory is enough.
# Volatile-TTL-> use the TTL algorithm (minimum survival time) for the data in the "expired set" to remove the data that is about to expire.
# Noeviction-> directly return an OOM exception without any interference.
###
# If data expiration does not cause exceptions to the "Application System" and the write operations in the system are intensive, we recommend that you use"Allkeys-LRU"
#Maxmemory-PolicyVolatile-LRU


# Whether to enable the aof function. "Yes" indicates that the aof file synchronization function is enabled. The default value is "no"
# For Master machines, we recommend that you use Aof. For slave, we recommend that you disable it (using snapshot ),
AppendonlyNo


# Aof file synchronization mechanism
##Always-> Any aof record is immediately synchronized to a file (written to a disk), with the highest security. If write requests are intensive, High Disk Io costs and response latency will occur.
##Everysec-> The synchronization is performed once per second, and the performance and security are high. It is also the default value.
##No-> If the file is not directly synchronized, the file is handed over to the OS for control. The OS selects a host to write data to the disk based on the buffer condition or idle condition in the file channel. The security and efficiency are related to the OS setting.
AppendfsyncEverysec

# During aof rewrite, whether to suspend the use of the file synchronization policy for the append of the aof new record, mainly considering disk Io expenditure and request blocking time.
# The default value is no, indicating "no hold". The new aof record will still be synchronized immediately.
##
No-appendfsync-on-RewriteNo

# Aof rewrite triggering time, Minimum File Size
Auto-Aof-rewrite-Min-size64 MB


# Aof every time after rewrite, the current aof file size will be remembered. When the file grows to a certain proportion, the aof rewrite will continue.
Auto-Aof-rewrite-Percentage100

# Whether to adopt the incremental "file sync" policy during aof rewrite. The default value is "yes" and must be yes.
# During the rewrite process, file synchronization is performed every 32 MB of data, which can reduce the number of disk operations written to the "aof large file.
Aof-rewrite-incremental-fsyncYes

# Maximum Lua script running time
Lua-time-limit5000

# "Slow operation log" record, unit: microseconds (one second per million, 1000*1000). If the operation time exceeds this value, the command information is recorded. (memory, non-file)
# The "Operation Time" does not include network I/O expenses. It only includes the time when the request reaches the server for "memory implementation". "0" indicates that all operations are recorded.
Slowlog-log-slower-10000
# Maximum number of records retained in "slow operation logs". "records" will be queued. If this length is exceeded, old records will be removed.
# You can view slow log information through "slowlog <subcommand> ARGs" (slowlog get 10, slowlog reset)
# Through the "slowlog get num" command can view the recent num slow records, including "record" Operation Time/command/K-V and other information
Slowlog-max-Len128

# View the data type of a key using the "type key" command
# View the encoding type of the key through "Object encoding key"
# Ziplist and hashtable can be used for encoding of hash Data Structures

# Ziplist is characterized by a small amount of space required for file storage (and memory storage). When the content is small, the performance is almost the same as that of hashtable. Therefore, redis uses ziplist for the hash type by default.

# If the number or value length of entries in the hash reaches the threshold, it will be reconstructed to hashtable.
# The maximum number of entries that can be stored in ziplist. The recommended value is 128.
Hash-max-ziplist-entries512
# Maximum number of bytes allowed for entry value in ziplist, which is recommended to be 1024
Hash-max-ziplist-Value64

# For the list type, ziplist and listlist encoding types are used.
# Same as hash.
List-max-ziplist-entries512
List-max-ziplist-Value64


# Zset is an ordered set with two encoding types: ziplist and skiplist

# Because "sorting" consumes extra performance, when there is a large amount of data in zset, it will be restructured into a skiplist.
# Same as hash.
Zset-max-ziplist-entries128
Zset-max-ziplist-Value64

# Maximum number of entries that can be saved in intset. If the threshold value is reached, intset will be reconstructed to hashtable
Set-max-intset-entries512


# Whether to enable the rehash function of the top-level data structure. If the memory permits this function, enable it.
# Rehash can improve the efficiency of K-V access to a large extent.
ActiverehashingYes

# Client Buffer Control

# In the interaction between the client and the server, each connection is associated with a buffer, which is used to queue the response information to be accepted by the client.
# If the client cannot consume response information in a timely manner, the buffer will be continuously accumulated to bring memory pressure to the server. If the backlog of data in the buffer reaches the threshold, it will
# The connection is closed and the buffer is removed ."
# Buffer control types include:
##Normal-> Normal connection
##Slave-> Connection to slave
##Pubsub-> Pub/sub-type connections. This type of connection often causes this problem because the pub end publishes messages intensively, but the sub end may consume less.
# Command Format: client-output-buffer-limit <class> # Soft indicates "tolerable value". It works with seconds. If the buffer value exceeds soft and reaches seconds, the connection is closed immediately. If the buffer value exceeds soft, the connection is closed after seconds.
# If the buffer data is smaller than soft, the connection will be retained.
# If both hard and soft are set to 0, buffer control is disabled. Generally, the hard value is greater than soft.
Client-output-buffer-LimitNormal 0 0 0
Client-output-buffer-LimitServer Load balancer 256 MB 64 MB 60
Client-output-buffer-LimitPubsub 32 MB 8 Mb 60

# Frequency of executing background tasks on redis server. The default value is 10. A greater value indicates the more frequent the execution frequency of redis on "intermittent tasks" (times/second)
# "Intermittent task" includes "Expiration set" Detection and disconnection of "Idle timeout". This value must be greater than 0 and less than 500. (See redis. H source code)

# If this value is too small, it means more CPU cycles are consumed, and the number of backend tasks that are polling is more frequent.

# This value is too large, which means the "memory sensitivity" is poor.
# Keep the default value
Hz10

# The include command is used to load an additional configuration file template. You can also manually specify the configuration file to include when starting redis server.
#Include/Path/to/local. conf
# Include/path/to/other. conf

Article transferred from: http://leonmau.iteye.com/blog/1395690

Go to 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.