返回顶部
首页 > 资讯 > 数据库 >redis配置文件详解
  • 486
分享到

redis配置文件详解

redis配置文件详解 2022-01-15 07:01:46 486人浏览 才女
摘要

位置 find / -name Redis.conf units单位 # Redis configuration file example. # # Note that in order to read the configu

redis配置文件详解

位置

find / -name Redis.conf

units单位

# Redis configuration file example.
#
# Note that in order to read the configuration file, Redis must be
# started with the file path as first argument:
#
# ./redis-server /path/to/redis.conf

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


配置大小单位,开头定义了一些基本的度量单位,不支持bit
对大小写不敏感

includes包含

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

network

################################## NETWORK #####################################

# tcp listen() backlog.
#
# In high requests-per-second environments you need an high backlog in order
# to avoid slow clients connections issues. Note that the linux kernel
# will silently truncate it to the value of /proc/sys/net/core/somaxconn so
# make sure to raise both the value of somaxconn and tcp_max_syn_backlog
# in order to get the desired effect.
tcp-backlog 511

设置tcp的backlog,backlog其实是一个连接队列,backlog队列总和=未完成三次握手队列+已完成三次握手队列.
在高并发环境下你需要一个高的backlog值来避免慢客户端连接问题.
注意linux内核会将这个值减小到/proc/sys/net/core/somaxconn的值,所以需要确认增大somaxconn和tcp_max_syn_backlog两个值来达到想要的效果



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

超时时间设置,0为关闭




# TCP keepalive.
#
# If non-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence
# of communication. This is useful for two reasons:
#
# 1) Detect dead peers.
# 2) Take the connection alive from the point of view of network
#    equipment in the middle.
#
# On Linux, the specified value (in seconds) is the period used to send ACKs.
# Note that to close the connection the double of the time is needed.
# On other kernels the period depends on the kernel configuration.
#
# A reasonable value for this option is 300 seconds, which is the new
# Redis default starting with Redis 3.2.1.
tcp-keepalive 300

单位为秒,如果设置为0,则不会进行keepalive检测,建议设置成60

general通用

# 是否以守护进行
daemonize no
# 进程管道id文件,如果没有指定,则在这个路径下
pidfile /var/run/redis_6379.pid
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of infORMation, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
# 日志级别
loglevel notice
# Specify the server verbosity level.
# This can be one of:
# debug (a lot of information, useful for development/testing)
# verbose (many rarely useful info, but not a mess like the debug level)
# notice (moderately verbose, what you want in production probably)
# warning (only very important / critical messages are logged)
# 日志名字
loglevel notice
# To enable logging to the system logger, just set 'syslog-enabled' to yes,
# and optionally update the other syslog parameters to suit your needs.
# 是否把日志输出到syslog中
# syslog-enabled no
# Specify the syslog identity.
# 指定syslog里的日志表示
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# syslog-facility local0
# Specify the syslog identity.
# syslog-ident redis

# Specify the syslog facility. Must be USER or between LOCAL0-LOCAL7.
# 指定syslog设备,值可以是user或者local0-local7
# syslog-facility local0
# Set the number of databases. The default database is DB 0, you can select
# a different one on a per-connection basis using SELECT  where
# dbid is a number between 0 and 'databases'-1
# 默认有16个数据库
databases 16

snapshotting快照

################################ SNAPSHOTTING  ################################
#
# Save the DB on disk:
#
#   save  
#
#   Will save the DB if both the given number of seconds and the given
#   number of write operations against the DB occurred.
#
#   In the example below the behaviour will be to save:
#   after 900 sec (15 min) if at least 1 key changed
#   after 300 sec (5 min) if at least 10 keys changed
#   after 60 sec if at least 10000 keys changed
#
#   Note: you can disable saving completely by commenting out all "save" lines.
#
#   It is also possible to remove all the previously configured save
#   points by adding a save directive with a single empty string argument
#   like in the following example:
# flushall和shutdown会立即出发save命令,进行备份
# 禁用RDB持久化策略,只要不设置任何save指令(在redis的命令窗口中使用save命令)或者使用下面的save ""也可以(save传入一个空字符串参数也可以)
#   save ""
# 下面三个条件符合其一就触发备份
# 900秒内有一个key改变过就备份
save 900 1
# 300秒内有10个key改变过就备份
save 300 10
# 60秒内有10000个key改变就触发备份
save 60 10000


