Redis7 有很多新的功能、bug修改、特性优化,因此也伴随着很多新配置和变化,本文进行逐一说明
注:相关推荐配置只代表个人观点,实际要具体情况具体分析,没有万能配置。
默认:appendonlydir,动态修改:no
定义存储aof文件的目录名,它和配置dir组成绝对目录。
和部署目录相关:决定是端口号或者默认值。
默认:no,动态修改:yes
aof是否支持时间戳,如设置会变成:
*3
$3
set
$5
hello
$5
world
结合现有体系决定。
注:有关新的aof,会有单独文章说明。
默认值:10,动态修改:true
当执行shutdown命令时,为slave节点复制剩余offset的最大等待时间,一定程度上提高一致性。
如果该配置为0,则该功能失效。
在Redis cron内如果发现shutdown-timeout不等于0,则会等待相关slave节点复制完毕。相关函数过长如感兴趣自行阅读。
server.c cron
if (isShutdownInitiated()) {
if (server.mstime >= server.shutdown_mstime || isReadyToShutdown()) {
if (finishShutdown() == C_OK) exit(0);
}
}
可根据自身写入、网络等等情况进行配置,个人认为默认值基本OK。
默认值:0,动态修改:true
(a) 对单个客户端输出缓冲区限制:
client-output-buffer-limit normal|slave|pubsub hardlimit sortlimit secends
(b) 对单个客户端的输入缓冲区,之前固定为1gb,在4.0之后改为可配置
client-query-buffer-limit 1gb
给所有clients加了最大内存的限制,当超过该限制后,Redis将会按照一定策略杀掉问题客户端,称为client eviction。
有两种配置方式:
(a) 具体值
maxmemory-clients 1g
(b) 百分比:为maxmemory配置的XX%
maxmemory-clients 10%
如果整机部署密度较高,建议配置一定百分比,但会有客户端被干掉的风险。
默认:0,动态修改:yes
无盘复制下,repl-diskless-sync-delay保证串行,repl-diskless-sync-max-replicas是在repl-diskless-sync-delay内的并行个数。
可根据从节点个数,机器部署密度等情况设置。ps: 通常都是一主一从,不需要该配置。
hash-max-listpack-entries 512
hash-max-listpack-value 64
list-max-listpack-size -2
zset-max-listpack-entries 128
zset-max-listpack-value 64
动态修改:yes
Redis 7中ziplist被listpack替代,所以相关配置都变为listpack,有关listpack会有单独文章说明。
建议结合单核cpu使用量、数据量等综合评估成本收益、性能、可用性。
默认:5000,动态修改:yes,设置为0关闭该功能
lua-time-limit的别名,分别服务于lua、function、module的一些特殊命令
谨慎设置,超时后Redis只允许一些特殊命令(如下),其他命令均返回a BUSY error.
SCRIPT KILL, FUNCTION KILL, SHUTDOWN NOSAVE and possibly some module specific 'allow-busy' commands
默认:yes,动态修改:yes
是否开启命令latency追踪
开启
默认:50 99 99.9,动态修改:yes
对应p50(中位数)、p99、p99.9每个命令的耗时,例如:
info latencystats
latency_percentiles_usec_scan:p50=270.335,p99=7110.655,p99.9=10682.367
latency_percentiles_usec_slowlog|get:p50=6.015,p99=30.079,p99.9=34.047
latency_percentiles_usec_role:p50=9.023,p99=9.023,p99.9=9.023
latency_percentiles_usec_set:p50=1.003,p99=3.007,p99.9=7.007
latency_percentiles_usec_psync:p50=274.431,p99=274.431,p99.9=274.431
latency_percentiles_usec_strlen:p50=7.007,p99=7.007,p99.9=7.007
latency_percentiles_usec_config|get:p50=12.031,p99=72.191,p99.9=83.455
latency_percentiles_usec_config|set:p50=1769.471,p99=1769.471,p99.9=1769.471
latency_percentiles_usec_config|rewrite:p50=1015.807,p99=1015.807,p99.9=1015.807
latency_percentiles_usec_subscribe:p50=3.007,p99=4.015,p99.9=4.015
latency_percentiles_usec_replconf:p50=1.003,p99=2.007,p99.9=4.015
latency_percentiles_usec_get:p50=0.001,p99=3.007,p99.9=3.007
latency_percentiles_usec_info:p50=59.135,p99=1277.951,p99.9=1925.119
latency_percentiles_usec_command:p50=1310.719,p99=1310.719,p99.9=1310.719
latency_percentiles_usec_publish:p50=7.007,p99=11.007,p99.9=15.039
latency_percentiles_usec_del:p50=1.003,p99=5.023,p99.9=18.047
latency_percentiles_usec_client|setname:p50=0.001,p99=2.007,p99.9=2.007
latency_percentiles_usec_expire:p50=1.003,p99=6.015,p99.9=20.095
latency_percentiles_usec_mget:p50=2.007,p99=4.015,p99.9=7.007
latency_percentiles_usec_ping:p50=1.003,p99=2.007,p99.9=4.015
latency_percentiles_usec_type:p50=1.003,p99=5.023,p99.9=5.023
latency_percentiles_usec_dbsize:p50=1.003,p99=2.007,p99.9=3.007
可以自行调配
默认:0,动态修改:no,范围0~65535
redis cluster默认的通信(bus)端口 = port + 10000,该值可以动态设置指定端口,例如
port=6379 cluster-port=0 bus-port=16379
port=6380 cluster-port=5000 bus-port=5000
port=6381 cluster-port=15000 bus-port=15000
如不是强烈需要,否则不要设置,会增加复杂性。
默认:"",动态修改:yes
指定了redis作为客户端时,建立连接时指定源ip地址。包括:
如果有多个ip地址,并且有将正常请求和redis内部请求分开的需求时,可以使用此配置;
否则,不建议设置。
默认:ip,动态修改:yes, 有三个值:ip、hostname、unknown-endpoint
7.0后redis cluster除了支持ip,还支持了hostname。
有强需求可以使用。
默认:空,动态修改:yes
如果cluster-preferred-endpoint-type设置为hostname,那cluster-announce-hostname就是具体的值。
有强需求可以使用。
默认:yes,动态修改:yes
当redis cluster处于down state时,是否可以继续使用shard pubsub。
保持默认值,但是不建议在集群版用这个功能,单独部署一个redis sentinel做pubsub会更好。
默认:0(表示无穷大),动态修改:yes
针对redis cluster中每一个cluster bus link's send buffer容量进行限制,超过这个限制会被“干掉”。
相关查看命令:cluster links
相关统计 info memory中的mem_cluster_links是link的总内存
建议配置一个合理值,因为正常情况下每个link的内存量不会很大。
默认:no,动态修改:no
设置是否允许对保护的配置进行动态配置;目前主要包括:
推荐默认设置即可。
默认:no,动态修改:no
为了安全考虑,禁止掉debug命令,且不能动态修改
debug命令在一些场景很有帮助,但对安全性有一些影响,需要综合评价,一定注意此配置不可以动态修改。
默认:no,动态修改:no
为了安全考虑,禁止掉module命令,且不能动态修改
是否需要module来决定
默认:2MB,动态修改:yes
maximum single read or write chunk size
如无特殊,默认即可。
随着一些新功能的加入,Redis也添加了很多新配置,例如appenddirname、maxmemory-clients、latency-*,listpack相关等,同时有一些默认值也发生变化(默认禁止module和debug、默认开启无盘复制)
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞1
添加新评论0 条评论