Redis Database parameter configuration file detailed

Source: Internet
Author: User
Tags hash memory usage redis password protection

# Redis configuration file

# When you need to configure the memory size in the configuration, you can use similar formats such as 1k, 5GB, 4M, which are converted as follows (case-insensitive)
#
# 1k =>
1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1MB =>
1024*1024 bytes
# 1g => 1000000000 bytes
# 1GB => 1024*1024*1024
bytes
#
# memory configuration case is the same. For example 1GB 1Gb 1GB 1gB

# Daemonize No by default, Redis does not run in the background, and if you need to run in the background, change the value of the item to Yes
Daemonize
Yes

Default parameters

The code is as follows Copy Code

361way@ubuntu ~$ egrep-v ' (^#|^$) ' redis.conf
################### #基本配置部分 ###########################
Daemonize Yes
#是否在后台运行
Pidfile/var/run/redis/redis-server.pid
#运行时redis的pid文件存放的路径
Port 6379
#redis监听的端口
Bind 127.0.0.1
#监听地址
Timeout 0
#设置客户端连接时的超时时间, the unit is seconds. When the client does not issue any instructions during this time, the server side closes the connection. 0 for never timeout
Tcp-keepalive 0
LogLevel Notice
Logfile/var/log/redis/redis-server.log
#日志文件存放的路径
Databases 16
################ #Snapshotting配置 ##########################
Save 900 1 #900秒之内有1个keys发生变化时
Save #300秒之内有10个keys发生变化时
Save 10000 #60秒之内有1万个keys发生变化时
Stop-writes-on-bgsave-error Yes
#是否启用停止写在save出错的时候
Rdbcompression Yes
#是否启用rdb文件压缩手段, the default is yes. Compression requires additional CPU overhead, but this can effectively reduce the size of the RDB file and facilitate storage/backup/transfer/Data recovery.
Rdbchecksum Yes
#是否对rdb文件使用CRC64校验和, the default is yes, and the CRC checksum is appended to the end of each RDB file content.
#对于其他第三方校验工具, it is convenient to detect the integrity of the file.
Dbfilename Dump.rdb
#指定rdb文件的名称
Dir/var/lib/redis
#指定rdb the directory location of the/aof file, only the folder cannot be a file
####################### Replication ##########################
Slave-serve-stale-data Yes
#如果当前server是slave, if slave continues to provide services to the client when it loses communication with master, "yes" means continue and "no" indicates termination.
Slave-read-only Yes
Repl-disable-tcp-nodelay No
Slave-priority 100
AppendOnly No
Appendfilename "Appendonly.aof"
#更新日志文件名, the default value is Appendonly.aof
Appendfsync everysec
#no表示让操作系统 (OS) Synchronizes data caching to disk (fast execution), always means that fsync () is invoked to write data to disk (most secure) after each update operation, and EVERYSEC indicates that it is synchronized once per second.
No-appendfsync-on-rewrite No
Auto-aof-rewrite-percentage 100
Auto-aof-rewrite-min-size 64MB
#如果达到64M的百分之百就停止写入
Lua-time-limit 5000
#执行一个LUA脚本时的最大时间, prevent dead loops, and so on, set to 0 is no limit, the unit is seconds
Slowlog-log-slower-than 10000
Slowlog-max-len 128
Notify-keyspace-events ""
Hash-max-ziplist-entries 512
Hash-max-ziplist-value 64
#redis 2.0 The hash data structure is introduced, and the hash contains more than the specified number of elements and when the maximum element is not over critical, the hash is stored in zipmap.
#zipmap又称为 small hash, can greatly reduce the use of memory
List-max-ziplist-entries 512
List-max-ziplist-value 64
Set-max-intset-entries 512
Zset-max-ziplist-entries 128
Zset-max-ziplist-value 64
activerehashing Yes
Client-output-buffer-limit Normal 0 0 0
Client-output-buffer-limit slave 256MB 64MB 60
Client-output-buffer-limit pubsub 32MB 8MB 60
Hz 10
#一个任务可以使用的cpu数目
Aof-rewrite-incremental-fsync Yes
Tcp-keepalive: Specifies whether the TCP connection is a long connection, the "Detective" signal is maintained by the server side, and the long connection adds additional server-side expenses
#默认为0. Indicates disabled, a value other than 0 indicates that "long connection" is turned on; Detective "The sending interval of the signal will be decided by the Linux system. After several "detectives", if the peer still does not reply, the connection will be closed or the connection will be kept open.