# By default Redis will stop accepting writes if RDB snapshots are enabled
# (at least one save point) and the latest background save failed.
# This will make the user aware (in a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
# 如何配置成no,表示不在乎数据不一致或者其他的手段发现和控制
stop-writes-on-bgsave-error yes


# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
# 对于存储到磁盘中的快照,可以设置是否进行压缩存储.
# 如果是的话,redis会采用LZF算法进行压缩.
# 如果不想消耗CPU进行要,可以设置为关闭此功能
rdbcompression yes


# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
# 在存储快照后,还可以让redis使用CRC64算法来进行数据检验
# 这样做会增加10%的性能消耗,
# 如果想获得最大的性能提升,则可以关闭此功能
rdbchecksum yes


# The filename where to dump the DB
# 保存时的文件名称,断电重启时读取的文件名称
dbfilename dump.rdb


# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
# 工作目录
dir ./

replication复制

security安全

# 获取登录密码
config get requirepass
127.0.0.1:8686> config get requirepass
1) "requirepass"
2) "51310400"
# 查询启动时所在的目录
config get dir
127.0.0.1:8686> config get dir
1) "dir"
2) "/alidata/redis-5.0.3/db"

# 设置redis密码
config set requirepass 123456

# 登录redis
[root@izm5e2q95pbpe1hh0kkwoiz /]# redis-cli -p 8686
127.0.0.1:8686> ping
(error) NOAUTH Authentication required.
127.0.0.1:8686> auth 51310400
OK
127.0.0.1:8686> ping
PONG

CLIENTS

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
# 最大连接数10000
# maxclients 10000

limits限制

# 最大内存
# maxmemory 

## 达到最大内存时清除策略
# MAXMEMORY POLICY: how Redis will select what to remove when maxmemory
# is reached. You can select among five behaviors:
#
## 使用LUR算法移除key,只对设置了过期时间的键.LRU最近最少使用算法
# volatile-lru -> Evict using approximated LRU among the keys with an expire set.
## 使用LRU算法移除key
# allkeys-lru -> Evict any key using approximated LRU.
# volatile-lfu -> Evict using approximated LFU among the keys with an expire set.
# allkeys-lfu -> Evict any key using approximated LFU.
## 在过期集合中移除随机的key,只对设置了过期时间的键
# volatile-random -> Remove a random key among the ones with an expire set.
## 移除随机的key
# allkeys-random -> Remove a random key, any key.
## 移除那些ttl值最小的key,即那些最近要过期的key
# volatile-ttl -> Remove the key with the nearest expire time (minor TTL)
## 不进行移除.针对写操作,只是返回错误信息   
# noeviction -> Don't evict anything, just return an error on write operations.
#
# LRU means Least Recently Used
# LFU means Least Frequently Used
#
# Both LRU, LFU and volatile-ttl are implemented using approximated
# randomized algorithms.
#
# Note: with any of the above policies, Redis will return an error on write
#       operations, when there are no suitable keys for eviction.
#
#       At the date of writing these commands are: set setnx setex append
#       incr decr rpush lpush rpushx lpushx linsert lset rpoplpush sadd
#       sinter sinterstore suNIOn sunionstore sdiff sdiffstore zadd zincrby
#       zunionstore zinterstore hset hsetnx hmset hincrby incrby decrby
#       getset mset msetnx exec sort
#
# The default is:
# 默认配置是不清除,但是配置没有开启
# maxmemory-policy noeviction
# LRU, LFU and minimal TTL algorithms are not precise algorithms but approximated
# algorithms (in order to save memory), so you can tune it for speed or
# accuracy. For default Redis will check five keys and pick the one that was
# used less recently, you can change the sample size using the following
# configuration directive.
#
# The default of 5 produces good enough results. 10 Approximates very closely
# true LRU but costs more CPU. 3 is faster but not very accurate.
# 设置样本你数量,LRU算法和最小TTL算法都并非是精确的算法,而是估算值,醉意可以设置样本的大小.redis默认会检查这么多个key并选择其中LRU的那个
# maxmemory-samples 5

