Redis configuration file redis. conf detailed description, redisredis. conf

Source: Internet
Author: User
Tags shared hosting strong password

Redis configuration file redis. conf detailed description, redisredis. conf

Redis. conf

1. daemonize
# By default Redis does not run as a daemon. use 'yes' if you need it. # Note that Redis will write a pid file in/var/run/redis. pid when daemonized. # Redis does not run as a daemon by default. You can modify this configuration item and use yes to enable the daemon (daemon) it refers to the computer program executed in the background in UNIX or other multi-task operating systems, and does not accept direct operation # control from computer users .) Daemonize no
2. pidfile
# When running daemonized, Redis writes a pid file in/var/run/redis. pid by # default. you can specify a custom pid file location here. # When Redis runs as a daemon, Redis places the pid file in/var/run/redis by default. pid, # You can configure it to another address. When running multiple redis services, You need to specify different pid files and ports # pidfile/var/run/redis. pid
3. port
# Accept connections on the specified port, default is 6379. # If port 0 is specified Redis will not listen on a TCP socket. # There is nothing to say about port 6379.
4. bind
# If you want you can bind a single interface, if the bind option is not # specified all the interfaces will listen for incoming connections. # specify the IP address that Redis can receive requests. If this parameter is not set, all requests are processed. We recommend that you set it in the production environment # bind 127.0.0.1
5. timeout
# Close the connection after a client is idle for N seconds (0 to disable) # timeout time for client connection, in seconds. connection timeout 0 is closed after timeout.
6. logfile
# Specify the log file name. also 'stdout' can be used to force # Redis to log on the standard output. note that if you use standard # output for logging but daemonize, logs will be sent to/dev/null # configure the log file address, which is printed in the window of the command line terminal by default. logfile stdout
7. databases
# Set the number of databases. the default database is DB 0, you can select # a different one on a per-connection basis using SELECT <dbid> where # dbid is a number between 0 and 'databases'-1 # set the number of databases, you can use the SELECT <dbid> command to switch databases. The default database is 0 databases 16.
8. save
# Save the DB on disk: # save <seconds> <changes> # Will save the DB if both the given number of seconds and the given # number of write operations against the DB occurred. # In the example below the behaviour will be to save: # after 900 sec (15 min) if at least 1 key changed # after 300 sec (5 min) if at least 10 keys changed # after 60 sec if at least 10000 keys changed # Note: you can disable savi Ng at all commenting all the "save" lines. # set the frequency of Redis database mirroring. # When one keys change within 900 seconds # When 10 keys change within 30 seconds # If 10000 keys change within 60 seconds, save 900 1 save 300 10 save 60 10000
9. rdbcompression
# Compress string objects using LZF when dump. rdb databases? # For default that's set to 'yes' as it's almost always a win. # If you want to save some CPU in the saving child set it to 'no' but # the dataset will likely be bigger if you have compressible values or keys. # Whether to compress rdbcompression during image backup yes
10. dbfinename
# The filename where to dump the DB # Name of The backup image file dbfilename dump. rdb
11. dir
# The working directory. # The DB will be written inside this directory, with the filename specified # above using the 'dbfilename' configuration ctictive. # Also the Append Only File will be created inside this directory. # Note that you must specify a directory here, not a file name. # path of the database image backup file. The path and file name must be configured separately because Redis writes the status of the current database to a temporary file during Backup. When the backup is complete, replace the temporary file with the file specified in # above, and the temporary file and the backup file configured above will be placed in the specified path dir./
12. slaveof
# Master-Slave replication. use slaveof to make a Redis instance a copy of # another Redis server. note that the configuration is local to the slave # so for example it is possible to configure the slave to save the DB with a # different interval, or to listen to another port, and so on. # Set the database as a slave database of another database # slaveof <masterip> <masterport>
13. masterauth
# If the master is password protected (using the "requirepass" configuration # directive below) it is possible to tell the slave to authenticate before # starting the replication synchronization process, otherwise the master will # refuse the slave request. # password verification required for connection to the primary database # masterauth <master-password>
14. requirepass
# Require clients to issue AUTH <PASSWORD> before processing any other # commands. this might be useful in environments in which you do not trust # others with access to the host running redis-server. # This shoshould stay commented out for backward compatibility and because most # people do not need auth (e.g. they run their own servers ). # Warning: since Redis is pretty fast an outside user can try up To #150 k passwords per second against a good box. this means that you should # use a very strong password otherwise it will be very easy to break. # Set the password required to specify any other before connecting the client. # Warning: redis is quite fast. An external user can perform K password attempts in one second. # You need to specify a very powerful password to prevent brute force cracking. # Requirepass foobared
15. maxclient
# Set the max number of connected clients at the same time. by default there # is no limit, and it's up to the number of file descriptors the Redis process # is able to open. the special value '0' means no limits. # Once the limit is reached Redis will close all the new connections sending # an error 'max number of clients reached '. # limit the number of customers connected at the same time. When the number of connections exceeds this value, # redis no longer receives other connection requests, and the client will receive an error message when trying to connect # maxclients 128
16. maxmemory
# Don't use more memory than the specified amount of bytes. # When the memory limit is reached Redis will try to remove keys # accordingly to the eviction policy selected (see maxmemmory-policy ). # If Redis can't remove keys according to the policy, or if the policy is # set to 'noeviction ', redis will start to reply with errors to commands # that wocould use more memory, like SET, LPUSH, and so on, and Will continue # to reply to read-only commands like GET. # This option is usually useful when using Redis as an LRU cache, or to set # an hard memory limit for an instance (using the 'noeviction 'policy ). # WARNING: If you have slaves attached to an instance with maxmemory on, # the size of the output buffers needed to feed the slaves are subtracted # from the used memory count, so that network proble MS/resyncs will # not trigger a loop where keys are evicted, and in turn the output # buffer of slaves is full with DELs of keys evicted triggering the deletion # of more keys, and so forth until the database is completely emptied. # In short... If you have slaves attached it is suggested that you set a lower # limit for maxmemory so that there is some free RAM on the system for slave # output buffers (but this is not needed if policy is 'noeviction '). # Set the maximum memory available for redis. # When the memory is full, if you still receive the set command, redis will first try to remove the key with expire information set, # No matter the key expiration time has not reached. # When deleting a key, it will be deleted according to the expiration time. The key to be expired will be deleted first. # If all keys with expire information are deleted, an error is returned. # In this way, redis will not receive write requests, but only get requests. # Maxmemory settings are suitable for using redis as a cache similar to memcached # maxmemory <bytes>
17. appendonly
# By default Redis asynchronously dumps the dataset on disk. if you can live # with the idea that the latest records will be lost if something like a crash # happens this is the preferred way to run Redis. if instead you care a lot # about your data and don't want to that a single record can get lost you shoshould # enable the append only mode: when this mode is enabled Redis will append # every write timeout Ation already ed in the file appendonly. aof. this file will # be read on startup in order to rebuild the full dataset in memory. # Note that you can have both the async dumps and the append only file if you # like (you have to comment the "save" statements above to disable the dumps ). # Still if append only mode is enabled Redis will load the data from the # log file at startup ignoring the dump. rdb fil E. # IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append # log file in background when it gets too big. # By default, redis will asynchronously back up database images to disks in the background, but this backup is very time-consuming. # backup cannot be performed frequently, if a fault occurs, such as power limit or power limit, it may cause a wide range of data loss. # Redis provides another more efficient database backup and disaster recovery method. # After the append only mode is enabled, redis will append each write operation request received to appendonly. in the aof file, # When redis is restarted, the previous state will be restored from the file. However, this will cause the appendonly. aof file to be too large. # redis also supports the BGREWRITEAOF command and reorganizes appendonly. aof. appendonly no
18. appendfsync
# The fsync () call tells the Operating System to actually write data on disk # instead to wait for more data in the output buffer. some OS will really flush # data on disk, some other OS will just try to do it ASAP. # Redis supports three different modes: # no: don't fsync, just let the OS flush the data when it wants. faster. # always: fsync after every write to the append only log. slow, Safest. # Everysec: fsync only if one second passed since the last fsync. compromise. # The default is "everysec" that's usually the right compromise between # speed and data safety. it's up to you to understand if you can relax this to # "no" that will let the operating system flush the output buffer when # it wants, for better performances (but if you can live with the idea of # some data loss consider t He default persistence mode that's snapshoary), # or on the contrary, use "always" that's very slow but a bit safer than # everysec. # If unsure, use "everysec ". # Set appendonly. aof file synchronization frequency. # Always indicates that all write operations are synchronized. everysec indicates that write operations are accumulated and synchronized once per second. # Appendfsync alwaysappendfsync everysec # appendfsync no
19. vm-enabled
# Virtual Memory allows Redis to work with datasets bigger than the actual # amount of RAM needed to hold the whole dataset in memory. # In order to do so very used keys are taken in memory while the other keys # are swapped into a swap file, similarly to what operating systems do # with memory pages. # To enable VM just set 'vm-enabled' to yes, and set the following three # vm parameters accordingly Your needs. # Whether to enable virtual memory support. Because redis is a memory database, and when the memory is full, it cannot receive new write requests. # In redis2.0, it provides support for virtual memory. # However, in redis, all keys are stored in the memory. When the memory is insufficient, only the value is placed in the SWAp zone. # This ensures that although virtual memory is used, the performance is basically unaffected. # At the same time, note that you need to set vm-max-memory enough to put down all your keyvm-enabled no # vm-enabled yes
20. vm-swap-file
# This is the path of the Redis swap file. as you can guess, swap files # can't be shared by different Redis instances, so make sure to use a swap # file for every redis process you are running. redis will complain if the # swap file is already in use. # The best kind of storage for the Redis swap file (that's accessed at random) # is a Solid State Disk (SSD ). # *** WARNING *** if you are using a shared hosting the default of putting # the swap file under/tmp is not secure. create a dir with access granted # only to Redis user and configure Redis to create the swap file there. # Set the virtual memory swap file path vm-swap-file/tmp/redis. swap
21. vm-max-memory
# Vm-max-memory configures the VM to use at max the specified amount of # RAM. everything that deos not fit will be swapped on disk * if * possible, that # is, if there is still enough contiguous space in the swap file. # With vm-max-memory 0 the system will swap everything it can. not a good # default, just specify the max amount of RAM you can in bytes, but it's # better to leave some margin. for insta Nce specify an amount of RAM # that's more or less between 60 and 80% of your free RAM. # set the maximum physical memory size that redis will use after enabling virtual memory. # The default value is 0. redis will put all the files that can be stored in the swap file to use the physical memory as little as possible. # In the production environment, you need to set this value according to the actual situation. It is best not to use the default 0vm-max-memory 0
22. vm-page-size
# Redis swap files is split into pages. an object can be saved using multiple # contiguous pages, but pages can't be shared between different objects. # So if your page is too big, small objects swapped out on disk will waste # a lot of space. if you page is too small, there is less space in the swap # file (assuming you configured the same number of total swap file pages ). # If you use a lot of small objects, use a page size of 64 or 32 bytes. # If you use a lot of big objects, use a bigger page size. # If unsure, use the default # Set the page size of the virtual memory. If your value is large, for example, you need to place all the articles such as blog and # News in value, make it bigger. If you want to store small content, set smaller vm-page-size 32.
23. vm-pages
# Number of total memory pages in the swap file. # Given that the page table (a bitmap of free/used pages) is taken in memory, # every 8 pages on disk will consume 1 byte of RAM. # The total swap size is vm-page-size * vm-pages # With the default of 32-bytes memory pages and 134217728 pages Redis will # use a 4 GB swap file, that will use 16 MB of RAM for the page table. # It's better to use the small Est acceptable value for your application, # but the default is large in order to work in most conditions. # Set the total number of pages for the swap file. # note that the page table information is stored in the physical memory, and each 8 pages occupies one byte in RAM. # The total virtual memory size = vm-page-size * vm-pagesvm-pages 134217728
24. vm-max-threads
# Max number of vm I/O threads running at the same time. # This threads are used to read/write data from/to swap file, since they # also encode and decode objects from disk to memory or the reverse, a bigger # number of threads can help with big objects even if they can't help with # I/O itself as the physical device may not be able to couple with parameters # reads/writes operations at the same time. # The s Pecial value of 0 turn off threaded I/O and enables the blocking # Virtual Memory implementation. # set the number of threads simultaneously used by VM IO. Vm-max-threads 4
25. hash-max-zipmap
# Hashes are encoded in a special way (much more memory efficient) when they # have at max a given numer of elements, and the biggest element does not # exceed a given threshold. you can configure this limits with the following # configuration ctives ves. # The hash data structure is introduced in redis 2.0. # When the hash contains more than the specified number of elements and the maximum number of elements does not exceed the critical value, # hash is stored by zipmap (also known as small hash, which greatly reduces memory usage, here we can set the two critical values hash-max-zipmap-entries 512hash-max-zipmap-value 64
26. activerehashing
# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in # order to help rehashing the main Redis hash table (the one mapping top-level # keys to values ). the hash table implementation redis uses (see dict. c) # performs a lazy rehashing: the more operation you run into an hash table # that is rhashing, the more rehashing "steps" are saved med, so if the # server is idle the rehashing Is never complete and some more memory is used # by the hash table. # The default is to use this millisecond 10 times every second in order to # active rehashing the main dictionaries, freeing memory when possible. # If unsure: # use "activerehashing no" if you have hard latency requirements and it is # not a good thing in your environment that Redis can reply form time to time # to queries with 2 mil Liseconds delay. # use "activerehashing yes" if you don't have such hard requirements but # want to free memory asap when possible. # After it is enabled, redis uses a CPU time of 1 ms every 100 milliseconds to re-hash the hash table of redis. # This can reduce the memory usage. # When your application scenario requires strict real-time performance and Redis cannot accept a latency of 2 milliseconds from time to time for requests, # Set this parameter to no. # If you do not have such strict real-time requirements, you can set it to yes to release the memory activerehashing yes as quickly as possible.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.