Redis master Configuration and Conf file description

Source: Internet
Author: User
Tags memory usage redis server memory redis server

Here is the configuration I used, using master-slave mode, turning off all persistence on master, and using aof persistence on slave:
$cat/opt/redis/etc/redis.conf

##### #Master Config

# # #General Configuration

Daemonize Yes to run the program #使用daemon Way, default to run daemon mode

Pidfile/tmp/redis.pid #pid文件位置

Port 6379 #使用默认端口

Timeout #client end Idle disconnect time

LogLevel Warning # logging level, default is notice, I use warning here, is to monitor the log convenience. After using warning, only the alarm will generate the log, which is very convenient to monitor the alarm by determining whether the log file is empty.

Logfile/opt/logs/redis/redis.log #日志产生的位置

Databases #默认是0, that is, only 1 db, my side set to 16, convenient for multiple applications using the same Redis server. Use the SELECTN command to confirm the use of Redis db, so that different applications will not have a problem if they use the same key.

# # #下面是SNAPSHOTTING持久化方式的策略. In order to ensure data relative security, in the following settings, the more frequent changes, snapshotting more frequent, that is, the greater the pressure, instead of spending on the persistence of resources will be more. So I chose the master-slave mode and turned off the snapshotting in master.

#save 900 1 #在900秒之内, Redis at least 1 changes are taken Redis snaps to disk

#save #在300秒之内, Redis at least 100 changes Redis take snapshots to disk

#save 10000 #在60秒之内, Redis at least 10,000 changes Redis snap to disk

Rdbcompression Yes #使用压缩

Dbfilename Dump.rdb #SNAPSHOTTING的文件名

dir/opt/data/redis/#SNAPSHOTTING文件的路径

# # #REPLICATION Settings,

#slaveof #如果这台机器是台redis Slave, you can open this setting. If I use Master-slave mode, I will turn the snapshotting off on master so that I can do it on the slave instead of on master, which can greatly improve master memory usage and system performance.

#slave-serve-stale-data Yes #如果slave cannot sync with master, can also read

### Security Settings

#requirepass aaaaaaaaa #redis性能太好, it doesn't make much sense to use a passwd.

#rename-command Flushall "" # you can turn off very dangerous commands in this way, such as the Flushall command, which empties the entire Redis server's data without having to confirm and never fail

# # #LIMIT Settings

MaxClients 0 #无client连接数量限制

MaxMemory 14GB #redis最大可使用的内存量, My server memory is 16G, if using Redis snapshotting copy-on-write lasting will write way, will use extra memory, In order to make the persistence of the operation will not use the system VM, so that Redis server performance degradation, it is recommended to retain Redis maximum use of half 8G of memory for the persistence of use, I personally feel very wasteful. I don't do persistence on master, use master-slave method

Maxmemory-policy VOLATILE-LRU # Use the LRU algorithm to delete a key that has an expiration time set, but if the program does not write a key expiration time, it is recommended that ALLKEYS-LRU be used, so that at least the Redis will not be writable.

# # #APPEND only MODE setting

AppendOnly no #不使用AOF, AoF is another way to persist, and I am not using it because this way does not guarantee data availability in the event of server or disk corruption.

Appendfsync everysec

No-appendfsync-on-rewrite No

Auto-aof-rewrite-percentage 100

Auto-aof-rewrite-min-size 64MB

# # #SLOW LOG settings

Slowlog-log-slower-than 10000 # If the operation time is greater than 0.001 seconds, log slow log, this log is recorded in memory, you can use REDIS-CLI slowlog get command to view

Maximum length of Slowlog-max-len 1024 #slow log

# # #VIRTUAL MEMORY settings

Vm-enabled no #不使用虚拟内存, in the Redis 2.4 version, the author has been very not recommended to use VMS.

Vm-swap-file/tmp/redis.swap

Vm-max-memory 0

Vm-page-size 32

Vm-pages 134217728

Vm-max-threads 4

# # #ADVANCED CONFIG settings, the following settings are mainly used to save memory, I did not modify them

Hash-max-zipmap-entries 512

Hash-max-zipmap-value 64

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

# # #INCLUDES settings, use the following configuration, you can configure some other settings, such as slave configuration

#include/path/to/local.conf

#include/path/to/other.conf

#include/opt/redis/etc/slave.conf If it's slave server, open this note

Slave configuration:
$cat/opt/redis/etc/slave.conf

##### #slave config

# # #REPLICATION settings,

slaveof redis01 6397 #如果这台机器是台redis Slave, you can open this setting. If I use Master-slave mode, I will turn the snapshotting off on master so that I can do it on the slave instead of on master, which can greatly improve master memory usage and system performance.

Slave-serve-stale-datano #如果slave cannot be synchronized with master and is set to slave unreadable to facilitate monitoring of script discovery problems.

# # #APPEND only MODE setting

appendonly Yes #在slave上使用了AOF to ensure data availability.

Other subsequent data backup work
1, with the Redis-clibgsave command every morning to a persistent masterredis data, and CP to other backup servers.
2, with the redis-clibgrewriteaof command every half hour to persist the data on the Slaveredis, and CP to other backup servers.
3, write a script, regular get master and slave on the key, see whether two sync, if not synchronized, timely alarm.

Article Source: http://www.m690.com/archives/380

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.