append only mode追加

############################## APPEND ONLY MODE ###############################

# By default Redis asynchronously dumps the dataset on disk. This mode is
# good enough in many applications, but an issue with the Redis process or
# a power outage may result into a few minutes of writes lost (depending on
# the configured save points).
#
# The Append Only File is an alternative persistence mode that provides
# much better durability. For instance using the default data fsync policy
# (see later in the config file) Redis can lose just one second of writes in a
# dramatic event like a server power outage, or a single write if something
# wrong with the Redis process itself happens, but the operating system is
# still running correctly.
#
# AOF and RDB persistence can be enabled at the same time without problems.
# If the AOF is enabled on startup Redis will load the AOF, that is the file
# with the better durability guarantees.
#
# Please check Http://redis.io/topics/persistence for more information.
# 默认是关闭状态
appendonly no
# The name of the append only file (default: "appendonly.aof")
# 备份文件的名字
appendfilename "appendonly.aof"

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

# appendfsync always
# 备份时机
# always:同步持久化,每次发生数据变更会被立即就到磁盘,性能较差但数据记录完整性比较好
# ererysec:出厂默认配置,异步操作,每秒记录,如果一秒内宕机,有数据丢失
# no:不追加
appendfsync everysec

# When the AOF fsync policy is set to always or everysec, and a background
# saving process (a background save or AOF log background rewriting) is
# performing a lot of I/O against the disk, in some Linux configurations
# Redis may block too long on the fsync() call. Note that there is no fix for
# this currently, as even performing fsync in a different thread will block
# our synchronous write(2) call.
#
# In order to mitigate this problem it's possible to use the following option
# that will prevent fsync() from being called in the main process while a
# BGSAVE or BGREWRITEAOF is in progress.
#
# This means that while another child is saving, the durability of Redis is
# the same as "appendfsync none". In practical terms, this means that it is
# possible to lose up to 30 seconds of log in the worst scenario (with the
# default Linux settings).
#
# If you have latency problems turn this to "yes". Otherwise leave it as
# "no" that is the safest pick from the point of view of durability.
# 重写时是否可以运用appendfsync,用默认no即可,保证数据安全性
no-appendfsync-on-rewrite no

# Automatic rewrite of the append only file.
# Redis is able to automatically rewrite the log file implicitly calling
# BGREWRITEAOF when the AOF log size grows by the specified percentage.
#
# This is how it works: Redis remembers the size of the AOF file after the
# latest rewrite (if no rewrite has happened since the restart, the size of
# the AOF at startup is used).
#
# This base size is compared to the current size. If the current size is
# bigger than the specified percentage, the rewrite is triggered. Also
# you need to specify a minimal size for the AOF file to be rewritten, this
# is useful to avoid rewriting the AOF file even if the percentage increase
# is reached but it is still pretty small.
#
# Specify a percentage of zero in order to disable the automatic AOF
# rewrite feature.
# 设置重写的基准值,此时是上次重写体积的100%,也就是体积翻一倍
auto-aof-rewrite-percentage 100
# 设置重写的基准值,此时是重写时日志要大于64MB
auto-aof-rewrite-min-size 64mb

常见配置redis.conf介绍






您可能感兴趣的文档:

--结束END--

本文标题: redis配置文件详解

本文链接: https://lsjlt.com/news/4194.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

