Redis Series III: Redis common settings

Source: Internet
Author: User
Tags syslog

I. Redis configuration file redis.conf location

CentOS: Default in/etc/redis.conf

Ubuntu: You can copy the configuration file to the directory from the extracted directory

Ii. specifying a profile when starting Redis

$redis-server/etc/redis.conf

Iii. Common Configuration Instructions

Daemonize Yes #设置后台运行, default Redis does not run in the background

LogFile "/var/log/redis.log" #设置log文件地址, by default using standard output, which is printed directly on the windows of the command-line terminal

Requirepass 123456 # Setting up a Redis connection password

Port 6379 #设置监听端口

Pidfile/var/run/redis.pid #设置pid文件路径

Bind 127.0.0.1 #绑定主机ip

Unixsocket/tmp/redis.sock #设置sock文件路径

Timeout #设置超时时间, default is 300s

loglevel verbose #日志等级, option has debug,verbose,notice,warning default is Erbose

LogFile stdout #日志记录方式, default is stdout

Syslog-enabled no #日志记录到系统日志中, default is no

Syslog-ident Redis #指定系统日志标识

Syslog-facility local0 #指定系统日志设备, default is Local0

Databases #可用数据库数, the default value is 16, the default database is 0

Save <seconds> <changes> #在多长时间内, the number of update operations, the data is synchronized to the data file.

Save 1 #15min内至少1个key被改变

Save #5min内至少有300个key被改变

Save 10000 #60s内至少有10000个key被改变

Rdbcompression Yes #存储至本地数据库时是否压缩数据, the default is Yes

Dbfilename Dump.rdb #本地数据库文件名, default is Dump.rdb

Dir./#本地数据库存放路径, default is./

Slaveof <masterip> <masterport> #当本机为从服务时, setting the IP and port of the primary service

Masterauth <master-password> #主服务的连接密码

Slave-serve-stale-data Yes

MaxClients #最大连接数, not limited by default

MaxMemory <bytes> #设置最大内存, when the maximum memory setting is reached, Redis tries to clear the expired or expiring key first, and when this method is processed, it still reaches the maximum memory setting and no more write operations are possible

MaxMemory setting policy

Maxmemory-policy Volatile-lru #maxmemory设置策略, the default is VOLATILE-LRU.

Maxmemory-samples 3

AppendOnly no #是否在每次更新操作后进行日志记录, if not turned on, may result in loss of data over a period of time when power is lost. Because the Redis itself synchronizes data files in sync with the save conditions above, some data will only exist in memory for a period of time. Default is No

Appendfilename appendonly.aof #更新日志文件名, default is Appendonly.aof

Three different synchronization modes supported by Redis:

# No:don ' t Fsync, just let the OS flush the data when it wants. Faster. Wait for OS to sync data cache to hard disk

# Always:fsync after every write to the append only log. Slow, safest. Call Fsync () to write data to disk after each update operation

# Everysec:fsync only if one second passed since the last fsync. Compromise. Synchronize once per second

Appendfsync everysec #更新日志条件, default is Everysec

No-appendfsync-on-rewrite No

Slowlog-log-slower-than 10000 #设置redis Slow log time, which only includes command execution time, not including IO operation time, such as client connection, response time, etc. The unit is microseconds (one out of 10,000 seconds) and the default is 10000. Negative indicates that disabling slow log,0 means logging all commands.

Slowlog-max-len #slowlog最大长度1024. This consumes memory and uses Slowlog reset to reclaim Slowlog memory.

#在redis2.4, it is strongly not recommended to use virtual memory.

Vm-enabled no #是否使用虚拟内存, default is no

Vm-swap-file/tmp/redis.swap #虚拟内存文件路径, the default is/tmp/redis.swap, and multiple Redis instances cannot share virtual memory files.

Vm-max-memory 0 #设置最大vm, default is 0, all value exists on disk.

Vm-page-size #设置vm的page大小, default is 32

Vm-pages 134217728 #设置swap文件中最大memory pages, default is 134217728. Swap size =vm-page-size * vm-pages

Vm-max-threads 4 #vm同时运行的最大io线程

#指定在超过一定的数量或者最大的元素超过某一临界值时, a special hashing algorithm is used

Hash-max-zipmap-entries #配置字段最多512个

Hash-max-zipmap-value #配置value最大为64字节

List-max-ziplist-entries 512

List-max-ziplist-value 64

Set-max-intset-entries 512

activerehashing Yes #是否重置hash表

Include/path/to/other.conf #引用其他配置文件

Redis Series One: initial knowledge of Redis

Redis Series II: Data types supported by Redis and how to use them (i)

Redis Series II: Data types supported by Redis and how to use them (ii)

Redis Series III: Redis common settings

Redis Series III: Redis common settings

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.