##### #Master config # # #General Configure the Daemonize yes #使用daemon Run the program, default to run not daemon pidfile/tmp/redis.pid #pid文件位置 Port 2001 #根据服务规定的端口填写 (default 6379) Timeout 30 # c Lient End Idle disconnect time LogLevel warning #日志记录级别, the 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 16 #默认是0, which is only 1 db, I set it to 16, Convenient for multiple applications using the same Redis server. Use the Select N 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 "" #可以用这种方式关掉非常危险的命令, such as the Flushall command, which empties the entire Redis server's data and does not have to be confirmed and never fail # # #LIMIT Settings MaxClients 0 #无client连接数量限制 MaxMemory 14GB #redis最大可使用的内存量, my server memory is 16G, if you use Redis snapshotting copy-on-write lasting write way, will use extra memory, in order to make the persistence operation will not use the system VM, Redis server performance degradation, it is recommended to retain Redis maximum use of half 8G of memory to be left to the persistence of use, I personally feel very wasteful. I don't do persistence on master, use master-slave method Maxmemory-policy Volatile-lru #使用LRU算法删除设置了过期时间的key, but if the program does not write the time to write key expiration time, it is recommended to use ALLKEYS-LRU, so that at least ensure that 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 #如果操作时间大于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 |