Loglevel:server log level, legal value: debug,verbose,notice,warning defaults to notice.

Debug is suitable for development environment, client action information will output log
Verbose output Some of the relatively useful information, the current effect is unknown
Notice suitable for production environment
Warning exception information
Databases: Sets the maximum number of "DB clusters" allowed by the Redis, which defaults to 16 clusters. The client can specify the "DB Cluster" index number that needs to be used by the "select" directive, which defaults to 0. In the top-level data structure of Redis, all k-v potentially include the "DB Cluster" index number, and any key will be subordinate to a "db". Any retrieval of the data will only overwrite the specified "db", for example, the data is inserted into the "Db10″", then the get in DB 1″ will return null. Classifying data into different DB clusters can help us implement specific requirements, such as specifying different DB index numbers based on different client connections.

Save <seconds> <changes>: At least how many change actions are triggered snapshot,snapshot will eventually generate a new Dump.rdb file during the number of seconds. Sets how often database mirroring is redis. The policy for saving data to disk. Save "" To disable the snapshot feature.

AppendOnly: Whether logging after each update operation, if not turned on, may result in loss of data over time during a power outage. Because Redis itself synchronizes data files by the above save condition, some data will only exist in memory for a period of time, and the default value is No.

When append only mode is turned on, Redis appends each write request to the Appendonly.aof file, and Redis resumes the previous state from the file when it restarts. But may cause the appendonly.aof file to be too big, therefore redis supports bgrewriteaof instruction, to appendonly.aof reorganization.

Other parameters:

MaxClients 10000: Maximum number of client links

slaveof <master ip> <master port>: Make the current server slave and assign master information to it

Requirepass Password: Authorization password for current server

Masterauth <master password>: Connected to Master in a certified manner. If password protection is used in master, slave must deliver the correct authorization password in order to connect successfully. The <master password> value in this configuration entry needs to be consistent with the "Requirepass" of the Master machine.

Vm-enabled Yes:redis is a memory database that cannot receive new write requests when memory is full, so support for virtual memory is provided after redis2.0. Note, however, that all keys in Redis are placed in memory and that only the value is placed in the swap area when there is not enough memory. Although the use of virtual memory, but the basic performance is not affected, it should be noted that the vm-max-memory set to enough to lay down all key.

Vm-swap-file/tmp/redis.swap: Set the swap file path for virtual memory, not multiple Redis instance sharing

Vm-max-memory 0: Set the maximum amount of physical memory that Redis will use after the virtual memory is turned on, by default 0,redis will put all of his swap files into the swap file to minimize the use of physical memory. That is, when Vm-max-memory is set to 0, all of the value is in the disk. In a production environment, you need to set this value according to the actual situation, preferably not using the default 0.

Vm-page-size 32: Sets the page size for virtual memory. If the value is larger, if you want to place all of the content of a blog, news, and so on in value, set a larger number.

Vm-pages 134217728: Sets the total page number of the swap file. Note that the page table information is placed in physical memory, each 8 page occupies 1 bytes of RAM, and the total virtual memory size = Vm-page-size * vm-pages.

Vm-max-threads 4: Sets the number of threads that VM IO uses concurrently.

activerehashing Yes: Reset the hash table, set to Yes Redis will use 1 milliseconds of CPU time per 100 milliseconds to hash the Redis hash table to reduce memory usage. When the use of the scene has a more stringent real-time requirements, can not accept the Redis request for a 2 millisecond delay, the configuration is No. If you do not have such stringent real-time requirements, you can set to Yes so that you can free up memory as quickly as possible.

Slave-serve-stale-data Yes: If the current server is slave, if slave continues to provide services to the client when it loses communication with master, "yes" means continue and "no" indicates termination.
In the "yes" case, Slave continues to provide read-only service to the client, possibly at this time the data has expired.
In the "No" case, any data request services sent to this server (both the client and the slave of this server) will be notified of the "error"

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.