Redis configuration file redis. conf

Source: Internet
Author: User
Tags shared hosting strong password

# 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.
Daemonize no

# When running daemonized, Redis writes a pid file in/var/run/redis. pid
# Default. You can specify a custom pid file location here.
# When Redis runs as a daemon, Redis puts the pid file in/var/run/redis. pid by default. You can configure it to another address. When running multiple redis services, you must specify different pid files and ports.
Pidfile/var/run/redis. pid

# 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 the port
Port 6379

# 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 this parameter in the production environment.
# Bind 127.0.0.1

# Close the connection after a client is idle for N seconds (0 to disable)
# Timeout time for client connection, in seconds. connection will be closed after timeout
Timeout 0

# 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 command line terminal window by default
Logfile stdout

# 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


#
# 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 saving at all commenting all the "save" lines.
# Set the frequency of Redis database mirroring.
# When one keys changes within 900 seconds
# When 10 keys change within 30 seconds
# When 10000 keys change within 60 seconds
Save 900 1
Save 300 10
Save 60 10000

# 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'
# The dataset will likely be bigger if you have compressible values or keys.
# Whether to perform compression during image backup
Rdbcompression yes

# The filename where to dump the DB
# Image backup file name
Dbfilename dump. rdb

# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# Above using the 'dbfilename' configuration ctive ve.
#
# 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 first 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 above,
# The temporary files and the backup files configured above are stored in the specified path.
Dir ./

# Master-Slave replication. Use slaveof to make a Redis instance a copy
# 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
# Different interval, or to listen to another port, and so on.
# Set the database as a slave database of another database
# Slaveof <masterip> <masterport>

# 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>

# 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
#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


# 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 will no longer receive other connection requests, and the client will receive an error message when trying to connect.
# Maxclients 128

# 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 problems/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 the 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, regardless of whether the key expires.
# 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>

# 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 operation completed 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
# Log file at startup ignoring the dump. rdb file.
#
# IMPORTANT: Check the BGREWRITEAOF to check how to rewrite the append
# Log file in background when it gets too big.
# By default, redis asynchronously backs up database images to disks in the background, but this backup is time-consuming and 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, so redis also supports the BGREWRITEAOF command to reorganize appendonly. aof
Appendonly no

# 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
# Speed and data safety. It's up to you to understand if you can relax this
# "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
# Some data loss consider the default persistence mode that's snapshoence ),
# Or on the contrary, use "always" that's very slow but a bit safer
# Everysec.
#
# If unsure, use "everysec ".
# Set the synchronization frequency of the appendonly. aof file. Always indicates that the write operation is synchronized every time, while everysec indicates that the write operation is accumulated and synchronized every second.
# Appendfsync always
Appendfsync everysec
# Appendfsync no

# 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 to your needs.
# Whether to enable virtual memory support. Because redis is a memory database and cannot receive new write requests when the memory is full, it provides support for Virtual Memory in redis2.0.
# 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 the virtual memory is used, the performance is basically unaffected. At the same time, you need to note that you should set vm-max-memory to enough to put down all your keys.
Vm-enabled no
# Vm-enabled yes

# 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
# 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 swap file path for the virtual memory
Vm-swap-file/tmp/redis. swap

# Vm-max-memory configures the VM to use at max the specified amount
# 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 instance 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 of its swap files into swap files to use as little physical memory 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 0
Vm-max-memory 0

# 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 relatively large, for example, you need to place all the articles such as blogs and news in the value, set it to a larger value, if you want to store small content, set it to a smaller value.
Vm-page-size 32

# 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 smallest 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.
# Total virtual memory size = vm-page-size * vm-pages
Vm-pages 134217728

# 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
# I/O itself as the physical device may not be able to couple with role
# Reads/writes operations at the same time.
#
# The special 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

# 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 ctictives.
# 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 will be stored with zipmap (also known as small hash, which greatly reduces memory usage, the two thresholds can be set here.
Hhash-max-zipmap-entries 512
Hash-max-zipmap-value 64

# 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
# 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
# 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 milliseconds delay.
#
# Use "activerehashing yes" if you don't have such hard requirements
# 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 redis hash table, which 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 as quickly as possible.
Activerehashing yes

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.