美文网首页
redis.conf详解之include

redis.conf详解之include

作者: 小易哥学呀学 | 来源:发表于2021-11-13 20:08 被阅读0次

1、用法:

在 $yourPath/redis.conf 文件中添加以下配置

include /path/to/local.conf

2、用途:

模块化配置,比如所有服务都有公共的配置,每个服务还需要个性配置,可以抽离出公共配置和个性配置,在公共配置中include个性配置。

3、注意事项:

(1)对同一个配置的多次设置,总是取最后配置的值。

$yourPath需要替换为你自己的路径

/users/xiaoyi $ cat $yourPath/gexing-tcp-keepalive-400.conf 
tcp-keepalive 400

/users/xiaoyi $ cat $yourPath/gexing-tcp-keepalive-500.conf 
tcp-keepalive 500

/users/xiaoyi $ cat $yourPath/redis.conf | grep "tcp-keepalive"
include $yourPath/gexing-tcp-keepalive-500.conf 
tcp-keepalive 300
include $yourPath/gexing-tcp-keepalive-400.conf 

结果:

/users/xiaoyi $ /usr/bin/redis-server $yourPath/redis.conf
/users/xiaoyi $ redis-cli
127.0.0.1:6379> config get tcp-keepalive
1) "tcp-keepalive"
2) "400"
127.0.0.1:6379>
(2)配置文件中include的值不会被CONFIG REWRITE重写
#step1 启动redis
/users/xiaoyi $ /usr/bin/redis-server $yourPath/redis.conf

#step2
/users/xiaoyi $ redis-cli
127.0.0.1:6379> config get tcp-keepalive
1) "tcp-keepalive"
2) "400"
127.0.0.1:6379> config set tcp-keepalive 600
OK
127.0.0.1:6379> config get tcp-keepalive
1) "tcp-keepalive"
2) "600"

#参数已经生效,但是配置文件中的值不会被重写。

#step3
/users/xiaoyi $ cat $youPath/redis.conf | grep tcp-keepalive
include $youPath/gexing-tcp-keepalive-500.conf
tcp-keepalive 300
include $youPath/gexing-tcp-keepalive-400.conf

4、原生注释

# Include one or more other config files here.  This is useful if you
# have a standard template that goes to all Redis servers but also need
# to customize a few per-server settings.  Include files can include
# other files, so use this wisely.
#
# Note that option "include" won't be rewritten by command "CONFIG REWRITE"
# from admin or Redis Sentinel. Since Redis always uses the last processed
# line as value of a configuration directive, you'd better put includes
# at the beginning of this file to avoid overwriting config change at runtime.
#
# If instead you are interested in using includes to override configuration
# options, it is better to use include as the last line.
#
# include /path/to/local.conf
# include /path/to/other.conf

相关文章

  • redis.conf详解之include

    1、用法: 在 $yourPath/redis.conf 文件中添加以下配置 2、用途: 模块化配置,比如所有服务...

  • Redis.conf详解

    Redis.conf详解 单位 对大小写不敏感 包含include /path/to/local.conf 网...

  • redis.conf详解之module

    1、用法: 在 $yourPath/redis.conf 文件中添加以下配置 2、module制作: 准备工作 1...

  • redis.conf详解之timeout

    用法 单位是秒 用途 在timeout时间内如果没有数据交互,redis侧将关闭连接。没有数据交互:redis客户...

  • redis.conf详解之port

    用法 用途 指定redis监听的端口。 注意事项: 1.默认是63792.配置为0时将不监听任何端口(也就是服务没...

  • redis.conf详解之bind

    用法 绑定到本机的其中一个ip 绑定到本机的两个ip,如果10.0.0.1无效redis依旧可以启动。 绑定到本机...

  • redis.conf详解之daemonize

    用法 作为非守护进程运行 作为守护进程运行 注意事项: 默认情况下,Redis不作为守护进程运行。如果以守护进程运...

  • redis.conf详解之pidfile

    用法 注意事项: 如果pidfile文件创建失败,也不会影响redis启动。配置了daemonize或pidfil...

  • redis.conf详解之maxclients

    本文基于 redis_version:6.2.5 用法 设置一个redis实例支持的最大连接数。 注意事项: 默认...

  • Redis.conf 详解

    Redis.conf 详解 参考地址:https://www.cnblogs.com/zhang-ke/p/598...

网友评论

      本文标题:redis.conf详解之include

      本文链接:https://www.haomeiwen.com/subject/qlmxtrtx.html