Redis运维手册

  • Last update: June 12, 2024
  • 1. 更改 Redis 配置

    使用 config 命令可以对Redis 的配置参数进行热修改,这样就不需要重启,如下所示:

    config get *   # 获得所有的配置项的key 
    127.0.0.1:7379> config get maxmemory 
    maxmemory 4294967296    # 改变redis的内存,推荐内存大小为 4G, 单位为byte
    127.0.0.1:7379> maxmemory 4294967296
    config get *   # 查看 
    127.0.0.1:7379> config get *

    2. 查看 Redis 的使用情况

    info  #查看redis的使用情况
    127.0.0.1:7379> info
    # Server
    redis_version:2.8.13  # Redis 服务器版本
    redis_mode:standalone  # 运行模式是单机状态,redis集群时是cluster nodes
    os:Linux3.5.0-48-generic x86_64  # 服务器的宿主操作系统
    arch_bits:64  # 架构(32 或 64 位)
    multiplexing_api:epoll  # Redis 所使用的事件处理机制
    tcp_port:7379  #  TCP/IP 监听端口
    uptime_in_seconds:11554  # redis启动至今经过的秒数
    uptime_in_days:0   # redis启动至今经过的天数

    3. Redis 运维

    3.1 Redis 单机

    启动 Redis 并查看 key 值,检查状态、远程连接操作如下所示:

    ./redis-cli -p 端口 -a 密码  # 本地启动Redis客户端,可以进行查看key值,删除key值,检查redis状态等操作,如果端口是6379的话可以省略
    ./redis-cli -h ip -p 端口 -a 密码  # 远程连接Redis服务,ip和端口为要连接的Redis服务,如果端口是6379的话可以省略

    3.2 Redis 集群

    远程连接节点、查看运行情况操作如下所示:

    ./redis-cli -h ip -c -p 端口 -a 密码   # 客户端远程连接某个节点,要输入对应的ip、端口、密码
    127.0.0.1:7379> cluster nodes    # 查看redis集群目前的主从分布和运行情况

    3.3 通用

    127.0.0.1:7379> time  # 显示服务器时间 , 时间戳(秒), 微秒数
    127.0.0.1:7379> dbsize  # 当前数据库的key的数量
    127.0.0.1:7379> set fine-1-ha "a"  # 设置 fine-1-ha 的值为 a
    127.0.0.1:7379> keys *  # 查询所有 key
    127.0.0.1:7379> keys fine*  # 模糊查询以 fine 为前缀的 key 值
    127.0.0.1:7379> keys *ha  # 模糊查询以 ha 为后缀的 key 值
    127.0.0.1:7379> DEL key1  # 清空指定的key,多个之间用空格隔开
    127.0.0.1:7379> flushall   # 清空整个 Redis 服务器的数据,谨慎使用
    127.0.0.1:7379> Flushdb  # 清空当前库所有键
    127.0.0.1:7379> exit   # 退出 Redis 客户端

    其他运维命令详情可参考 Redis 官网:http://www.redis.cn/commands.html

    XXX

    • dd

    • xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
      xxxxxx
    xxxx





    附件列表


    主题: 部署升级
    Previous
    Next
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy