Redis(04) -- Redis配置文件详解

本文详细解析了Redis6配置文件的重点内容,包括Units单位、INCLUDES包含、网络相关配置(如bind、protected-mode、Port、tcp-backlog、timeout、tcp-keepalive)、GENERAL通用设置(如daemonize、pidfile、loglevel、logfile、databases)、SECURITY安全选项(如requirepass)以及LIMITS限制(如maxclients、maxmemory、maxmemory-policy、maxmemory-samples)。通过对这些设置的理解,读者可以更好地管理和优化Redis服务器。
摘要由CSDN通过智能技术生成

Redis6

 

四)Redis配置文件详解

4.1)Units单位

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

# 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.

4.2)INCLUDES包含

类似jsp中的include,多实例的情况可以把公用的配置文件提取出来

################################## 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.
#
# Note that 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

4.3)网络相关配置

4.3.1)bind

默认情况bind=127.0.0.1,只能接受本机的访问请求,不写的情况下,无限制接受任何ip地址的访问,为了能够让除本机的其余服务器也能远程访问,将 bind 127.0.0.1 -::1注释掉

# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT OUT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1 -::1

4.3.2)protected-mode

为了能够让除本机的其余服务器也能远程访问,将 protected-mode yes 修改为 protected-mode no

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domai
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值