• 设为首页
  • 收藏本站
  • 积分充值
  • VIP赞助
  • 手机版
  • 微博
  • 微信
    微信公众号 添加方式:
    1:搜索微信号(888888
    2:扫描左侧二维码
  • 快捷导航
    福建二哥 门户 查看主题

    如何使用docker compose一键部署redis服务

    发布者: 雪落无声 | 发布时间: 2025-6-19 12:43| 查看数: 93| 评论数: 0|帖子模式

    1、创建安装目录
    1. mkdir /data/redis/  -p && cd /data/redis
    复制代码
    2、创建docker-compose.yml文件
    1. version: '3'
    2. services:
    3.   redis:
    4.     image: registry.cn-hangzhou.aliyuncs.com/xiaopangpang/redis:7.0.5
    5.     container_name: redis
    6.     restart: always
    7.     environment:
    8.       TZ: Asia/Shanghai
    9.       LANG: en_US.UTF-8
    10.     ports:
    11.       - "6379:6379"
    12.     volumes:
    13.       - "./redis/data:/data"
    14.       - "./redis/config/redis.conf:/etc/redis/redis.conf"
    15.     command: redis-server /etc/redis/redis.conf --requirepass 123456 --appendonly yes
    复制代码
    3、创建redis.conf配置文件
    1. # Redis configuration file example.
    2. #
    3. # Note that in order to read the configuration file, Redis must be
    4. # started with the file path as first argument:
    5. #
    6. # ./redis-server /path/to/redis.conf

    7. # Note on units: when memory size is needed, it is possible to specify
    8. # it in the usual form of 1k 5GB 4M and so forth:
    9. #
    10. # 1k => 1000 bytes
    11. # 1kb => 1024 bytes
    12. # 1m => 1000000 bytes
    13. # 1mb => 1024*1024 bytes
    14. # 1g => 1000000000 bytes
    15. # 1gb => 1024*1024*1024 bytes
    16. #
    17. # units are case insensitive so 1GB 1Gb 1gB are all the same.

    18. ################################## INCLUDES ###################################

    19. # Include one or more other config files here.  This is useful if you
    20. # have a standard template that goes to all Redis servers but also need
    21. # to customize a few per-server settings.  Include files can include
    22. # other files, so use this wisely.
    23. #
    24. # Note that option "include" won't be rewritten by command "CONFIG REWRITE"
    25. # from admin or Redis Sentinel. Since Redis always uses the last processed
    26. # line as value of a configuration directive, you'd better put includes
    27. # at the beginning of this file to avoid overwriting config change at runtime.
    28. #
    29. # If instead you are interested in using includes to override configuration
    30. # options, it is better to use include as the last line.
    31. #
    32. # Included paths may contain wildcards. All files matching the wildcards will
    33. # be included in alphabetical order.
    34. # Note that if an include path contains a wildcards but no files match it when
    35. # the server is started, the include statement will be ignored and no error will
    36. # be emitted.  It is safe, therefore, to include wildcard files from empty
    37. # directories.
    38. #
    39. # include /path/to/local.conf
    40. # include /path/to/other.conf
    41. # include /path/to/fragments/*.conf
    42. #

    43. ################################## MODULES #####################################

    44. # Load modules at startup. If the server is not able to load modules
    45. # it will abort. It is possible to use multiple loadmodule directives.
    46. #
    47. # loadmodule /path/to/my_module.so
    48. # loadmodule /path/to/other_module.so

    49. ################################## NETWORK #####################################

    50. # By default, if no "bind" configuration directive is specified, Redis listens
    51. # for connections from all available network interfaces on the host machine.
    52. # It is possible to listen to just one or multiple selected interfaces using
    53. # the "bind" configuration directive, followed by one or more IP addresses.
    54. # Each address can be prefixed by "-", which means that redis will not fail to
    55. # start if the address is not available. Being not available only refers to
    56. # addresses that does not correspond to any network interface. Addresses that
    57. # are already in use will always fail, and unsupported protocols will always BE
    58. # silently skipped.
    59. #
    60. # Examples:
    61. #
    62. # bind 192.168.1.100 10.0.0.1     # listens on two specific IPv4 addresses
    63. # bind 127.0.0.1 ::1              # listens on loopback IPv4 and IPv6
    64. # bind * -::*                     # like the default, all available interfaces
    65. #
    66. # ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
    67. # internet, binding to all the interfaces is dangerous and will expose the
    68. # instance to everybody on the internet. So by default we uncomment the
    69. # following bind directive, that will force Redis to listen only on the
    70. # IPv4 and IPv6 (if available) loopback interface addresses (this means Redis
    71. # will only be able to accept client connections from the same host that it is
    72. # running on).
    73. #
    74. # IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
    75. # COMMENT OUT THE FOLLOWING LINE.
    76. #
    77. # You will also need to set a password unless you explicitly disable protected
    78. # mode.
    79. # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    80. # 注释允许外部访问redis
    81. # bind 127.0.0.1 -::1

    82. # By default, outgoing connections (from replica to master, from Sentinel to
    83. # instances, cluster bus, etc.) are not bound to a specific local address. In
    84. # most cases, this means the operating system will handle that based on routing
    85. # and the interface through which the connection goes out.
    86. #
    87. # Using bind-source-addr it is possible to configure a specific address to bind
    88. # to, which may also affect how the connection gets routed.
    89. #
    90. # Example:
    91. #
    92. # bind-source-addr 10.0.0.1

    93. # Protected mode is a layer of security protection, in order to avoid that
    94. # Redis instances left open on the internet are accessed and exploited.
    95. #
    96. # When protected mode is on and the default user has no password, the server
    97. # only accepts local connections from the IPv4 address (127.0.0.1), IPv6 address
    98. # (::1) or Unix domain sockets.
    99. #
    100. # By default protected mode is enabled. You should disable it only if
    101. # you are sure you want clients from other hosts to connect to Redis
    102. # even if no authentication is configured.
    103. protected-mode yes

    104. # Redis uses default hardened security configuration directives to reduce the
    105. # attack surface on innocent users. Therefore, several sensitive configuration
    106. # directives are immutable, and some potentially-dangerous commands are blocked.
    107. #
    108. # Configuration directives that control files that Redis writes to (e.g., 'dir'
    109. # and 'dbfilename') and that aren't usually modified during runtime
    110. # are protected by making them immutable.
    111. #
    112. # Commands that can increase the attack surface of Redis and that aren't usually
    113. # called by users are blocked by default.
    114. #
    115. # These can be exposed to either all connections or just local ones by setting
    116. # each of the configs listed below to either of these values:
    117. #
    118. # no    - Block for any connection (remain immutable)
    119. # yes   - Allow for any connection (no protection)
    120. # local - Allow only for local connections. Ones originating from the
    121. #         IPv4 address (127.0.0.1), IPv6 address (::1) or Unix domain sockets.
    122. #
    123. # enable-protected-configs no
    124. # enable-debug-command no
    125. # enable-module-command no

    126. # Accept connections on the specified port, default is 6379 (IANA #815344).
    127. # If port 0 is specified Redis will not listen on a TCP socket.
    128. port 6379

    129. # TCP listen() backlog.
    130. #
    131. # In high requests-per-second environments you need a high backlog in order
    132. # to avoid slow clients connection issues. Note that the Linux kernel
    133. # will silently truncate it to the value of /proc/sys/net/core/somaxconn so
    134. # make sure to raise both the value of somaxconn and tcp_max_syn_backlog
    135. # in order to get the desired effect.
    136. tcp-backlog 511

    137. # Unix socket.
    138. #
    139. # Specify the path for the Unix socket that will be used to listen for
    140. # incoming connections. There is no default, so Redis will not listen
    141. # on a unix socket when not specified.
    142. #
    143. # unixsocket /run/redis.sock
    144. # unixsocketperm 700

    145. # Close the connection after a client is idle for N seconds (0 to disable)
    146. timeout 0

    147. # TCP keepalive.
    148. #
    149. # If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
    150. # of communication. This is useful for two reasons:
    151. #
    152. # 1) Detect dead peers.
    153. # 2) Force network equipment in the middle to consider the connection to be
    154. #    alive.
    155. #
    156. # On Linux, the specified value (in seconds) is the period used to send ACKs.
    157. # Note that to close the connection the double of the time is needed.
    158. # On other kernels the period depends on the kernel configuration.
    159. #
    160. # A reasonable value for this option is 300 seconds, which is the new
    161. # Redis default starting with Redis 3.2.1.
    162. tcp-keepalive 300

    163. # Apply OS-specific mechanism to mark the listening socket with the specified
    164. # ID, to support advanced routing and filtering capabilities.
    165. #
    166. # On Linux, the ID represents a connection mark.
    167. # On FreeBSD, the ID represents a socket cookie ID.
    168. # On OpenBSD, the ID represents a route table ID.
    169. #
    170. # The default value is 0, which implies no marking is required.
    171. # socket-mark-id 0

    172. ################################# TLS/SSL #####################################

    173. # By default, TLS/SSL is disabled. To enable it, the "tls-port" configuration
    174. # directive can be used to define TLS-listening ports. To enable TLS on the
    175. # default port, use:
    176. #
    177. # port 0
    178. # tls-port 6379

    179. # Configure a X.509 certificate and private key to use for authenticating the
    180. # server to connected clients, masters or cluster peers.  These files should be
    181. # PEM formatted.
    182. #
    183. # tls-cert-file redis.crt
    184. # tls-key-file redis.key
    185. #
    186. # If the key file is encrypted using a passphrase, it can be included here
    187. # as well.
    188. #
    189. # tls-key-file-pass secret

    190. # Normally Redis uses the same certificate for both server functions (accepting
    191. # connections) and client functions (replicating from a master, establishing
    192. # cluster bus connections, etc.).
    193. #
    194. # Sometimes certificates are issued with attributes that designate them as
    195. # client-only or server-only certificates. In that case it may be desired to use
    196. # different certificates for incoming (server) and outgoing (client)
    197. # connections. To do that, use the following directives:
    198. #
    199. # tls-client-cert-file client.crt
    200. # tls-client-key-file client.key
    201. #
    202. # If the key file is encrypted using a passphrase, it can be included here
    203. # as well.
    204. #
    205. # tls-client-key-file-pass secret

    206. # Configure a DH parameters file to enable Diffie-Hellman (DH) key exchange,
    207. # required by older versions of OpenSSL (<3.0). Newer versions do not require
    208. # this configuration and recommend against it.
    209. #
    210. # tls-dh-params-file redis.dh

    211. # Configure a CA certificate(s) bundle or directory to authenticate TLS/SSL
    212. # clients and peers.  Redis requires an explicit configuration of at least one
    213. # of these, and will not implicitly use the system wide configuration.
    214. #
    215. # tls-ca-cert-file ca.crt
    216. # tls-ca-cert-dir /etc/ssl/certs

    217. # By default, clients (including replica servers) on a TLS port are required
    218. # to authenticate using valid client side certificates.
    219. #
    220. # If "no" is specified, client certificates are not required and not accepted.
    221. # If "optional" is specified, client certificates are accepted and must be
    222. # valid if provided, but are not required.
    223. #
    224. # tls-auth-clients no
    225. # tls-auth-clients optional

    226. # By default, a Redis replica does not attempt to establish a TLS connection
    227. # with its master.
    228. #
    229. # Use the following directive to enable TLS on replication links.
    230. #
    231. # tls-replication yes

    232. # By default, the Redis Cluster bus uses a plain TCP connection. To enable
    233. # TLS for the bus protocol, use the following directive:
    234. #
    235. # tls-cluster yes

    236. # By default, only TLSv1.2 and TLSv1.3 are enabled and it is highly recommended
    237. # that older formally deprecated versions are kept disabled to reduce the attack surface.
    238. # You can explicitly specify TLS versions to support.
    239. # Allowed values are case insensitive and include "TLSv1", "TLSv1.1", "TLSv1.2",
    240. # "TLSv1.3" (OpenSSL >= 1.1.1) or any combination.
    241. # To enable only TLSv1.2 and TLSv1.3, use:
    242. #
    243. # tls-protocols "TLSv1.2 TLSv1.3"

    244. # Configure allowed ciphers.  See the ciphers(1ssl) manpage for more information
    245. # about the syntax of this string.
    246. #
    247. # Note: this configuration applies only to <= TLSv1.2.
    248. #
    249. # tls-ciphers DEFAULT:!MEDIUM

    250. # Configure allowed TLSv1.3 ciphersuites.  See the ciphers(1ssl) manpage for more
    251. # information about the syntax of this string, and specifically for TLSv1.3
    252. # ciphersuites.
    253. #
    254. # tls-ciphersuites TLS_CHACHA20_POLY1305_SHA256

    255. # When choosing a cipher, use the server's preference instead of the client
    256. # preference. By default, the server follows the client's preference.
    257. #
    258. # tls-prefer-server-ciphers yes

    259. # By default, TLS session caching is enabled to allow faster and less expensive
    260. # reconnections by clients that support it. Use the following directive to disable
    261. # caching.
    262. #
    263. # tls-session-caching no

    264. # Change the default number of TLS sessions cached. A zero value sets the cache
    265. # to unlimited size. The default size is 20480.
    266. #
    267. # tls-session-cache-size 5000

    268. # Change the default timeout of cached TLS sessions. The default timeout is 300
    269. # seconds.
    270. #
    271. # tls-session-cache-timeout 60

    272. ################################# GENERAL #####################################

    273. # By default Redis does not run as a daemon. Use 'yes' if you need it.
    274. # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
    275. # When Redis is supervised by upstart or systemd, this parameter has no impact.
    276. daemonize no

    277. # If you run Redis from upstart or systemd, Redis can interact with your
    278. # supervision tree. Options:
    279. #   supervised no      - no supervision interaction
    280. #   supervised upstart - signal upstart by putting Redis into SIGSTOP mode
    281. #                        requires "expect stop" in your upstart job config
    282. #   supervised systemd - signal systemd by writing READY=1 to $NOTIFY_SOCKET
    283. #                        on startup, and updating Redis status on a regular
    284. #                        basis.
    285. #   supervised auto    - detect upstart or systemd method based on
    286. #                        UPSTART_JOB or NOTIFY_SOCKET environment variables
    287. # Note: these supervision methods only signal "process is ready."
    288. #       They do not enable continuous pings back to your supervisor.
    289. #
    290. # The default is "no". To run under upstart/systemd, you can simply uncomment
    291. # the line below:
    292. #
    293. # supervised auto

    294. # If a pid file is specified, Redis writes it where specified at startup
    295. # and removes it at exit.
    296. #
    297. # When the server runs non daemonized, no pid file is created if none is
    298. # specified in the configuration. When the server is daemonized, the pid file
    299. # is used even if not specified, defaulting to "/var/run/redis.pid".
    300. #
    301. # Creating a pid file is best effort: if Redis is not able to create it
    302. # nothing bad happens, the server will start and run normally.
    303. #
    304. # Note that on modern Linux systems "/run/redis.pid" is more conforming
    305. # and should be used instead.
    306. pidfile /var/run/redis_6379.pid

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

    314. # Specify the log file name. Also the empty string can be used to force
    315. # Redis to log on the standard output. Note that if you use standard
    316. # output for logging but daemonize, logs will be sent to /dev/null
    317. logfile ""

    318. # To enable logging to the system logger, just set 'syslog-enabled' to yes,
    319. # and optionally update the other syslog parameters to suit your needs.
    320. # syslog-enabled no

    321. # Specify the syslog identity.
    322. # syslog-ident redis

    323. # Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
    324. # syslog-facility local0

    325. # To disable the built in crash log, which will possibly produce cleaner core
    326. # dumps when they are needed, uncomment the following:
    327. #
    328. # crash-log-enabled no

    329. # To disable the fast memory check that's run as part of the crash log, which
    330. # will possibly let redis terminate sooner, uncomment the following:
    331. #
    332. # crash-memcheck-enabled no

    333. # Set the number of databases. The default database is DB 0, you can select
    334. # a different one on a per-connection basis using SELECT <dbid> where
    335. # dbid is a number between 0 and 'databases'-1
    336. databases 16

    337. # By default Redis shows an ASCII art logo only when started to log to the
    338. # standard output and if the standard output is a TTY and syslog logging is
    339. # disabled. Basically this means that normally a logo is displayed only in
    340. # interactive sessions.
    341. #
    342. # However it is possible to force the pre-4.0 behavior and always show a
    343. # ASCII art logo in startup logs by setting the following option to yes.
    344. always-show-logo no

    345. # By default, Redis modifies the process title (as seen in 'top' and 'ps') to
    346. # provide some runtime information. It is possible to disable this and leave
    347. # the process name as executed by setting the following to no.
    348. set-proc-title yes

    349. # When changing the process title, Redis uses the following template to construct
    350. # the modified title.
    351. #
    352. # Template variables are specified in curly brackets. The following variables are
    353. # supported:
    354. #
    355. # {title}           Name of process as executed if parent, or type of child process.
    356. # {listen-addr}     Bind address or '*' followed by TCP or TLS port listening on, or
    357. #                   Unix socket if only that's available.
    358. # {server-mode}     Special mode, i.e. "[sentinel]" or "[cluster]".
    359. # {port}            TCP port listening on, or 0.
    360. # {tls-port}        TLS port listening on, or 0.
    361. # {unixsocket}      Unix domain socket listening on, or "".
    362. # {config-file}     Name of configuration file used.
    363. #
    364. proc-title-template "{title} {listen-addr} {server-mode}"

    365. ################################ SNAPSHOTTING  ################################

    366. # Save the DB to disk.
    367. #
    368. # save <seconds> <changes> [<seconds> <changes> ...]
    369. #
    370. # Redis will save the DB if the given number of seconds elapsed and it
    371. # surpassed the given number of write operations against the DB.
    372. #
    373. # Snapshotting can be completely disabled with a single empty string argument
    374. # as in following example:
    375. #
    376. # save ""
    377. #
    378. # Unless specified otherwise, by default Redis will save the DB:
    379. #   * After 3600 seconds (an hour) if at least 1 change was performed
    380. #   * After 300 seconds (5 minutes) if at least 100 changes were performed
    381. #   * After 60 seconds if at least 10000 changes were performed
    382. #
    383. # You can set these explicitly by uncommenting the following line.
    384. #
    385. # save 3600 1 300 100 60 10000

    386. # By default Redis will stop accepting writes if RDB snapshots are enabled
    387. # (at least one save point) and the latest background save failed.
    388. # This will make the user aware (in a hard way) that data is not persisting
    389. # on disk properly, otherwise chances are that no one will notice and some
    390. # disaster will happen.
    391. #
    392. # If the background saving process will start working again Redis will
    393. # automatically allow writes again.
    394. #
    395. # However if you have setup your proper monitoring of the Redis server
    396. # and persistence, you may want to disable this feature so that Redis will
    397. # continue to work as usual even if there are problems with disk,
    398. # permissions, and so forth.
    399. stop-writes-on-bgsave-error yes

    400. # Compress string objects using LZF when dump .rdb databases?
    401. # By default compression is enabled as it's almost always a win.
    402. # If you want to save some CPU in the saving child set it to 'no' but
    403. # the dataset will likely be bigger if you have compressible values or keys.
    404. rdbcompression yes

    405. # Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
    406. # This makes the format more resistant to corruption but there is a performance
    407. # hit to pay (around 10%) when saving and loading RDB files, so you can disable it
    408. # for maximum performances.
    409. #
    410. # RDB files created with checksum disabled have a checksum of zero that will
    411. # tell the loading code to skip the check.
    412. rdbchecksum yes

    413. # Enables or disables full sanitization checks for ziplist and listpack etc when
    414. # loading an RDB or RESTORE payload. This reduces the chances of a assertion or
    415. # crash later on while processing commands.
    416. # Options:
    417. #   no         - Never perform full sanitization
    418. #   yes        - Always perform full sanitization
    419. #   clients    - Perform full sanitization only for user connections.
    420. #                Excludes: RDB files, RESTORE commands received from the master
    421. #                connection, and client connections which have the
    422. #                skip-sanitize-payload ACL flag.
    423. # The default should be 'clients' but since it currently affects cluster
    424. # resharding via MIGRATE, it is temporarily set to 'no' by default.
    425. #
    426. # sanitize-dump-payload no

    427. # The filename where to dump the DB
    428. dbfilename dump.rdb

    429. # Remove RDB files used by replication in instances without persistence
    430. # enabled. By default this option is disabled, however there are environments
    431. # where for regulations or other security concerns, RDB files persisted on
    432. # disk by masters in order to feed replicas, or stored on disk by replicas
    433. # in order to load them for the initial synchronization, should be deleted
    434. # ASAP. Note that this option ONLY WORKS in instances that have both AOF
    435. # and RDB persistence disabled, otherwise is completely ignored.
    436. #
    437. # An alternative (and sometimes better) way to obtain the same effect is
    438. # to use diskless replication on both master and replicas instances. However
    439. # in the case of replicas, diskless is not always an option.
    440. rdb-del-sync-files no

    441. # The working directory.
    442. #
    443. # The DB will be written inside this directory, with the filename specified
    444. # above using the 'dbfilename' configuration directive.
    445. #
    446. # The Append Only File will also be created inside this directory.
    447. #
    448. # Note that you must specify a directory here, not a file name.
    449. dir ./

    450. ################################# REPLICATION #################################

    451. # Master-Replica replication. Use replicaof to make a Redis instance a copy of
    452. # another Redis server. A few things to understand ASAP about Redis replication.
    453. #
    454. #   +------------------+      +---------------+
    455. #   |      Master      | ---> |    Replica    |
    456. #   | (receive writes) |      |  (exact copy) |
    457. #   +------------------+      +---------------+
    458. #
    459. # 1) Redis replication is asynchronous, but you can configure a master to
    460. #    stop accepting writes if it appears to be not connected with at least
    461. #    a given number of replicas.
    462. # 2) Redis replicas are able to perform a partial resynchronization with the
    463. #    master if the replication link is lost for a relatively small amount of
    464. #    time. You may want to configure the replication backlog size (see the next
    465. #    sections of this file) with a sensible value depending on your needs.
    466. # 3) Replication is automatic and does not need user intervention. After a
    467. #    network partition replicas automatically try to reconnect to masters
    468. #    and resynchronize with them.
    469. #
    470. # replicaof <masterip> <masterport>

    471. # If the master is password protected (using the "requirepass" configuration
    472. # directive below) it is possible to tell the replica to authenticate before
    473. # starting the replication synchronization process, otherwise the master will
    474. # refuse the replica request.
    475. #
    476. # masterauth <master-password>
    477. #
    478. # However this is not enough if you are using Redis ACLs (for Redis version
    479. # 6 or greater), and the default user is not capable of running the PSYNC
    480. # command and/or other commands needed for replication. In this case it's
    481. # better to configure a special user to use with replication, and specify the
    482. # masteruser configuration as such:
    483. #
    484. # masteruser <username>
    485. #
    486. # When masteruser is specified, the replica will authenticate against its
    487. # master using the new AUTH form: AUTH <username> <password>.

    488. # When a replica loses its connection with the master, or when the replication
    489. # is still in progress, the replica can act in two different ways:
    490. #
    491. # 1) if replica-serve-stale-data is set to 'yes' (the default) the replica will
    492. #    still reply to client requests, possibly with out of date data, or the
    493. #    data set may just be empty if this is the first synchronization.
    494. #
    495. # 2) If replica-serve-stale-data is set to 'no' the replica will reply with error
    496. #    "MASTERDOWN Link with MASTER is down and replica-serve-stale-data is set to 'no'"
    497. #    to all data access commands, excluding commands such as:
    498. #    INFO, REPLICAOF, AUTH, SHUTDOWN, REPLCONF, ROLE, CONFIG, SUBSCRIBE,
    499. #    UNSUBSCRIBE, PSUBSCRIBE, PUNSUBSCRIBE, PUBLISH, PUBSUB, COMMAND, POST,
    500. #    HOST and LATENCY.
    501. #
    502. replica-serve-stale-data yes

    503. # You can configure a replica instance to accept writes or not. Writing against
    504. # a replica instance may be useful to store some ephemeral data (because data
    505. # written on a replica will be easily deleted after resync with the master) but
    506. # may also cause problems if clients are writing to it because of a
    507. # misconfiguration.
    508. #
    509. # Since Redis 2.6 by default replicas are read-only.
    510. #
    511. # Note: read only replicas are not designed to be exposed to untrusted clients
    512. # on the internet. It's just a protection layer against misuse of the instance.
    513. # Still a read only replica exports by default all the administrative commands
    514. # such as CONFIG, DEBUG, and so forth. To a limited extent you can improve
    515. # security of read only replicas using 'rename-command' to shadow all the
    516. # administrative / dangerous commands.
    517. replica-read-only yes

    518. # Replication SYNC strategy: disk or socket.
    519. #
    520. # New replicas and reconnecting replicas that are not able to continue the
    521. # replication process just receiving differences, need to do what is called a
    522. # "full synchronization". An RDB file is transmitted from the master to the
    523. # replicas.
    524. #
    525. # The transmission can happen in two different ways:
    526. #
    527. # 1) Disk-backed: The Redis master creates a new process that writes the RDB
    528. #                 file on disk. Later the file is transferred by the parent
    529. #                 process to the replicas incrementally.
    530. # 2) Diskless: The Redis master creates a new process that directly writes the
    531. #              RDB file to replica sockets, without touching the disk at all.
    532. #
    533. # With disk-backed replication, while the RDB file is generated, more replicas
    534. # can be queued and served with the RDB file as soon as the current child
    535. # producing the RDB file finishes its work. With diskless replication instead
    536. # once the transfer starts, new replicas arriving will be queued and a new
    537. # transfer will start when the current one terminates.
    538. #
    539. # When diskless replication is used, the master waits a configurable amount of
    540. # time (in seconds) before starting the transfer in the hope that multiple
    541. # replicas will arrive and the transfer can be parallelized.
    542. #
    543. # With slow disks and fast (large bandwidth) networks, diskless replication
    544. # works better.
    545. repl-diskless-sync yes

    546. # When diskless replication is enabled, it is possible to configure the delay
    547. # the server waits in order to spawn the child that transfers the RDB via socket
    548. # to the replicas.
    549. #
    550. # This is important since once the transfer starts, it is not possible to serve
    551. # new replicas arriving, that will be queued for the next RDB transfer, so the
    552. # server waits a delay in order to let more replicas arrive.
    553. #
    554. # The delay is specified in seconds, and by default is 5 seconds. To disable
    555. # it entirely just set it to 0 seconds and the transfer will start ASAP.
    556. repl-diskless-sync-delay 5

    557. # When diskless replication is enabled with a delay, it is possible to let
    558. # the replication start before the maximum delay is reached if the maximum
    559. # number of replicas expected have connected. Default of 0 means that the
    560. # maximum is not defined and Redis will wait the full delay.
    561. repl-diskless-sync-max-replicas 0

    562. # -----------------------------------------------------------------------------
    563. # WARNING: RDB diskless load is experimental. Since in this setup the replica
    564. # does not immediately store an RDB on disk, it may cause data loss during
    565. # failovers. RDB diskless load + Redis modules not handling I/O reads may also
    566. # cause Redis to abort in case of I/O errors during the initial synchronization
    567. # stage with the master. Use only if you know what you are doing.
    568. # -----------------------------------------------------------------------------
    569. #
    570. # Replica can load the RDB it reads from the replication link directly from the
    571. # socket, or store the RDB to a file and read that file after it was completely
    572. # received from the master.
    573. #
    574. # In many cases the disk is slower than the network, and storing and loading
    575. # the RDB file may increase replication time (and even increase the master's
    576. # Copy on Write memory and replica buffers).
    577. # However, parsing the RDB file directly from the socket may mean that we have
    578. # to flush the contents of the current database before the full rdb was
    579. # received. For this reason we have the following options:
    580. #
    581. # "disabled"    - Don't use diskless load (store the rdb file to the disk first)
    582. # "on-empty-db" - Use diskless load only when it is completely safe.
    583. # "swapdb"      - Keep current db contents in RAM while parsing the data directly
    584. #                 from the socket. Replicas in this mode can keep serving current
    585. #                 data set while replication is in progress, except for cases where
    586. #                 they can't recognize master as having a data set from same
    587. #                 replication history.
    588. #                 Note that this requires sufficient memory, if you don't have it,
    589. #                 you risk an OOM kill.
    590. repl-diskless-load disabled

    591. # Master send PINGs to its replicas in a predefined interval. It's possible to
    592. # change this interval with the repl_ping_replica_period option. The default
    593. # value is 10 seconds.
    594. #
    595. # repl-ping-replica-period 10

    596. # The following option sets the replication timeout for:
    597. #
    598. # 1) Bulk transfer I/O during SYNC, from the point of view of replica.
    599. # 2) Master timeout from the point of view of replicas (data, pings).
    600. # 3) Replica timeout from the point of view of masters (REPLCONF ACK pings).
    601. #
    602. # It is important to make sure that this value is greater than the value
    603. # specified for repl-ping-replica-period otherwise a timeout will be detected
    604. # every time there is low traffic between the master and the replica. The default
    605. # value is 60 seconds.
    606. #
    607. # repl-timeout 60

    608. # Disable TCP_NODELAY on the replica socket after SYNC?
    609. #
    610. # If you select "yes" Redis will use a smaller number of TCP packets and
    611. # less bandwidth to send data to replicas. But this can add a delay for
    612. # the data to appear on the replica side, up to 40 milliseconds with
    613. # Linux kernels using a default configuration.
    614. #
    615. # If you select "no" the delay for data to appear on the replica side will
    616. # be reduced but more bandwidth will be used for replication.
    617. #
    618. # By default we optimize for low latency, but in very high traffic conditions
    619. # or when the master and replicas are many hops away, turning this to "yes" may
    620. # be a good idea.
    621. repl-disable-tcp-nodelay no

    622. # Set the replication backlog size. The backlog is a buffer that accumulates
    623. # replica data when replicas are disconnected for some time, so that when a
    624. # replica wants to reconnect again, often a full resync is not needed, but a
    625. # partial resync is enough, just passing the portion of data the replica
    626. # missed while disconnected.
    627. #
    628. # The bigger the replication backlog, the longer the replica can endure the
    629. # disconnect and later be able to perform a partial resynchronization.
    630. #
    631. # The backlog is only allocated if there is at least one replica connected.
    632. #
    633. # repl-backlog-size 1mb

    634. # After a master has no connected replicas for some time, the backlog will be
    635. # freed. The following option configures the amount of seconds that need to
    636. # elapse, starting from the time the last replica disconnected, for the backlog
    637. # buffer to be freed.
    638. #
    639. # Note that replicas never free the backlog for timeout, since they may be
    640. # promoted to masters later, and should be able to correctly "partially
    641. # resynchronize" with other replicas: hence they should always accumulate backlog.
    642. #
    643. # A value of 0 means to never release the backlog.
    644. #
    645. # repl-backlog-ttl 3600

    646. # The replica priority is an integer number published by Redis in the INFO
    647. # output. It is used by Redis Sentinel in order to select a replica to promote
    648. # into a master if the master is no longer working correctly.
    649. #
    650. # A replica with a low priority number is considered better for promotion, so
    651. # for instance if there are three replicas with priority 10, 100, 25 Sentinel
    652. # will pick the one with priority 10, that is the lowest.
    653. #
    654. # However a special priority of 0 marks the replica as not able to perform the
    655. # role of master, so a replica with priority of 0 will never be selected by
    656. # Redis Sentinel for promotion.
    657. #
    658. # By default the priority is 100.
    659. replica-priority 100

    660. # The propagation error behavior controls how Redis will behave when it is
    661. # unable to handle a command being processed in the replication stream from a master
    662. # or processed while reading from an AOF file. Errors that occur during propagation
    663. # are unexpected, and can cause data inconsistency. However, there are edge cases
    664. # in earlier versions of Redis where it was possible for the server to replicate or persist
    665. # commands that would fail on future versions. For this reason the default behavior
    666. # is to ignore such errors and continue processing commands.
    667. #
    668. # If an application wants to ensure there is no data divergence, this configuration
    669. # should be set to 'panic' instead. The value can also be set to 'panic-on-replicas'
    670. # to only panic when a replica encounters an error on the replication stream. One of
    671. # these two panic values will become the default value in the future once there are
    672. # sufficient safety mechanisms in place to prevent false positive crashes.
    673. #
    674. # propagation-error-behavior ignore

    675. # Replica ignore disk write errors controls the behavior of a replica when it is
    676. # unable to persist a write command received from its master to disk. By default,
    677. # this configuration is set to 'no' and will crash the replica in this condition.
    678. # It is not recommended to change this default, however in order to be compatible
    679. # with older versions of Redis this config can be toggled to 'yes' which will just
    680. # log a warning and execute the write command it got from the master.
    681. #
    682. # replica-ignore-disk-write-errors no

    683. # -----------------------------------------------------------------------------
    684. # By default, Redis Sentinel includes all replicas in its reports. A replica
    685. # can be excluded from Redis Sentinel's announcements. An unannounced replica
    686. # will be ignored by the 'sentinel replicas <master>' command and won't be
    687. # exposed to Redis Sentinel's clients.
    688. #
    689. # This option does not change the behavior of replica-priority. Even with
    690. # replica-announced set to 'no', the replica can be promoted to master. To
    691. # prevent this behavior, set replica-priority to 0.
    692. #
    693. # replica-announced yes

    694. # It is possible for a master to stop accepting writes if there are less than
    695. # N replicas connected, having a lag less or equal than M seconds.
    696. #
    697. # The N replicas need to be in "online" state.
    698. #
    699. # The lag in seconds, that must be <= the specified value, is calculated from
    700. # the last ping received from the replica, that is usually sent every second.
    701. #
    702. # This option does not GUARANTEE that N replicas will accept the write, but
    703. # will limit the window of exposure for lost writes in case not enough replicas
    704. # are available, to the specified number of seconds.
    705. #
    706. # For example to require at least 3 replicas with a lag <= 10 seconds use:
    707. #
    708. # min-replicas-to-write 3
    709. # min-replicas-max-lag 10
    710. #
    711. # Setting one or the other to 0 disables the feature.
    712. #
    713. # By default min-replicas-to-write is set to 0 (feature disabled) and
    714. # min-replicas-max-lag is set to 10.

    715. # A Redis master is able to list the address and port of the attached
    716. # replicas in different ways. For example the "INFO replication" section
    717. # offers this information, which is used, among other tools, by
    718. # Redis Sentinel in order to discover replica instances.
    719. # Another place where this info is available is in the output of the
    720. # "ROLE" command of a master.
    721. #
    722. # The listed IP address and port normally reported by a replica is
    723. # obtained in the following way:
    724. #
    725. #   IP: The address is auto detected by checking the peer address
    726. #   of the socket used by the replica to connect with the master.
    727. #
    728. #   Port: The port is communicated by the replica during the replication
    729. #   handshake, and is normally the port that the replica is using to
    730. #   listen for connections.
    731. #
    732. # However when port forwarding or Network Address Translation (NAT) is
    733. # used, the replica may actually be reachable via different IP and port
    734. # pairs. The following two options can be used by a replica in order to
    735. # report to its master a specific set of IP and port, so that both INFO
    736. # and ROLE will report those values.
    737. #
    738. # There is no need to use both the options if you need to override just
    739. # the port or the IP address.
    740. #
    741. # replica-announce-ip 5.5.5.5
    742. # replica-announce-port 1234

    743. ############################### KEYS TRACKING #################################

    744. # Redis implements server assisted support for client side caching of values.
    745. # This is implemented using an invalidation table that remembers, using
    746. # a radix key indexed by key name, what clients have which keys. In turn
    747. # this is used in order to send invalidation messages to clients. Please
    748. # check this page to understand more about the feature:
    749. #
    750. #   https://redis.io/topics/client-side-caching
    751. #
    752. # When tracking is enabled for a client, all the read only queries are assumed
    753. # to be cached: this will force Redis to store information in the invalidation
    754. # table. When keys are modified, such information is flushed away, and
    755. # invalidation messages are sent to the clients. However if the workload is
    756. # heavily dominated by reads, Redis could use more and more memory in order
    757. # to track the keys fetched by many clients.
    758. #
    759. # For this reason it is possible to configure a maximum fill value for the
    760. # invalidation table. By default it is set to 1M of keys, and once this limit
    761. # is reached, Redis will start to evict keys in the invalidation table
    762. # even if they were not modified, just to reclaim memory: this will in turn
    763. # force the clients to invalidate the cached values. Basically the table
    764. # maximum size is a trade off between the memory you want to spend server
    765. # side to track information about who cached what, and the ability of clients
    766. # to retain cached objects in memory.
    767. #
    768. # If you set the value to 0, it means there are no limits, and Redis will
    769. # retain as many keys as needed in the invalidation table.
    770. # In the "stats" INFO section, you can find information about the number of
    771. # keys in the invalidation table at every given moment.
    772. #
    773. # Note: when key tracking is used in broadcasting mode, no memory is used
    774. # in the server side so this setting is useless.
    775. #
    776. # tracking-table-max-keys 1000000

    777. ################################## SECURITY ###################################

    778. # Warning: since Redis is pretty fast, an outside user can try up to
    779. # 1 million passwords per second against a modern box. This means that you
    780. # should use very strong passwords, otherwise they will be very easy to break.
    781. # Note that because the password is really a shared secret between the client
    782. # and the server, and should not be memorized by any human, the password
    783. # can be easily a long string from /dev/urandom or whatever, so by using a
    784. # long and unguessable password no brute force attack will be possible.

    785. # Redis ACL users are defined in the following format:
    786. #
    787. #   user <username> ... acl rules ...
    788. #
    789. # For example:
    790. #
    791. #   user worker +@list +@connection ~jobs:* on >ffa9203c493aa99
    792. #
    793. # The special username "default" is used for new connections. If this user
    794. # has the "nopass" rule, then new connections will be immediately authenticated
    795. # as the "default" user without the need of any password provided via the
    796. # AUTH command. Otherwise if the "default" user is not flagged with "nopass"
    797. # the connections will start in not authenticated state, and will require
    798. # AUTH (or the HELLO command AUTH option) in order to be authenticated and
    799. # start to work.
    800. #
    801. # The ACL rules that describe what a user can do are the following:
    802. #
    803. #  on           Enable the user: it is possible to authenticate as this user.
    804. #  off          Disable the user: it's no longer possible to authenticate
    805. #               with this user, however the already authenticated connections
    806. #               will still work.
    807. #  skip-sanitize-payload    RESTORE dump-payload sanitization is skipped.
    808. #  sanitize-payload         RESTORE dump-payload is sanitized (default).
    809. #  +<command>   Allow the execution of that command.
    810. #               May be used with `|` for allowing subcommands (e.g "+config|get")
    811. #  -<command>   Disallow the execution of that command.
    812. #               May be used with `|` for blocking subcommands (e.g "-config|set")
    813. #  +@<category> Allow the execution of all the commands in such category
    814. #               with valid categories are like @admin, @set, @sortedset, ...
    815. #               and so forth, see the full list in the server.c file where
    816. #               the Redis command table is described and defined.
    817. #               The special category @all means all the commands, but currently
    818. #               present in the server, and that will be loaded in the future
    819. #               via modules.
    820. #  +<command>|first-arg  Allow a specific first argument of an otherwise
    821. #                        disabled command. It is only supported on commands with
    822. #                        no sub-commands, and is not allowed as negative form
    823. #                        like -SELECT|1, only additive starting with "+". This
    824. #                        feature is deprecated and may be removed in the future.
    825. #  allcommands  Alias for +@all. Note that it implies the ability to execute
    826. #               all the future commands loaded via the modules system.
    827. #  nocommands   Alias for -@all.
    828. #  ~<pattern>   Add a pattern of keys that can be mentioned as part of
    829. #               commands. For instance ~* allows all the keys. The pattern
    830. #               is a glob-style pattern like the one of KEYS.
    831. #               It is possible to specify multiple patterns.
    832. # %R~<pattern>  Add key read pattern that specifies which keys can be read
    833. #               from.
    834. # %W~<pattern>  Add key write pattern that specifies which keys can be
    835. #               written to.
    836. #  allkeys      Alias for ~*
    837. #  resetkeys    Flush the list of allowed keys patterns.
    838. #  &<pattern>   Add a glob-style pattern of Pub/Sub channels that can be
    839. #               accessed by the user. It is possible to specify multiple channel
    840. #               patterns.
    841. #  allchannels  Alias for &*
    842. #  resetchannels            Flush the list of allowed channel patterns.
    843. #  ><password>  Add this password to the list of valid password for the user.
    844. #               For example >mypass will add "mypass" to the list.
    845. #               This directive clears the "nopass" flag (see later).
    846. #  <<password>  Remove this password from the list of valid passwords.
    847. #  nopass       All the set passwords of the user are removed, and the user
    848. #               is flagged as requiring no password: it means that every
    849. #               password will work against this user. If this directive is
    850. #               used for the default user, every new connection will be
    851. #               immediately authenticated with the default user without
    852. #               any explicit AUTH command required. Note that the "resetpass"
    853. #               directive will clear this condition.
    854. #  resetpass    Flush the list of allowed passwords. Moreover removes the
    855. #               "nopass" status. After "resetpass" the user has no associated
    856. #               passwords and there is no way to authenticate without adding
    857. #               some password (or setting it as "nopass" later).
    858. #  reset        Performs the following actions: resetpass, resetkeys, off,
    859. #               -@all. The user returns to the same state it has immediately
    860. #               after its creation.
    861. # (<options>)   Create a new selector with the options specified within the
    862. #               parentheses and attach it to the user. Each option should be
    863. #               space separated. The first character must be ( and the last
    864. #               character must be ).
    865. # clearselectors            Remove all of the currently attached selectors.
    866. #                           Note this does not change the "root" user permissions,
    867. #                           which are the permissions directly applied onto the
    868. #                           user (outside the parentheses).
    869. #
    870. # ACL rules can be specified in any order: for instance you can start with
    871. # passwords, then flags, or key patterns. However note that the additive
    872. # and subtractive rules will CHANGE MEANING depending on the ordering.
    873. # For instance see the following example:
    874. #
    875. #   user alice on +@all -DEBUG ~* >somepassword
    876. #
    877. # This will allow "alice" to use all the commands with the exception of the
    878. # DEBUG command, since +@all added all the commands to the set of the commands
    879. # alice can use, and later DEBUG was removed. However if we invert the order
    880. # of two ACL rules the result will be different:
    881. #
    882. #   user alice on -DEBUG +@all ~* >somepassword
    883. #
    884. # Now DEBUG was removed when alice had yet no commands in the set of allowed
    885. # commands, later all the commands are added, so the user will be able to
    886. # execute everything.
    887. #
    888. # Basically ACL rules are processed left-to-right.
    889. #
    890. # The following is a list of command categories and their meanings:
    891. # * keyspace - Writing or reading from keys, databases, or their metadata
    892. #     in a type agnostic way. Includes DEL, RESTORE, DUMP, RENAME, EXISTS, DBSIZE,
    893. #     KEYS, EXPIRE, TTL, FLUSHALL, etc. Commands that may modify the keyspace,
    894. #     key or metadata will also have `write` category. Commands that only read
    895. #     the keyspace, key or metadata will have the `read` category.
    896. # * read - Reading from keys (values or metadata). Note that commands that don't
    897. #     interact with keys, will not have either `read` or `write`.
    898. # * write - Writing to keys (values or metadata)
    899. # * admin - Administrative commands. Normal applications will never need to use
    900. #     these. Includes REPLICAOF, CONFIG, DEBUG, SAVE, MONITOR, ACL, SHUTDOWN, etc.
    901. # * dangerous - Potentially dangerous (each should be considered with care for
    902. #     various reasons). This includes FLUSHALL, MIGRATE, RESTORE, SORT, KEYS,
    903. #     CLIENT, DEBUG, INFO, CONFIG, SAVE, REPLICAOF, etc.
    904. # * connection - Commands affecting the connection or other connections.
    905. #     This includes AUTH, SELECT, COMMAND, CLIENT, ECHO, PING, etc.
    906. # * blocking - Potentially blocking the connection until released by another
    907. #     command.
    908. # * fast - Fast O(1) commands. May loop on the number of arguments, but not the
    909. #     number of elements in the key.
    910. # * slow - All commands that are not Fast.
    911. # * pubsub - PUBLISH / SUBSCRIBE related
    912. # * transaction - WATCH / MULTI / EXEC related commands.
    913. # * scripting - Scripting related.
    914. # * set - Data type: sets related.
    915. # * sortedset - Data type: zsets related.
    916. # * list - Data type: lists related.
    917. # * hash - Data type: hashes related.
    918. # * string - Data type: strings related.
    919. # * bitmap - Data type: bitmaps related.
    920. # * hyperloglog - Data type: hyperloglog related.
    921. # * geo - Data type: geo related.
    922. # * stream - Data type: streams related.
    923. #
    924. # For more information about ACL configuration please refer to
    925. # the Redis web site at https://redis.io/topics/acl

    926. # ACL LOG
    927. #
    928. # The ACL Log tracks failed commands and authentication events associated
    929. # with ACLs. The ACL Log is useful to troubleshoot failed commands blocked
    930. # by ACLs. The ACL Log is stored in memory. You can reclaim memory with
    931. # ACL LOG RESET. Define the maximum entry length of the ACL Log below.
    932. acllog-max-len 128

    933. # Using an external ACL file
    934. #
    935. # Instead of configuring users here in this file, it is possible to use
    936. # a stand-alone file just listing users. The two methods cannot be mixed:
    937. # if you configure users here and at the same time you activate the external
    938. # ACL file, the server will refuse to start.
    939. #
    940. # The format of the external ACL user file is exactly the same as the
    941. # format that is used inside redis.conf to describe users.
    942. #
    943. # aclfile /etc/redis/users.acl

    944. # IMPORTANT NOTE: starting with Redis 6 "requirepass" is just a compatibility
    945. # layer on top of the new ACL system. The option effect will be just setting
    946. # the password for the default user. Clients will still authenticate using
    947. # AUTH <password> as usually, or more explicitly with AUTH default <password>
    948. # if they follow the new protocol: both will work.
    949. #
    950. # The requirepass is not compatible with aclfile option and the ACL LOAD
    951. # command, these will cause requirepass to be ignored.
    952. #
    953. # requirepass foobared

    954. # New users are initialized with restrictive permissions by default, via the
    955. # equivalent of this ACL rule 'off resetkeys -@all'. Starting with Redis 6.2, it
    956. # is possible to manage access to Pub/Sub channels with ACL rules as well. The
    957. # default Pub/Sub channels permission if new users is controlled by the
    958. # acl-pubsub-default configuration directive, which accepts one of these values:
    959. #
    960. # allchannels: grants access to all Pub/Sub channels
    961. # resetchannels: revokes access to all Pub/Sub channels
    962. #
    963. # From Redis 7.0, acl-pubsub-default defaults to 'resetchannels' permission.
    964. #
    965. # acl-pubsub-default resetchannels

    966. # Command renaming (DEPRECATED).
    967. #
    968. # ------------------------------------------------------------------------
    969. # WARNING: avoid using this option if possible. Instead use ACLs to remove
    970. # commands from the default user, and put them only in some admin user you
    971. # create for administrative purposes.
    972. # ------------------------------------------------------------------------
    973. #
    974. # It is possible to change the name of dangerous commands in a shared
    975. # environment. For instance the CONFIG command may be renamed into something
    976. # hard to guess so that it will still be available for internal-use tools
    977. # but not available for general clients.
    978. #
    979. # Example:
    980. #
    981. # rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52
    982. #
    983. # It is also possible to completely kill a command by renaming it into
    984. # an empty string:
    985. #
    986. # rename-command CONFIG ""
    987. #
    988. # Please note that changing the name of commands that are logged into the
    989. # AOF file or transmitted to replicas may cause problems.

    990. ################################### CLIENTS ####################################

    991. # Set the max number of connected clients at the same time. By default
    992. # this limit is set to 10000 clients, however if the Redis server is not
    993. # able to configure the process file limit to allow for the specified limit
    994. # the max number of allowed clients is set to the current file limit
    995. # minus 32 (as Redis reserves a few file descriptors for internal uses).
    996. #
    997. # Once the limit is reached Redis will close all the new connections sending
    998. # an error 'max number of clients reached'.
    999. #
    1000. # IMPORTANT: When Redis Cluster is used, the max number of connections is also
    1001. # shared with the cluster bus: every node in the cluster will use two
    1002. # connections, one incoming and another outgoing. It is important to size the
    1003. # limit accordingly in case of very large clusters.
    1004. #
    1005. # maxclients 10000

    1006. ############################## MEMORY MANAGEMENT ################################

    1007. # Set a memory usage limit to the specified amount of bytes.
    1008. # When the memory limit is reached Redis will try to remove keys
    1009. # according to the eviction policy selected (see maxmemory-policy).
    1010. #
    1011. # If Redis can't remove keys according to the policy, or if the policy is
    1012. # set to 'noeviction', Redis will start to reply with errors to commands
    1013. # that would use more memory, like SET, LPUSH, and so on, and will continue
    1014. # to reply to read-only commands like GET.
    1015. #
    1016. # This option is usually useful when using Redis as an LRU or LFU cache, or to
    1017. # set a hard memory limit for an instance (using the 'noeviction' policy).
    1018. #
    1019. # WARNING: If you have replicas attached to an instance with maxmemory on,
    1020. # the size of the output buffers needed to feed the replicas are subtracted
    1021. # from the used memory count, so that network problems / resyncs will
    1022. # not trigger a loop where keys are evicted, and in turn the output
    1023. # buffer of replicas is full with DELs of keys evicted triggering the deletion
    1024. # of more keys, and so forth until the database is completely emptied.
    1025. #
    1026. # In short... if you have replicas attached it is suggested that you set a lower
    1027. # limit for maxmemory so that there is some free RAM on the system for replica
    1028. # output buffers (but this is not needed if the policy is 'noeviction').
    1029. #
    1030. # maxmemory <bytes>

    1031. # MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
    1032. # is reached. You can select one from the following behaviors:
    1033. #
    1034. # volatile-lru -> Evict using approximated LRU, only keys with an expire set.
    1035. # allkeys-lru -> Evict any key using approximated LRU.
    1036. # volatile-lfu -> Evict using approximated LFU, only keys with an expire set.
    1037. # allkeys-lfu -> Evict any key using approximated LFU.
    1038. # volatile-random -> Remove a random key having an expire set.
    1039. # allkeys-random -> Remove a random key, any key.
    1040. # volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
    1041. # noeviction -> Don't evict anything, just return an error on write operations.
    1042. #
    1043. # LRU means Least Recently Used
    1044. # LFU means Least Frequently Used
    1045. #
    1046. # Both LRU, LFU and volatile-ttl are implemented using approximated
    1047. # randomized algorithms.
    1048. #
    1049. # Note: with any of the above policies, when there are no suitable keys for
    1050. # eviction, Redis will return an error on write operations that require
    1051. # more memory. These are usually commands that create new keys, add data or
    1052. # modify existing keys. A few examples are: SET, INCR, HSET, LPUSH, SUNIONSTORE,
    1053. # SORT (due to the STORE argument), and EXEC (if the transaction includes any
    1054. # command that requires memory).
    1055. #
    1056. # The default is:
    1057. #
    1058. # maxmemory-policy noeviction

    1059. # LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
    1060. # algorithms (in order to save memory), so you can tune it for speed or
    1061. # accuracy. By default Redis will check five keys and pick the one that was
    1062. # used least recently, you can change the sample size using the following
    1063. # configuration directive.
    1064. #
    1065. # The default of 5 produces good enough results. 10 Approximates very closely
    1066. # true LRU but costs more CPU. 3 is faster but not very accurate.
    1067. #
    1068. # maxmemory-samples 5

    1069. # Eviction processing is designed to function well with the default setting.
    1070. # If there is an unusually large amount of write traffic, this value may need to
    1071. # be increased.  Decreasing this value may reduce latency at the risk of
    1072. # eviction processing effectiveness
    1073. #   0 = minimum latency, 10 = default, 100 = process without regard to latency
    1074. #
    1075. # maxmemory-eviction-tenacity 10

    1076. # Starting from Redis 5, by default a replica will ignore its maxmemory setting
    1077. # (unless it is promoted to master after a failover or manually). It means
    1078. # that the eviction of keys will be just handled by the master, sending the
    1079. # DEL commands to the replica as keys evict in the master side.
    1080. #
    1081. # This behavior ensures that masters and replicas stay consistent, and is usually
    1082. # what you want, however if your replica is writable, or you want the replica
    1083. # to have a different memory setting, and you are sure all the writes performed
    1084. # to the replica are idempotent, then you may change this default (but be sure
    1085. # to understand what you are doing).
    1086. #
    1087. # Note that since the replica by default does not evict, it may end using more
    1088. # memory than the one set via maxmemory (there are certain buffers that may
    1089. # be larger on the replica, or data structures may sometimes take more memory
    1090. # and so forth). So make sure you monitor your replicas and make sure they
    1091. # have enough memory to never hit a real out-of-memory condition before the
    1092. # master hits the configured maxmemory setting.
    1093. #
    1094. # replica-ignore-maxmemory yes

    1095. # Redis reclaims expired keys in two ways: upon access when those keys are
    1096. # found to be expired, and also in background, in what is called the
    1097. # "active expire key". The key space is slowly and interactively scanned
    1098. # looking for expired keys to reclaim, so that it is possible to free memory
    1099. # of keys that are expired and will never be accessed again in a short time.
    1100. #
    1101. # The default effort of the expire cycle will try to avoid having more than
    1102. # ten percent of expired keys still in memory, and will try to avoid consuming
    1103. # more than 25% of total memory and to add latency to the system. However
    1104. # it is possible to increase the expire "effort" that is normally set to
    1105. # "1", to a greater value, up to the value "10". At its maximum value the
    1106. # system will use more CPU, longer cycles (and technically may introduce
    1107. # more latency), and will tolerate less already expired keys still present
    1108. # in the system. It's a tradeoff between memory, CPU and latency.
    1109. #
    1110. # active-expire-effort 1

    1111. ############################# LAZY FREEING ####################################

    1112. # Redis has two primitives to delete keys. One is called DEL and is a blocking
    1113. # deletion of the object. It means that the server stops processing new commands
    1114. # in order to reclaim all the memory associated with an object in a synchronous
    1115. # way. If the key deleted is associated with a small object, the time needed
    1116. # in order to execute the DEL command is very small and comparable to most other
    1117. # O(1) or O(log_N) commands in Redis. However if the key is associated with an
    1118. # aggregated value containing millions of elements, the server can block for
    1119. # a long time (even seconds) in order to complete the operation.
    1120. #
    1121. # For the above reasons Redis also offers non blocking deletion primitives
    1122. # such as UNLINK (non blocking DEL) and the ASYNC option of FLUSHALL and
    1123. # FLUSHDB commands, in order to reclaim memory in background. Those commands
    1124. # are executed in constant time. Another thread will incrementally free the
    1125. # object in the background as fast as possible.
    1126. #
    1127. # DEL, UNLINK and ASYNC option of FLUSHALL and FLUSHDB are user-controlled.
    1128. # It's up to the design of the application to understand when it is a good
    1129. # idea to use one or the other. However the Redis server sometimes has to
    1130. # delete keys or flush the whole database as a side effect of other operations.
    1131. # Specifically Redis deletes objects independently of a user call in the
    1132. # following scenarios:
    1133. #
    1134. # 1) On eviction, because of the maxmemory and maxmemory policy configurations,
    1135. #    in order to make room for new data, without going over the specified
    1136. #    memory limit.
    1137. # 2) Because of expire: when a key with an associated time to live (see the
    1138. #    EXPIRE command) must be deleted from memory.
    1139. # 3) Because of a side effect of a command that stores data on a key that may
    1140. #    already exist. For example the RENAME command may delete the old key
    1141. #    content when it is replaced with another one. Similarly SUNIONSTORE
    1142. #    or SORT with STORE option may delete existing keys. The SET command
    1143. #    itself removes any old content of the specified key in order to replace
    1144. #    it with the specified string.
    1145. # 4) During replication, when a replica performs a full resynchronization with
    1146. #    its master, the content of the whole database is removed in order to
    1147. #    load the RDB file just transferred.
    1148. #
    1149. # In all the above cases the default is to delete objects in a blocking way,
    1150. # like if DEL was called. However you can configure each case specifically
    1151. # in order to instead release memory in a non-blocking way like if UNLINK
    1152. # was called, using the following configuration directives.

    1153. lazyfree-lazy-eviction no
    1154. lazyfree-lazy-expire no
    1155. lazyfree-lazy-server-del no
    1156. replica-lazy-flush no

    1157. # It is also possible, for the case when to replace the user code DEL calls
    1158. # with UNLINK calls is not easy, to modify the default behavior of the DEL
    1159. # command to act exactly like UNLINK, using the following configuration
    1160. # directive:

    1161. lazyfree-lazy-user-del no

    1162. # FLUSHDB, FLUSHALL, SCRIPT FLUSH and FUNCTION FLUSH support both asynchronous and synchronous
    1163. # deletion, which can be controlled by passing the [SYNC|ASYNC] flags into the
    1164. # commands. When neither flag is passed, this directive will be used to determine
    1165. # if the data should be deleted asynchronously.

    1166. lazyfree-lazy-user-flush no

    1167. ################################ THREADED I/O #################################

    1168. # Redis is mostly single threaded, however there are certain threaded
    1169. # operations such as UNLINK, slow I/O accesses and other things that are
    1170. # performed on side threads.
    1171. #
    1172. # Now it is also possible to handle Redis clients socket reads and writes
    1173. # in different I/O threads. Since especially writing is so slow, normally
    1174. # Redis users use pipelining in order to speed up the Redis performances per
    1175. # core, and spawn multiple instances in order to scale more. Using I/O
    1176. # threads it is possible to easily speedup two times Redis without resorting
    1177. # to pipelining nor sharding of the instance.
    1178. #
    1179. # By default threading is disabled, we suggest enabling it only in machines
    1180. # that have at least 4 or more cores, leaving at least one spare core.
    1181. # Using more than 8 threads is unlikely to help much. We also recommend using
    1182. # threaded I/O only if you actually have performance problems, with Redis
    1183. # instances being able to use a quite big percentage of CPU time, otherwise
    1184. # there is no point in using this feature.
    1185. #
    1186. # So for instance if you have a four cores boxes, try to use 2 or 3 I/O
    1187. # threads, if you have a 8 cores, try to use 6 threads. In order to
    1188. # enable I/O threads use the following configuration directive:
    1189. #
    1190. # io-threads 4
    1191. #
    1192. # Setting io-threads to 1 will just use the main thread as usual.
    1193. # When I/O threads are enabled, we only use threads for writes, that is
    1194. # to thread the write(2) syscall and transfer the client buffers to the
    1195. # socket. However it is also possible to enable threading of reads and
    1196. # protocol parsing using the following configuration directive, by setting
    1197. # it to yes:
    1198. #
    1199. # io-threads-do-reads no
    1200. #
    1201. # Usually threading reads doesn't help much.
    1202. #
    1203. # NOTE 1: This configuration directive cannot be changed at runtime via
    1204. # CONFIG SET. Also, this feature currently does not work when SSL is
    1205. # enabled.
    1206. #
    1207. # NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
    1208. # sure you also run the benchmark itself in threaded mode, using the
    1209. # --threads option to match the number of Redis threads, otherwise you'll not
    1210. # be able to notice the improvements.

    1211. ############################ KERNEL OOM CONTROL ##############################

    1212. # On Linux, it is possible to hint the kernel OOM killer on what processes
    1213. # should be killed first when out of memory.
    1214. #
    1215. # Enabling this feature makes Redis actively control the oom_score_adj value
    1216. # for all its processes, depending on their role. The default scores will
    1217. # attempt to have background child processes killed before all others, and
    1218. # replicas killed before masters.
    1219. #
    1220. # Redis supports these options:
    1221. #
    1222. # no:       Don't make changes to oom-score-adj (default).
    1223. # yes:      Alias to "relative" see below.
    1224. # absolute: Values in oom-score-adj-values are written as is to the kernel.
    1225. # relative: Values are used relative to the initial value of oom_score_adj when
    1226. #           the server starts and are then clamped to a range of -1000 to 1000.
    1227. #           Because typically the initial value is 0, they will often match the
    1228. #           absolute values.
    1229. oom-score-adj no

    1230. # When oom-score-adj is used, this directive controls the specific values used
    1231. # for master, replica and background child processes. Values range -2000 to
    1232. # 2000 (higher means more likely to be killed).
    1233. #
    1234. # Unprivileged processes (not root, and without CAP_SYS_RESOURCE capabilities)
    1235. # can freely increase their value, but not decrease it below its initial
    1236. # settings. This means that setting oom-score-adj to "relative" and setting the
    1237. # oom-score-adj-values to positive values will always succeed.
    1238. oom-score-adj-values 0 200 800


    1239. #################### KERNEL transparent hugepage CONTROL ######################

    1240. # Usually the kernel Transparent Huge Pages control is set to "madvise" or
    1241. # or "never" by default (/sys/kernel/mm/transparent_hugepage/enabled), in which
    1242. # case this config has no effect. On systems in which it is set to "always",
    1243. # redis will attempt to disable it specifically for the redis process in order
    1244. # to avoid latency problems specifically with fork(2) and CoW.
    1245. # If for some reason you prefer to keep it enabled, you can set this config to
    1246. # "no" and the kernel global to "always".

    1247. disable-thp yes

    1248. ############################## APPEND ONLY MODE ###############################

    1249. # By default Redis asynchronously dumps the dataset on disk. This mode is
    1250. # good enough in many applications, but an issue with the Redis process or
    1251. # a power outage may result into a few minutes of writes lost (depending on
    1252. # the configured save points).
    1253. #
    1254. # The Append Only File is an alternative persistence mode that provides
    1255. # much better durability. For instance using the default data fsync policy
    1256. # (see later in the config file) Redis can lose just one second of writes in a
    1257. # dramatic event like a server power outage, or a single write if something
    1258. # wrong with the Redis process itself happens, but the operating system is
    1259. # still running correctly.
    1260. #
    1261. # AOF and RDB persistence can be enabled at the same time without problems.
    1262. # If the AOF is enabled on startup Redis will load the AOF, that is the file
    1263. # with the better durability guarantees.
    1264. #
    1265. # Please check https://redis.io/topics/persistence for more information.

    1266. appendonly no

    1267. # The base name of the append only file.
    1268. #
    1269. # Redis 7 and newer use a set of append-only files to persist the dataset
    1270. # and changes applied to it. There are two basic types of files in use:
    1271. #
    1272. # - Base files, which are a snapshot representing the complete state of the
    1273. #   dataset at the time the file was created. Base files can be either in
    1274. #   the form of RDB (binary serialized) or AOF (textual commands).
    1275. # - Incremental files, which contain additional commands that were applied
    1276. #   to the dataset following the previous file.
    1277. #
    1278. # In addition, manifest files are used to track the files and the order in
    1279. # which they were created and should be applied.
    1280. #
    1281. # Append-only file names are created by Redis following a specific pattern.
    1282. # The file name's prefix is based on the 'appendfilename' configuration
    1283. # parameter, followed by additional information about the sequence and type.
    1284. #
    1285. # For example, if appendfilename is set to appendonly.aof, the following file
    1286. # names could be derived:
    1287. #
    1288. # - appendonly.aof.1.base.rdb as a base file.
    1289. # - appendonly.aof.1.incr.aof, appendonly.aof.2.incr.aof as incremental files.
    1290. # - appendonly.aof.manifest as a manifest file.

    1291. appendfilename "appendonly.aof"

    1292. # For convenience, Redis stores all persistent append-only files in a dedicated
    1293. # directory. The name of the directory is determined by the appenddirname
    1294. # configuration parameter.

    1295. appenddirname "appendonlydir"

    1296. # The fsync() call tells the Operating System to actually write data on disk
    1297. # instead of waiting for more data in the output buffer. Some OS will really flush
    1298. # data on disk, some other OS will just try to do it ASAP.
    1299. #
    1300. # Redis supports three different modes:
    1301. #
    1302. # no: don't fsync, just let the OS flush the data when it wants. Faster.
    1303. # always: fsync after every write to the append only log. Slow, Safest.
    1304. # everysec: fsync only one time every second. Compromise.
    1305. #
    1306. # The default is "everysec", as that's usually the right compromise between
    1307. # speed and data safety. It's up to you to understand if you can relax this to
    1308. # "no" that will let the operating system flush the output buffer when
    1309. # it wants, for better performances (but if you can live with the idea of
    1310. # some data loss consider the default persistence mode that's snapshotting),
    1311. # or on the contrary, use "always" that's very slow but a bit safer than
    1312. # everysec.
    1313. #
    1314. # More details please check the following article:
    1315. # http://antirez.com/post/redis-persistence-demystified.html
    1316. #
    1317. # If unsure, use "everysec".

    1318. # appendfsync always
    1319. appendfsync everysec
    1320. # appendfsync no

    1321. # When the AOF fsync policy is set to always or everysec, and a background
    1322. # saving process (a background save or AOF log background rewriting) is
    1323. # performing a lot of I/O against the disk, in some Linux configurations
    1324. # Redis may block too long on the fsync() call. Note that there is no fix for
    1325. # this currently, as even performing fsync in a different thread will block
    1326. # our synchronous write(2) call.
    1327. #
    1328. # In order to mitigate this problem it's possible to use the following option
    1329. # that will prevent fsync() from being called in the main process while a
    1330. # BGSAVE or BGREWRITEAOF is in progress.
    1331. #
    1332. # This means that while another child is saving, the durability of Redis is
    1333. # the same as "appendfsync no". In practical terms, this means that it is
    1334. # possible to lose up to 30 seconds of log in the worst scenario (with the
    1335. # default Linux settings).
    1336. #
    1337. # If you have latency problems turn this to "yes". Otherwise leave it as
    1338. # "no" that is the safest pick from the point of view of durability.

    1339. no-appendfsync-on-rewrite no

    1340. # Automatic rewrite of the append only file.
    1341. # Redis is able to automatically rewrite the log file implicitly calling
    1342. # BGREWRITEAOF when the AOF log size grows by the specified percentage.
    1343. #
    1344. # This is how it works: Redis remembers the size of the AOF file after the
    1345. # latest rewrite (if no rewrite has happened since the restart, the size of
    1346. # the AOF at startup is used).
    1347. #
    1348. # This base size is compared to the current size. If the current size is
    1349. # bigger than the specified percentage, the rewrite is triggered. Also
    1350. # you need to specify a minimal size for the AOF file to be rewritten, this
    1351. # is useful to avoid rewriting the AOF file even if the percentage increase
    1352. # is reached but it is still pretty small.
    1353. #
    1354. # Specify a percentage of zero in order to disable the automatic AOF
    1355. # rewrite feature.

    1356. auto-aof-rewrite-percentage 100
    1357. auto-aof-rewrite-min-size 64mb

    1358. # An AOF file may be found to be truncated at the end during the Redis
    1359. # startup process, when the AOF data gets loaded back into memory.
    1360. # This may happen when the system where Redis is running
    1361. # crashes, especially when an ext4 filesystem is mounted without the
    1362. # data=ordered option (however this can't happen when Redis itself
    1363. # crashes or aborts but the operating system still works correctly).
    1364. #
    1365. # Redis can either exit with an error when this happens, or load as much
    1366. # data as possible (the default now) and start if the AOF file is found
    1367. # to be truncated at the end. The following option controls this behavior.
    1368. #
    1369. # If aof-load-truncated is set to yes, a truncated AOF file is loaded and
    1370. # the Redis server starts emitting a log to inform the user of the event.
    1371. # Otherwise if the option is set to no, the server aborts with an error
    1372. # and refuses to start. When the option is set to no, the user requires
    1373. # to fix the AOF file using the "redis-check-aof" utility before to restart
    1374. # the server.
    1375. #
    1376. # Note that if the AOF file will be found to be corrupted in the middle
    1377. # the server will still exit with an error. This option only applies when
    1378. # Redis will try to read more data from the AOF file but not enough bytes
    1379. # will be found.
    1380. aof-load-truncated yes

    1381. # Redis can create append-only base files in either RDB or AOF formats. Using
    1382. # the RDB format is always faster and more efficient, and disabling it is only
    1383. # supported for backward compatibility purposes.
    1384. aof-use-rdb-preamble yes

    1385. # Redis supports recording timestamp annotations in the AOF to support restoring
    1386. # the data from a specific point-in-time. However, using this capability changes
    1387. # the AOF format in a way that may not be compatible with existing AOF parsers.
    1388. aof-timestamp-enabled no

    1389. ################################ SHUTDOWN #####################################

    1390. # Maximum time to wait for replicas when shutting down, in seconds.
    1391. #
    1392. # During shut down, a grace period allows any lagging replicas to catch up with
    1393. # the latest replication offset before the master exists. This period can
    1394. # prevent data loss, especially for deployments without configured disk backups.
    1395. #
    1396. # The 'shutdown-timeout' value is the grace period's duration in seconds. It is
    1397. # only applicable when the instance has replicas. To disable the feature, set
    1398. # the value to 0.
    1399. #
    1400. # shutdown-timeout 10

    1401. # When Redis receives a SIGINT or SIGTERM, shutdown is initiated and by default
    1402. # an RDB snapshot is written to disk in a blocking operation if save points are configured.
    1403. # The options used on signaled shutdown can include the following values:
    1404. # default:  Saves RDB snapshot only if save points are configured.
    1405. #           Waits for lagging replicas to catch up.
    1406. # save:     Forces a DB saving operation even if no save points are configured.
    1407. # nosave:   Prevents DB saving operation even if one or more save points are configured.
    1408. # now:      Skips waiting for lagging replicas.
    1409. # force:    Ignores any errors that would normally prevent the server from exiting.
    1410. #
    1411. # Any combination of values is allowed as long as "save" and "nosave" are not set simultaneously.
    1412. # Example: "nosave force now"
    1413. #
    1414. # shutdown-on-sigint default
    1415. # shutdown-on-sigterm default

    1416. ################ NON-DETERMINISTIC LONG BLOCKING COMMANDS #####################

    1417. # Maximum time in milliseconds for EVAL scripts, functions and in some cases
    1418. # modules' commands before Redis can start processing or rejecting other clients.
    1419. #
    1420. # If the maximum execution time is reached Redis will start to reply to most
    1421. # commands with a BUSY error.
    1422. #
    1423. # In this state Redis will only allow a handful of commands to be executed.
    1424. # For instance, SCRIPT KILL, FUNCTION KILL, SHUTDOWN NOSAVE and possibly some
    1425. # module specific 'allow-busy' commands.
    1426. #
    1427. # SCRIPT KILL and FUNCTION KILL will only be able to stop a script that did not
    1428. # yet call any write commands, so SHUTDOWN NOSAVE may be the only way to stop
    1429. # the server in the case a write command was already issued by the script when
    1430. # the user doesn't want to wait for the natural termination of the script.
    1431. #
    1432. # The default is 5 seconds. It is possible to set it to 0 or a negative value
    1433. # to disable this mechanism (uninterrupted execution). Note that in the past
    1434. # this config had a different name, which is now an alias, so both of these do
    1435. # the same:
    1436. # lua-time-limit 5000
    1437. # busy-reply-threshold 5000

    1438. ################################ REDIS CLUSTER  ###############################

    1439. # Normal Redis instances can't be part of a Redis Cluster; only nodes that are
    1440. # started as cluster nodes can. In order to start a Redis instance as a
    1441. # cluster node enable the cluster support uncommenting the following:
    1442. #
    1443. # cluster-enabled yes

    1444. # Every cluster node has a cluster configuration file. This file is not
    1445. # intended to be edited by hand. It is created and updated by Redis nodes.
    1446. # Every Redis Cluster node requires a different cluster configuration file.
    1447. # Make sure that instances running in the same system do not have
    1448. # overlapping cluster configuration file names.
    1449. #
    1450. # cluster-config-file nodes-6379.conf

    1451. # Cluster node timeout is the amount of milliseconds a node must be unreachable
    1452. # for it to be considered in failure state.
    1453. # Most other internal time limits are a multiple of the node timeout.
    1454. #
    1455. # cluster-node-timeout 15000

    1456. # The cluster port is the port that the cluster bus will listen for inbound connections on. When set
    1457. # to the default value, 0, it will be bound to the command port + 10000. Setting this value requires
    1458. # you to specify the cluster bus port when executing cluster meet.
    1459. # cluster-port 0

    1460. # A replica of a failing master will avoid to start a failover if its data
    1461. # looks too old.
    1462. #
    1463. # There is no simple way for a replica to actually have an exact measure of
    1464. # its "data age", so the following two checks are performed:
    1465. #
    1466. # 1) If there are multiple replicas able to failover, they exchange messages
    1467. #    in order to try to give an advantage to the replica with the best
    1468. #    replication offset (more data from the master processed).
    1469. #    Replicas will try to get their rank by offset, and apply to the start
    1470. #    of the failover a delay proportional to their rank.
    1471. #
    1472. # 2) Every single replica computes the time of the last interaction with
    1473. #    its master. This can be the last ping or command received (if the master
    1474. #    is still in the "connected" state), or the time that elapsed since the
    1475. #    disconnection with the master (if the replication link is currently down).
    1476. #    If the last interaction is too old, the replica will not try to failover
    1477. #    at all.
    1478. #
    1479. # The point "2" can be tuned by user. Specifically a replica will not perform
    1480. # the failover if, since the last interaction with the master, the time
    1481. # elapsed is greater than:
    1482. #
    1483. #   (node-timeout * cluster-replica-validity-factor) + repl-ping-replica-period
    1484. #
    1485. # So for example if node-timeout is 30 seconds, and the cluster-replica-validity-factor
    1486. # is 10, and assuming a default repl-ping-replica-period of 10 seconds, the
    1487. # replica will not try to failover if it was not able to talk with the master
    1488. # for longer than 310 seconds.
    1489. #
    1490. # A large cluster-replica-validity-factor may allow replicas with too old data to failover
    1491. # a master, while a too small value may prevent the cluster from being able to
    1492. # elect a replica at all.
    1493. #
    1494. # For maximum availability, it is possible to set the cluster-replica-validity-factor
    1495. # to a value of 0, which means, that replicas will always try to failover the
    1496. # master regardless of the last time they interacted with the master.
    1497. # (However they'll always try to apply a delay proportional to their
    1498. # offset rank).
    1499. #
    1500. # Zero is the only value able to guarantee that when all the partitions heal
    1501. # the cluster will always be able to continue.
    1502. #
    1503. # cluster-replica-validity-factor 10

    1504. # Cluster replicas are able to migrate to orphaned masters, that are masters
    1505. # that are left without working replicas. This improves the cluster ability
    1506. # to resist to failures as otherwise an orphaned master can't be failed over
    1507. # in case of failure if it has no working replicas.
    1508. #
    1509. # Replicas migrate to orphaned masters only if there are still at least a
    1510. # given number of other working replicas for their old master. This number
    1511. # is the "migration barrier". A migration barrier of 1 means that a replica
    1512. # will migrate only if there is at least 1 other working replica for its master
    1513. # and so forth. It usually reflects the number of replicas you want for every
    1514. # master in your cluster.
    1515. #
    1516. # Default is 1 (replicas migrate only if their masters remain with at least
    1517. # one replica). To disable migration just set it to a very large value or
    1518. # set cluster-allow-replica-migration to 'no'.
    1519. # A value of 0 can be set but is useful only for debugging and dangerous
    1520. # in production.
    1521. #
    1522. # cluster-migration-barrier 1

    1523. # Turning off this option allows to use less automatic cluster configuration.
    1524. # It both disables migration to orphaned masters and migration from masters
    1525. # that became empty.
    1526. #
    1527. # Default is 'yes' (allow automatic migrations).
    1528. #
    1529. # cluster-allow-replica-migration yes

    1530. # By default Redis Cluster nodes stop accepting queries if they detect there
    1531. # is at least a hash slot uncovered (no available node is serving it).
    1532. # This way if the cluster is partially down (for example a range of hash slots
    1533. # are no longer covered) all the cluster becomes, eventually, unavailable.
    1534. # It automatically returns available as soon as all the slots are covered again.
    1535. #
    1536. # However sometimes you want the subset of the cluster which is working,
    1537. # to continue to accept queries for the part of the key space that is still
    1538. # covered. In order to do so, just set the cluster-require-full-coverage
    1539. # option to no.
    1540. #
    1541. # cluster-require-full-coverage yes

    1542. # This option, when set to yes, prevents replicas from trying to failover its
    1543. # master during master failures. However the replica can still perform a
    1544. # manual failover, if forced to do so.
    1545. #
    1546. # This is useful in different scenarios, especially in the case of multiple
    1547. # data center operations, where we want one side to never be promoted if not
    1548. # in the case of a total DC failure.
    1549. #
    1550. # cluster-replica-no-failover no

    1551. # This option, when set to yes, allows nodes to serve read traffic while the
    1552. # cluster is in a down state, as long as it believes it owns the slots.
    1553. #
    1554. # This is useful for two cases.  The first case is for when an application
    1555. # doesn't require consistency of data during node failures or network partitions.
    1556. # One example of this is a cache, where as long as the node has the data it
    1557. # should be able to serve it.
    1558. #
    1559. # The second use case is for configurations that don't meet the recommended
    1560. # three shards but want to enable cluster mode and scale later. A
    1561. # master outage in a 1 or 2 shard configuration causes a read/write outage to the
    1562. # entire cluster without this option set, with it set there is only a write outage.
    1563. # Without a quorum of masters, slot ownership will not change automatically.
    1564. #
    1565. # cluster-allow-reads-when-down no

    1566. # This option, when set to yes, allows nodes to serve pubsub shard traffic while
    1567. # the cluster is in a down state, as long as it believes it owns the slots.
    1568. #
    1569. # This is useful if the application would like to use the pubsub feature even when
    1570. # the cluster global stable state is not OK. If the application wants to make sure only
    1571. # one shard is serving a given channel, this feature should be kept as yes.
    1572. #
    1573. # cluster-allow-pubsubshard-when-down yes

    1574. # Cluster link send buffer limit is the limit on the memory usage of an individual
    1575. # cluster bus link's send buffer in bytes. Cluster links would be freed if they exceed
    1576. # this limit. This is to primarily prevent send buffers from growing unbounded on links
    1577. # toward slow peers (E.g. PubSub messages being piled up).
    1578. # This limit is disabled by default. Enable this limit when 'mem_cluster_links' INFO field
    1579. # and/or 'send-buffer-allocated' entries in the 'CLUSTER LINKS` command output continuously increase.
    1580. # Minimum limit of 1gb is recommended so that cluster link buffer can fit in at least a single
    1581. # PubSub message by default. (client-query-buffer-limit default value is 1gb)
    1582. #
    1583. # cluster-link-sendbuf-limit 0

    1584. # Clusters can configure their announced hostname using this config. This is a common use case for
    1585. # applications that need to use TLS Server Name Indication (SNI) or dealing with DNS based
    1586. # routing. By default this value is only shown as additional metadata in the CLUSTER SLOTS
    1587. # command, but can be changed using 'cluster-preferred-endpoint-type' config. This value is
    1588. # communicated along the clusterbus to all nodes, setting it to an empty string will remove
    1589. # the hostname and also propagate the removal.
    1590. #
    1591. # cluster-announce-hostname ""

    1592. # Clusters can advertise how clients should connect to them using either their IP address,
    1593. # a user defined hostname, or by declaring they have no endpoint. Which endpoint is
    1594. # shown as the preferred endpoint is set by using the cluster-preferred-endpoint-type
    1595. # config with values 'ip', 'hostname', or 'unknown-endpoint'. This value controls how
    1596. # the endpoint returned for MOVED/ASKING requests as well as the first field of CLUSTER SLOTS.
    1597. # If the preferred endpoint type is set to hostname, but no announced hostname is set, a '?'
    1598. # will be returned instead.
    1599. #
    1600. # When a cluster advertises itself as having an unknown endpoint, it's indicating that
    1601. # the server doesn't know how clients can reach the cluster. This can happen in certain
    1602. # networking situations where there are multiple possible routes to the node, and the
    1603. # server doesn't know which one the client took. In this case, the server is expecting
    1604. # the client to reach out on the same endpoint it used for making the last request, but use
    1605. # the port provided in the response.
    1606. #
    1607. # cluster-preferred-endpoint-type ip

    1608. # In order to setup your cluster make sure to read the documentation
    1609. # available at https://redis.io web site.

    1610. ########################## CLUSTER DOCKER/NAT support  ########################

    1611. # In certain deployments, Redis Cluster nodes address discovery fails, because
    1612. # addresses are NAT-ted or because ports are forwarded (the typical case is
    1613. # Docker and other containers).
    1614. #
    1615. # In order to make Redis Cluster working in such environments, a static
    1616. # configuration where each node knows its public address is needed. The
    1617. # following four options are used for this scope, and are:
    1618. #
    1619. # * cluster-announce-ip
    1620. # * cluster-announce-port
    1621. # * cluster-announce-tls-port
    1622. # * cluster-announce-bus-port
    1623. #
    1624. # Each instructs the node about its address, client ports (for connections
    1625. # without and with TLS) and cluster message bus port. The information is then
    1626. # published in the header of the bus packets so that other nodes will be able to
    1627. # correctly map the address of the node publishing the information.
    1628. #
    1629. # If cluster-tls is set to yes and cluster-announce-tls-port is omitted or set
    1630. # to zero, then cluster-announce-port refers to the TLS port. Note also that
    1631. # cluster-announce-tls-port has no effect if cluster-tls is set to no.
    1632. #
    1633. # If the above options are not used, the normal Redis Cluster auto-detection
    1634. # will be used instead.
    1635. #
    1636. # Note that when remapped, the bus port may not be at the fixed offset of
    1637. # clients port + 10000, so you can specify any port and bus-port depending
    1638. # on how they get remapped. If the bus-port is not set, a fixed offset of
    1639. # 10000 will be used as usual.
    1640. #
    1641. # Example:
    1642. #
    1643. # cluster-announce-ip 10.1.1.5
    1644. # cluster-announce-tls-port 6379
    1645. # cluster-announce-port 0
    1646. # cluster-announce-bus-port 6380

    1647. ################################## SLOW LOG ###################################

    1648. # The Redis Slow Log is a system to log queries that exceeded a specified
    1649. # execution time. The execution time does not include the I/O operations
    1650. # like talking with the client, sending the reply and so forth,
    1651. # but just the time needed to actually execute the command (this is the only
    1652. # stage of command execution where the thread is blocked and can not serve
    1653. # other requests in the meantime).
    1654. #
    1655. # You can configure the slow log with two parameters: one tells Redis
    1656. # what is the execution time, in microseconds, to exceed in order for the
    1657. # command to get logged, and the other parameter is the length of the
    1658. # slow log. When a new command is logged the oldest one is removed from the
    1659. # queue of logged commands.

    1660. # The following time is expressed in microseconds, so 1000000 is equivalent
    1661. # to one second. Note that a negative number disables the slow log, while
    1662. # a value of zero forces the logging of every command.
    1663. slowlog-log-slower-than 10000

    1664. # There is no limit to this length. Just be aware that it will consume memory.
    1665. # You can reclaim memory used by the slow log with SLOWLOG RESET.
    1666. slowlog-max-len 128

    1667. ################################ LATENCY MONITOR ##############################

    1668. # The Redis latency monitoring subsystem samples different operations
    1669. # at runtime in order to collect data related to possible sources of
    1670. # latency of a Redis instance.
    1671. #
    1672. # Via the LATENCY command this information is available to the user that can
    1673. # print graphs and obtain reports.
    1674. #
    1675. # The system only logs operations that were performed in a time equal or
    1676. # greater than the amount of milliseconds specified via the
    1677. # latency-monitor-threshold configuration directive. When its value is set
    1678. # to zero, the latency monitor is turned off.
    1679. #
    1680. # By default latency monitoring is disabled since it is mostly not needed
    1681. # if you don't have latency issues, and collecting data has a performance
    1682. # impact, that while very small, can be measured under big load. Latency
    1683. # monitoring can easily be enabled at runtime using the command
    1684. # "CONFIG SET latency-monitor-threshold <milliseconds>" if needed.
    1685. latency-monitor-threshold 0

    1686. ################################ LATENCY TRACKING ##############################

    1687. # The Redis extended latency monitoring tracks the per command latencies and enables
    1688. # exporting the percentile distribution via the INFO latencystats command,
    1689. # and cumulative latency distributions (histograms) via the LATENCY command.
    1690. #
    1691. # By default, the extended latency monitoring is enabled since the overhead
    1692. # of keeping track of the command latency is very small.
    1693. # latency-tracking yes

    1694. # By default the exported latency percentiles via the INFO latencystats command
    1695. # are the p50, p99, and p999.
    1696. # latency-tracking-info-percentiles 50 99 99.9

    1697. ############################# EVENT NOTIFICATION ##############################

    1698. # Redis can notify Pub/Sub clients about events happening in the key space.
    1699. # This feature is documented at https://redis.io/topics/notifications
    1700. #
    1701. # For instance if keyspace events notification is enabled, and a client
    1702. # performs a DEL operation on key "foo" stored in the Database 0, two
    1703. # messages will be published via Pub/Sub:
    1704. #
    1705. # PUBLISH __keyspace@0__:foo del
    1706. # PUBLISH __keyevent@0__:del foo
    1707. #
    1708. # It is possible to select the events that Redis will notify among a set
    1709. # of classes. Every class is identified by a single character:
    1710. #
    1711. #  K     Keyspace events, published with __keyspace@<db>__ prefix.
    1712. #  E     Keyevent events, published with __keyevent@<db>__ prefix.
    1713. #  g     Generic commands (non-type specific) like DEL, EXPIRE, RENAME, ...
    1714. #  $     String commands
    1715. #  l     List commands
    1716. #  s     Set commands
    1717. #  h     Hash commands
    1718. #  z     Sorted set commands
    1719. #  x     Expired events (events generated every time a key expires)
    1720. #  e     Evicted events (events generated when a key is evicted for maxmemory)
    1721. #  n     New key events (Note: not included in the 'A' class)
    1722. #  t     Stream commands
    1723. #  d     Module key type events
    1724. #  m     Key-miss events (Note: It is not included in the 'A' class)
    1725. #  A     Alias for g$lshzxetd, so that the "AKE" string means all the events
    1726. #        (Except key-miss events which are excluded from 'A' due to their
    1727. #         unique nature).
    1728. #
    1729. #  The "notify-keyspace-events" takes as argument a string that is composed
    1730. #  of zero or multiple characters. The empty string means that notifications
    1731. #  are disabled.
    1732. #
    1733. #  Example: to enable list and generic events, from the point of view of the
    1734. #           event name, use:
    1735. #
    1736. #  notify-keyspace-events Elg
    1737. #
    1738. #  Example 2: to get the stream of the expired keys subscribing to channel
    1739. #             name __keyevent@0__:expired use:
    1740. #
    1741. #  notify-keyspace-events Ex
    1742. #
    1743. #  By default all notifications are disabled because most users don't need
    1744. #  this feature and the feature has some overhead. Note that if you don't
    1745. #  specify at least one of K or E, no events will be delivered.
    1746. notify-keyspace-events ""

    1747. ############################### ADVANCED CONFIG ###############################

    1748. # Hashes are encoded using a memory efficient data structure when they have a
    1749. # small number of entries, and the biggest entry does not exceed a given
    1750. # threshold. These thresholds can be configured using the following directives.
    1751. hash-max-listpack-entries 512
    1752. hash-max-listpack-value 64

    1753. # Lists are also encoded in a special way to save a lot of space.
    1754. # The number of entries allowed per internal list node can be specified
    1755. # as a fixed maximum size or a maximum number of elements.
    1756. # For a fixed maximum size, use -5 through -1, meaning:
    1757. # -5: max size: 64 Kb  <-- not recommended for normal workloads
    1758. # -4: max size: 32 Kb  <-- not recommended
    1759. # -3: max size: 16 Kb  <-- probably not recommended
    1760. # -2: max size: 8 Kb   <-- good
    1761. # -1: max size: 4 Kb   <-- good
    1762. # Positive numbers mean store up to _exactly_ that number of elements
    1763. # per list node.
    1764. # The highest performing option is usually -2 (8 Kb size) or -1 (4 Kb size),
    1765. # but if your use case is unique, adjust the settings as necessary.
    1766. list-max-listpack-size -2

    1767. # Lists may also be compressed.
    1768. # Compress depth is the number of quicklist ziplist nodes from *each* side of
    1769. # the list to *exclude* from compression.  The head and tail of the list
    1770. # are always uncompressed for fast push/pop operations.  Settings are:
    1771. # 0: disable all list compression
    1772. # 1: depth 1 means "don't start compressing until after 1 node into the list,
    1773. #    going from either the head or tail"
    1774. #    So: [head]->node->node->...->node->[tail]
    1775. #    [head], [tail] will always be uncompressed; inner nodes will compress.
    1776. # 2: [head]->[next]->node->node->...->node->[prev]->[tail]
    1777. #    2 here means: don't compress head or head->next or tail->prev or tail,
    1778. #    but compress all nodes between them.
    1779. # 3: [head]->[next]->[next]->node->node->...->node->[prev]->[prev]->[tail]
    1780. # etc.
    1781. list-compress-depth 0

    1782. # Sets have a special encoding in just one case: when a set is composed
    1783. # of just strings that happen to be integers in radix 10 in the range
    1784. # of 64 bit signed integers.
    1785. # The following configuration setting sets the limit in the size of the
    1786. # set in order to use this special memory saving encoding.
    1787. set-max-intset-entries 512

    1788. # Similarly to hashes and lists, sorted sets are also specially encoded in
    1789. # order to save a lot of space. This encoding is only used when the length and
    1790. # elements of a sorted set are below the following limits:
    1791. zset-max-listpack-entries 128
    1792. zset-max-listpack-value 64

    1793. # HyperLogLog sparse representation bytes limit. The limit includes the
    1794. # 16 bytes header. When an HyperLogLog using the sparse representation crosses
    1795. # this limit, it is converted into the dense representation.
    1796. #
    1797. # A value greater than 16000 is totally useless, since at that point the
    1798. # dense representation is more memory efficient.
    1799. #
    1800. # The suggested value is ~ 3000 in order to have the benefits of
    1801. # the space efficient encoding without slowing down too much PFADD,
    1802. # which is O(N) with the sparse encoding. The value can be raised to
    1803. # ~ 10000 when CPU is not a concern, but space is, and the data set is
    1804. # composed of many HyperLogLogs with cardinality in the 0 - 15000 range.
    1805. hll-sparse-max-bytes 3000

    1806. # Streams macro node max size / items. The stream data structure is a radix
    1807. # tree of big nodes that encode multiple items inside. Using this configuration
    1808. # it is possible to configure how big a single node can be in bytes, and the
    1809. # maximum number of items it may contain before switching to a new node when
    1810. # appending new stream entries. If any of the following settings are set to
    1811. # zero, the limit is ignored, so for instance it is possible to set just a
    1812. # max entries limit by setting max-bytes to 0 and max-entries to the desired
    1813. # value.
    1814. stream-node-max-bytes 4096
    1815. stream-node-max-entries 100

    1816. # Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in
    1817. # order to help rehashing the main Redis hash table (the one mapping top-level
    1818. # keys to values). The hash table implementation Redis uses (see dict.c)
    1819. # performs a lazy rehashing: the more operation you run into a hash table
    1820. # that is rehashing, the more rehashing "steps" are performed, so if the
    1821. # server is idle the rehashing is never complete and some more memory is used
    1822. # by the hash table.
    1823. #
    1824. # The default is to use this millisecond 10 times every second in order to
    1825. # actively rehash the main dictionaries, freeing memory when possible.
    1826. #
    1827. # If unsure:
    1828. # use "activerehashing no" if you have hard latency requirements and it is
    1829. # not a good thing in your environment that Redis can reply from time to time
    1830. # to queries with 2 milliseconds delay.
    1831. #
    1832. # use "activerehashing yes" if you don't have such hard requirements but
    1833. # want to free memory asap when possible.
    1834. activerehashing yes

    1835. # The client output buffer limits can be used to force disconnection of clients
    1836. # that are not reading data from the server fast enough for some reason (a
    1837. # common reason is that a Pub/Sub client can't consume messages as fast as the
    1838. # publisher can produce them).
    1839. #
    1840. # The limit can be set differently for the three different classes of clients:
    1841. #
    1842. # normal -> normal clients including MONITOR clients
    1843. # replica -> replica clients
    1844. # pubsub -> clients subscribed to at least one pubsub channel or pattern
    1845. #
    1846. # The syntax of every client-output-buffer-limit directive is the following:
    1847. #
    1848. # client-output-buffer-limit <class> <hard limit> <soft limit> <soft seconds>
    1849. #
    1850. # A client is immediately disconnected once the hard limit is reached, or if
    1851. # the soft limit is reached and remains reached for the specified number of
    1852. # seconds (continuously).
    1853. # So for instance if the hard limit is 32 megabytes and the soft limit is
    1854. # 16 megabytes / 10 seconds, the client will get disconnected immediately
    1855. # if the size of the output buffers reach 32 megabytes, but will also get
    1856. # disconnected if the client reaches 16 megabytes and continuously overcomes
    1857. # the limit for 10 seconds.
    1858. #
    1859. # By default normal clients are not limited because they don't receive data
    1860. # without asking (in a push way), but just after a request, so only
    1861. # asynchronous clients may create a scenario where data is requested faster
    1862. # than it can read.
    1863. #
    1864. # Instead there is a default limit for pubsub and replica clients, since
    1865. # subscribers and replicas receive data in a push fashion.
    1866. #
    1867. # Note that it doesn't make sense to set the replica clients output buffer
    1868. # limit lower than the repl-backlog-size config (partial sync will succeed
    1869. # and then replica will get disconnected).
    1870. # Such a configuration is ignored (the size of repl-backlog-size will be used).
    1871. # This doesn't have memory consumption implications since the replica client
    1872. # will share the backlog buffers memory.
    1873. #
    1874. # Both the hard or the soft limit can be disabled by setting them to zero.
    1875. client-output-buffer-limit normal 0 0 0
    1876. client-output-buffer-limit replica 256mb 64mb 60
    1877. client-output-buffer-limit pubsub 32mb 8mb 60

    1878. # Client query buffers accumulate new commands. They are limited to a fixed
    1879. # amount by default in order to avoid that a protocol desynchronization (for
    1880. # instance due to a bug in the client) will lead to unbound memory usage in
    1881. # the query buffer. However you can configure it here if you have very special
    1882. # needs, such us huge multi/exec requests or alike.
    1883. #
    1884. # client-query-buffer-limit 1gb

    1885. # In some scenarios client connections can hog up memory leading to OOM
    1886. # errors or data eviction. To avoid this we can cap the accumulated memory
    1887. # used by all client connections (all pubsub and normal clients). Once we
    1888. # reach that limit connections will be dropped by the server freeing up
    1889. # memory. The server will attempt to drop the connections using the most
    1890. # memory first. We call this mechanism "client eviction".
    1891. #
    1892. # Client eviction is configured using the maxmemory-clients setting as follows:
    1893. # 0 - client eviction is disabled (default)
    1894. #
    1895. # A memory value can be used for the client eviction threshold,
    1896. # for example:
    1897. # maxmemory-clients 1g
    1898. #
    1899. # A percentage value (between 1% and 100%) means the client eviction threshold
    1900. # is based on a percentage of the maxmemory setting. For example to set client
    1901. # eviction at 5% of maxmemory:
    1902. # maxmemory-clients 5%

    1903. # In the Redis protocol, bulk requests, that are, elements representing single
    1904. # strings, are normally limited to 512 mb. However you can change this limit
    1905. # here, but must be 1mb or greater
    1906. #
    1907. # proto-max-bulk-len 512mb

    1908. # Redis calls an internal function to perform many background tasks, like
    1909. # closing connections of clients in timeout, purging expired keys that are
    1910. # never requested, and so forth.
    1911. #
    1912. # Not all tasks are performed with the same frequency, but Redis checks for
    1913. # tasks to perform according to the specified "hz" value.
    1914. #
    1915. # By default "hz" is set to 10. Raising the value will use more CPU when
    1916. # Redis is idle, but at the same time will make Redis more responsive when
    1917. # there are many keys expiring at the same time, and timeouts may be
    1918. # handled with more precision.
    1919. #
    1920. # The range is between 1 and 500, however a value over 100 is usually not
    1921. # a good idea. Most users should use the default of 10 and raise this up to
    1922. # 100 only in environments where very low latency is required.
    1923. hz 10

    1924. # Normally it is useful to have an HZ value which is proportional to the
    1925. # number of clients connected. This is useful in order, for instance, to
    1926. # avoid too many clients are processed for each background task invocation
    1927. # in order to avoid latency spikes.
    1928. #
    1929. # Since the default HZ value by default is conservatively set to 10, Redis
    1930. # offers, and enables by default, the ability to use an adaptive HZ value
    1931. # which will temporarily raise when there are many connected clients.
    1932. #
    1933. # When dynamic HZ is enabled, the actual configured HZ will be used
    1934. # as a baseline, but multiples of the configured HZ value will be actually
    1935. # used as needed once more clients are connected. In this way an idle
    1936. # instance will use very little CPU time while a busy instance will be
    1937. # more responsive.
    1938. dynamic-hz yes

    1939. # When a child rewrites the AOF file, if the following option is enabled
    1940. # the file will be fsync-ed every 4 MB of data generated. This is useful
    1941. # in order to commit the file to the disk more incrementally and avoid
    1942. # big latency spikes.
    1943. aof-rewrite-incremental-fsync yes

    1944. # When redis saves RDB file, if the following option is enabled
    1945. # the file will be fsync-ed every 4 MB of data generated. This is useful
    1946. # in order to commit the file to the disk more incrementally and avoid
    1947. # big latency spikes.
    1948. rdb-save-incremental-fsync yes

    1949. # Redis LFU eviction (see maxmemory setting) can be tuned. However it is a good
    1950. # idea to start with the default settings and only change them after investigating
    1951. # how to improve the performances and how the keys LFU change over time, which
    1952. # is possible to inspect via the OBJECT FREQ command.
    1953. #
    1954. # There are two tunable parameters in the Redis LFU implementation: the
    1955. # counter logarithm factor and the counter decay time. It is important to
    1956. # understand what the two parameters mean before changing them.
    1957. #
    1958. # The LFU counter is just 8 bits per key, it's maximum value is 255, so Redis
    1959. # uses a probabilistic increment with logarithmic behavior. Given the value
    1960. # of the old counter, when a key is accessed, the counter is incremented in
    1961. # this way:
    1962. #
    1963. # 1. A random number R between 0 and 1 is extracted.
    1964. # 2. A probability P is calculated as 1/(old_value*lfu_log_factor+1).
    1965. # 3. The counter is incremented only if R < P.
    1966. #
    1967. # The default lfu-log-factor is 10. This is a table of how the frequency
    1968. # counter changes with a different number of accesses with different
    1969. # logarithmic factors:
    1970. #
    1971. # +--------+------------+------------+------------+------------+------------+
    1972. # | factor | 100 hits   | 1000 hits  | 100K hits  | 1M hits    | 10M hits   |
    1973. # +--------+------------+------------+------------+------------+------------+
    1974. # | 0      | 104        | 255        | 255        | 255        | 255        |
    1975. # +--------+------------+------------+------------+------------+------------+
    1976. # | 1      | 18         | 49         | 255        | 255        | 255        |
    1977. # +--------+------------+------------+------------+------------+------------+
    1978. # | 10     | 10         | 18         | 142        | 255        | 255        |
    1979. # +--------+------------+------------+------------+------------+------------+
    1980. # | 100    | 8          | 11         | 49         | 143        | 255        |
    1981. # +--------+------------+------------+------------+------------+------------+
    1982. #
    1983. # NOTE: The above table was obtained by running the following commands:
    1984. #
    1985. #   redis-benchmark -n 1000000 incr foo
    1986. #   redis-cli object freq foo
    1987. #
    1988. # NOTE 2: The counter initial value is 5 in order to give new objects a chance
    1989. # to accumulate hits.
    1990. #
    1991. # The counter decay time is the time, in minutes, that must elapse in order
    1992. # for the key counter to be divided by two (or decremented if it has a value
    1993. # less <= 10).
    1994. #
    1995. # The default value for the lfu-decay-time is 1. A special value of 0 means to
    1996. # decay the counter every time it happens to be scanned.
    1997. #
    1998. # lfu-log-factor 10
    1999. # lfu-decay-time 1

    2000. ########################### ACTIVE DEFRAGMENTATION #######################
    2001. #
    2002. # What is active defragmentation?
    2003. # -------------------------------
    2004. #
    2005. # Active (online) defragmentation allows a Redis server to compact the
    2006. # spaces left between small allocations and deallocations of data in memory,
    2007. # thus allowing to reclaim back memory.
    2008. #
    2009. # Fragmentation is a natural process that happens with every allocator (but
    2010. # less so with Jemalloc, fortunately) and certain workloads. Normally a server
    2011. # restart is needed in order to lower the fragmentation, or at least to flush
    2012. # away all the data and create it again. However thanks to this feature
    2013. # implemented by Oran Agra for Redis 4.0 this process can happen at runtime
    2014. # in a "hot" way, while the server is running.
    2015. #
    2016. # Basically when the fragmentation is over a certain level (see the
    2017. # configuration options below) Redis will start to create new copies of the
    2018. # values in contiguous memory regions by exploiting certain specific Jemalloc
    2019. # features (in order to understand if an allocation is causing fragmentation
    2020. # and to allocate it in a better place), and at the same time, will release the
    2021. # old copies of the data. This process, repeated incrementally for all the keys
    2022. # will cause the fragmentation to drop back to normal values.
    2023. #
    2024. # Important things to understand:
    2025. #
    2026. # 1. This feature is disabled by default, and only works if you compiled Redis
    2027. #    to use the copy of Jemalloc we ship with the source code of Redis.
    2028. #    This is the default with Linux builds.
    2029. #
    2030. # 2. You never need to enable this feature if you don't have fragmentation
    2031. #    issues.
    2032. #
    2033. # 3. Once you experience fragmentation, you can enable this feature when
    2034. #    needed with the command "CONFIG SET activedefrag yes".
    2035. #
    2036. # The configuration parameters are able to fine tune the behavior of the
    2037. # defragmentation process. If you are not sure about what they mean it is
    2038. # a good idea to leave the defaults untouched.

    2039. # Active defragmentation is disabled by default
    2040. # activedefrag no

    2041. # Minimum amount of fragmentation waste to start active defrag
    2042. # active-defrag-ignore-bytes 100mb

    2043. # Minimum percentage of fragmentation to start active defrag
    2044. # active-defrag-threshold-lower 10

    2045. # Maximum percentage of fragmentation at which we use maximum effort
    2046. # active-defrag-threshold-upper 100

    2047. # Minimal effort for defrag in CPU percentage, to be used when the lower
    2048. # threshold is reached
    2049. # active-defrag-cycle-min 1

    2050. # Maximal effort for defrag in CPU percentage, to be used when the upper
    2051. # threshold is reached
    2052. # active-defrag-cycle-max 25

    2053. # Maximum number of set/hash/zset/list fields that will be processed from
    2054. # the main dictionary scan
    2055. # active-defrag-max-scan-fields 1000

    2056. # Jemalloc background thread for purging will be enabled by default
    2057. jemalloc-bg-thread yes

    2058. # It is possible to pin different threads and processes of Redis to specific
    2059. # CPUs in your system, in order to maximize the performances of the server.
    2060. # This is useful both in order to pin different Redis threads in different
    2061. # CPUs, but also in order to make sure that multiple Redis instances running
    2062. # in the same host will be pinned to different CPUs.
    2063. #
    2064. # Normally you can do this using the "taskset" command, however it is also
    2065. # possible to this via Redis configuration directly, both in Linux and FreeBSD.
    2066. #
    2067. # You can pin the server/IO threads, bio threads, aof rewrite child process, and
    2068. # the bgsave child process. The syntax to specify the cpu list is the same as
    2069. # the taskset command:
    2070. #
    2071. # Set redis server/io threads to cpu affinity 0,2,4,6:
    2072. # server_cpulist 0-7:2
    2073. #
    2074. # Set bio threads to cpu affinity 1,3:
    2075. # bio_cpulist 1,3
    2076. #
    2077. # Set aof rewrite child process to cpu affinity 8,9,10,11:
    2078. # aof_rewrite_cpulist 8-11
    2079. #
    2080. # Set bgsave child process to cpu affinity 1,10,11
    2081. # bgsave_cpulist 1,10-11

    2082. # In some cases redis will emit warnings and even refuse to start if it detects
    2083. # that the system is in bad state, it is possible to suppress these warnings
    2084. # by setting the following config which takes a space delimited list of warnings
    2085. # to suppress
    2086. #
    2087. # ignore-warnings ARM64-COW-BUG
    复制代码
    4、查看目录结构
    1. tree /data/redis/
    复制代码


    5、启动服务
    1. docker compose up -d
    复制代码


    6、查看服务状态



    7、登录验证
    1. docker compose exec redis /bin/bash
    复制代码


    8、连接测试
    1. redis-cli -a 123456
    复制代码


    9、查看redis信息并验证



    总结

    到此这篇关于如何使用docker compose一键部署redis服务的文章就介绍到这了,更多相关docker compose一键部署redis服务内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

    来源:https://www.jb51.net/database/335994jfp.htm
    免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    ×

    最新评论

    浏览过的版块

    QQ Archiver 手机版 小黑屋 福建二哥 ( 闽ICP备2022004717号|闽公网安备35052402000345号 )

    Powered by Discuz! X3.5 © 2001-2023

    快速回复 返回顶部 返回列表