猜你喜欢
  • redis配置文件详解
    位置 find / -name redis.conf units单位 # Redis configuration file example. # # Note that in order to read the configu...
    99+
    2022-01-15
    redis配置文件详解
  • redis-配置文件详解
    1.基本配置daemonize no 是否以后台进程启动databases 16 创建database的数量(默认选中的是database 0) save 900 1 #刷新快照到硬盘中,必须满足两者...
    99+
    2024-04-02
  • redis 配置文件详解
    bind 0.0.0.0                 #绑定redis服务器网卡IP,默认为127.0.0.1,即本地...
    99+
    2024-04-02
  • redis配置文件中常用配置详解
    此次安装的版本为: 5.0.3 [root@localhost local]# redis-server --version Redis server v=5.0.3 sha=0...
    99+
    2024-04-02
  • Redis配置文件(redis.conf)参数详解
    redis配置文件参数说明:1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程daemonize no2. 当Redis以守护进程方式运行时,Redis默认会把pid...
    99+
    2024-04-02
  • Redis配置文件解析
    Redis概述:    是一个基于Key-Value的持久化数据库存储,支持丰富的数据类型,用C语言编写,可基于内存又可持久化的日志型、Key-Value数据库,并提...
    99+
    2024-04-02
  • 03 redis 配置文件解释
    #### 通用配置           daemonize no #是否作为守护进程运...
    99+
    2024-04-02
  • NoSQL--Redis 配置文件
    一、 redis  conf 参数配置: 1、#是否作为守护进程运行:作为后台进程运行。daemonize yes#如以后台进程运行,则需指定一个pid,默认为/va...
    99+
    2024-04-02
  • package.json文件配置详解
    package.json 是npm init命令初始化后,在项目的根目录下自动生成的配置文件,它定义了这个项目的配置信息以及所需要的各种模块,npm install根据这个命令,自动下载所需的模块。pack...
    99+
    2022-06-04
    详解 文件 package
  • postgresql.conf配置文件详解
    postgresql.conf文件是PostgreSQL数据库系统的主配置文件,它包含了数据库服务器的各种配置选项。下面是postg...
    99+
    2023-09-13
    详解
  • prometheus 配置文件详解
    目录 prometheus 配置文件详解 简介配置文件 原始配置文件内容global字段alerting 字段 alert_relabel_configsalertmanagersrule_fi...
    99+
    2023-09-05
    prometheus 服务器 linux java 运维
  • Redis配置文件redis.conf的详细分析
    这篇文章主要介绍了Redis配置文件redis.conf的详细分析,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。文章目录一、常用的三十条配置...
    99+
    2024-04-02
  • Redis2.8配置文件中文详解
    add by zhj : 没找到本文的原文。另外,redis配置文件中文翻译 也翻译的不错,可以与本文对照看。两篇文章都是以Redis2.8来介绍的 在Redis中直接启动redis-server服务时, ...
    99+
    2022-06-04
    中文 配置文件 详解
  • redis读取配置文件
    redis 读取配置文件的路径位于 /etc/redis/redis.conf 或 /usr/local/etc/redis/redis.conf。它会读取配置文件并逐行解析,将配置选项...
    99+
    2024-04-19
    redis 键值对
  • Nginx配置文件(nginx.conf)详解
    1、配置文件在哪? 想要了解nginx的配置文件,得先知道它在哪吧!可通过以下命令查看:  2、nginx.conf文件的结构 nginx.conf一共由3部分组成:全局块、events块、http块。 2.1全局块 全局块是默认配置文件...
    99+
    2023-09-23
    nginx 运维 服务器
  • Maven配置文件pom.xml详解
    什么是POM?POM是项目对象模型(Project Object Model)的简称,它是Maven项目中的文件,使用XML表示,名称叫做pom.xml。在Maven中,当谈到Project的时候,不仅仅是一堆包含代码的文件。一个Proje...
    99+
    2023-05-31
    maven pom mave
  • 【八】MySQL-配置文件详解
    # 客户端设置,即客户端默认的连接参数 [client]   # 默认连接端口 port = 3306   # 用于本地连接的socket套接字 socket = /usr/local/mysql/data/mysql.sock   # 字...
    99+
    2023-10-26
    mysql 数据库 服务器
  • WordPress配置文件wp-config.php详解
    今天安装一个wp主题时候忽然前后台都报错,这就完了,只能去服务器上修改程序或者修改配置了,正好搜索到一个说明比较详细的配置,共享给大家! 数据库信息 WordPress链接数据库需设定以下四个值: 复制代码代码如下:defin...
    99+
    2024-04-02
  • 详解Mybatis核心配置文件
    Mybatis核心配置文件 记录在mybatis核心配置文件中,常用的配置选项: 下边是之前的配置选项: <?xml version="1.0" encoding=...
    99+
    2024-04-02
  • MyBatis全局配置文件详解
    目录MyBatis全局配置文件settings设置typeAliases类型命名存在的问题:@Alias("")environments环境transactionManager事务管...
    99+
    2024-04-02
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作