• redis的配置简介


    Redis的配置文件

    redis启动的时候依赖的配置文件

    • 配置文件对单位的大小写不敏感

      # Redis configuration file example.
      #
      # Note that in order to read the configuration file, Redis must be
      # started with the file path as first argument:
      #
      # ./redis-server /path/to/redis.conf
      
      # Note on units: when memory size is needed, it is possible to specify
      # it in the usual form of 1k 5GB 4M and so forth:
      #
      # 1k => 1000 bytes
      # 1kb => 1024 bytes
      # 1m => 1000000 bytes
      # 1mb => 1024*1024 bytes
      # 1g => 1000000000 bytes
      # 1gb => 1024*1024*1024 bytes
      
    • 可以使用include来包含别的文件

      # 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.
      #
      # Notice 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
      
    • 网络模块

      bind:可以使用通配符或者自己的公网ip来使我们的redis服务能够公开

      protected-mode:是否开始保护模式

      port:绑定的端口

    • 通用的配置

      daemobize:是否开启守护进程,默认是no

      pidfile:如果是守护进程的方式运行,则需要制定这个配置文件

      loglevel:日志级别

      # Specify the server verbosity level.
      # This can be one of:
      # debug (a lot of information, useful for development/testing)
      # verbose (many rarely useful info, but not a mess like the debug level)
      # notice (moderately verbose, what you want in production probably)
      # warning (only very important / critical messages are logged)
      loglevel notice
      

      logfile:日志的文件名

      databases:数据库的数量,默认是16个数据库

      always-show-logo:是否显示开启时候的logo

    • 快照

      持久化,在规定的时间内执行了多少次的操作,则会生快照

      一般会有rdbaof两个文件

      • 默认的规则

        # Save the DB on disk:
        #
        #   save <seconds> <changes>
        #
        #   Will save the DB if both the given number of seconds and the given
        #   number of write operations against the DB occurred.
        #
        #   In the example below the behaviour will be to save:
        #   after 900 sec (15 min) if at least 1 key changed
        #   after 300 sec (5 min) if at least 10 keys changed
        #   after 60 sec if at least 10000 keys changed
        #
        #   Note: you can disable saving completely by commenting out all "save" lines.
        #
        #   It is also possible to remove all the previously configured save
        #   points by adding a save directive with a single empty string argument
        #   like in the following example:
        #
        #   save ""
        
        # 如果900s内,有一次key进行了修改,那么就进行持久化操作
        save 900 1 
        # 如果300s内,有超过10个key进行了修改,那么就进行持久化操作
        save 300 10
        # 如果60s内,有超过10000个key进行了修改,那么就进行持久化操作
        save 60 10000
        
      • stop-writes-on-bgsave-error:持久化出现错误后是否继续工作

      • rdbcompression:是否压缩rdb文件

      • rdbchecksum:保存rdb文件的时候进行校验

      • dir:rdb文件保存的目录

    • 安全

      requirepass:设置登录密码

    • 客户端

      maxclients:最大客户端数

      maxmemory <bytes>:redis最大内存设置

      maxmemory-policy:内存达到上限后的处理策略

      # volatile-lru -> remove the key with an expire set using an LRU algorithm
      # allkeys-lru -> remove any key according to the LRU algorithm
      # volatile-random -> remove a random key with an expire set
      # allkeys-random -> remove a random key, any key
      # volatile-ttl -> remove the key with the nearest expire time (minor TTL)
      # noeviction -> don't expire at all, just return an error on write operations
      #
      # Note: with any of the above policies, Redis will return an error on write
      #       operations, when there are no suitable keys for eviction.
      #
      #       At the date of writing these commands are: set setnx setex append
      #       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
      #       sinter sinterstore sunion sunionstore sdiff sdiffstore zadd zincrby
      #       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
      #       getset mset msetnx exec sort
      #
      # The default is:
      #
      # maxmemory-policy noeviction
      
    • APPEND ONLY模式,aof配置

      appendonly:是否开启aof

      appendfilename:aof的文件名

      # appendfsync always ## 每次修改都执行一次
      appendfsync everysec  ## 每秒都执行一次,可能会丢失1s的数据
      # appendfsync no ## 不执行不同步
      
  • 相关阅读:
    [BZOJ1584][Usaco2009 Mar]Cleaning Up 打扫卫生
    CSS浮动
    Django by example -----1总结
    C#函数重载
    linux目录的特点
    Linux调优
    linux
    对齐方式
    19-10-25-G-悲伤
    19-10-24-H
  • 原文地址:https://www.cnblogs.com/ivy-blogs/p/13918194.html
Copyright © 2020-2023  润新知