zoukankan      html  css  js  c++  java
  • 修改 redis 配置参数查看和修改,无需重启

    Redis Config Get 命令

    Redis Config Get 命令用于获取 redis 服务的配置参数。

    在 Redis 2.4 版本中, 有部分参数没有办法用 CONFIG GET 访问,但是在最新的 Redis 2.6 版本中,所有配置参数都已经可以用 CONFIG GET 访问了。

    语法

    redis Config Get 命令基本语法如下:

    redis 127.0.0.1:6379> CONFIG GET parameter
    

    可用版本

    >= 2.0.0

    返回值

    给定配置参数的值。

    实例

    redis 127.0.0.1:6379> config get *max-*-entries* 
    1) "hash-max-zipmap-entries"
    2) "512"
    3) "list-max-ziplist-entries"
    4) "512"
    5) "set-max-intset-entries"
    6) "512"
    

     

    Redis Config Set 命令

    Redis Config Set 命令可以动态地调整 Redis 服务器的配置(configuration)而无须重启。

    你可以使用它修改配置参数,或者改变 Redis 的持久化(Persistence)方式。

    语法

    redis Config Set 命令基本语法如下:

    redis 127.0.0.1:6379> CONFIG Set parameter value 
    

    可用版本

    >= 2.0.0

    返回值

    当设置成功时返回 OK ,否则返回一个错误。

    实例

    redis 127.0.0.1:6379> CONFIG GET slowlog-max-len
    1) "slowlog-max-len"
    2) "1024"
    
    redis 127.0.0.1:6379> CONFIG SET slowlog-max-len 10086
    OK
    
    redis 127.0.0.1:6379> CONFIG GET slowlog-max-len
    1) "slowlog-max-len"
    2) "10086"
    

    实际案例

    redis由于key删除策略配置错误导致内存满,不能写入redis。修改key删除策略,不重启redis

    1、查看配置文件及现在redis加载中的配置

    [root@w15 redis]# cat 6379.conf|grep maxmemory-policy
    # according to the eviction policy selected (see maxmemory-policy).
    maxmemory-policy noeviction
    [root@w15 redis]# redis-cli -p 6379
    127.0.0.1:6379> CONFIG GET maxmemory-policy
    1) "maxmemory-policy"
    2) "noeviction"
    127.0.0.1:6379> 
    

    2、修改配置文件(下次redis重启生效)以及在线修改redis配置

    [root@w15 redis]# cat 6379.conf|grep maxmemory-policy
    # according to the eviction policy selected (see maxmemory-policy).
    maxmemory-policy volatile-lru
    [root@w15 redis]# redis-cli -p 6379
    127.0.0.1:6379> CONFIG GET maxmemory-policy
    1) "maxmemory-policy"
    2) "volatile-lru"
    127.0.0.1:16379> exit
    
  • 相关阅读:
    eclipse控制台出现中文乱码的问题
    运行jar包
    [MongoDB]------windos下的安装部署与基础使用
    SQLMap-----初识
    序言(第一次写随笔,怎么才能装成经常写的样子呢)
    php7.4编译(centos)
    NGINX 2
    NGINX 1
    LVS的DR模式与NET模式的负载均衡实验
    命令在线查询
  • 原文地址:https://www.cnblogs.com/xzlive/p/14363351.html
Copyright © 2011-2022 走看看