设为首页 收藏本站
查看: 664|回复: 0

[经验分享] redis.conf配置文件详细讲解(一)

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2016-12-30 10:01:11 | 显示全部楼层 |阅读模式
1.      内存大小配置说明

[redis@Centos6 ~]$ cat run/redis-3.2.6/redis.conf

# 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 andso forth:[l1]

#

# 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.[l2]

2.      INCLUEDS设置说明

####### INCLUDES ###################################



#Include one or more other config files here. This is useful if you

# have a standard template that goes toall Redis servers but also need

# to customize a few per-serversettings.  Include files can include

# other files, so use this wisely.[l3]

#

# Noticeoption "include" won't be rewritten by command "CONFIGREWRITE"

# from admin or Redis Sentinel. SinceRedis always uses the last processed

# line as value of a configurationdirective, you'd better put includes

# at the beginning of this file to avoidoverwriting config change at runtime.[l4]

#

# Ifinstead you are interested in using includes to override configuration

# options, it is better to use include asthe last line.[l5]

#

# include /path/to/local.conf

# include /path/to/other.conf

3.      网络配置说明

######NETWORK #####################################[l6]



# Bydefault, if no "bind" configuration directive is specified, Redislistens

# for connections from all the networkinterfaces available on the server.

# It is possible to listen to just one ormultiple selected interfaces using

# the "bind" configurationdirective, followed by one or more IP addresses.[l7]

#

# Examples:

#

# bind 192.168.1.100 10.0.0.1

# bind 127.0.0.1 ::1

#

# ~~~WARNING ~~~ If the computer running Redis is directly exposed to the

# internet, binding to all the interfacesis dangerous and will expose the

# instance to everybody on the internet.So by default we uncomment the

# following bind directive, that willforce Redis to listen only into

# the IPv4 lookback interface address(this means Redis will be able to

# accept connections only from clientsrunning into the same computer it

# is running).[l8]

#

# IFYOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES

# JUST COMMENT THE FOLLOWING LINE.[l9]

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

bind 127.0.0.1



# Protectedmode is a layer of security protection, in order to avoid that

# Redis instances left open on theinternet are accessed and exploited.[l10]

#

# Whenprotected mode is on and if:[l11]

#

# 1)The server is not binding explicitly to a set of addresses using the

#   "bind" directive.[l12]

# 2) Nopassword is configured.[l13]

#

#The server only accepts connections from clients connecting from the

# IPv4 and IPv6 loopback addresses127.0.0.1 and ::1, and from Unix domain

# sockets.[l14]

#

# Bydefault protected mode is enabled. You should disable it only if

# you are sure you want clients fromother hosts to connect to Redis

# even if no authentication isconfigured, nor a specific set of interfaces

# are explicitly listed using the"bind" directive.[l15]

protected-modeyes[l16]



#Accept connections on the specified port, default is 6379 (IANA #815344).

# If port 0 is specified Redis will notlisten on a TCP socket.[l17]

port 6379



#TCP listen() backlog.[l18]

#

#In high requests-per-second environments you need an high backlog in order

# to avoid slow clients connectionsissues. Note that the Linux kernel

# will silently truncate it to the valueof /proc/sys/net/core/somaxconn so

# make sure to raise both the value ofsomaxconn and tcp_max_syn_backlog

# in order to get the desired effect.[l19]

tcp-backlog 511



# Unix socket.

#

#Specify the path for the Unix socket that will be used to listen for

# incoming connections. There is nodefault, so Redis will not listen

# on a unix socket when not specified.[l20]

#

# unixsocket /tmp/redis.sock

# unixsocketperm 700



# Closethe connection after a client is idle for N seconds (0 to disable)[l21]

timeout 0



# TCP keepalive.

#

# Ifnon-zero, use SO_KEEPALIVE to send TCP ACKs to clients in absence

# of communication. This is useful fortwo reasons:[l22]

#

# 1)Detect dead peers.

# 2) Take the connection alive from thepoint of view of network

#   equipment in the middle.[l23]

#

# OnLinux, the specified value (in seconds) is the period used to send ACKs.

# Note that to close the connection thedouble of the time is needed.

# On other kernels the period depends onthe kernel configuration.[l24]

#

#A reasonable value for this option is 300 seconds, which is the new

# Redis default starting with Redis3.2.1.[l25]

tcp-keepalive 300

[l1]当需要为某个配置项指定内存大小的时候,必须要带上单位,同城的格式是1k,5gb,4m等

[l2]单位不区分大小写,1GB,1GB,1GB都一样。

[l3]在此处包含一个或多个其他配置文件。如果您有一个标准模板可用于所有Redis服务器,但还需要自定义几个每服务器设置,这将非常有用。包含文件可以包括其他文件,因此请明智地使用。

[l4]注意选项“include”不会被来自admin或RedisSentinel的命令“CONFIG REWRITE”重写。由于Redis总是使用最后处理的行作为配置指令的值,因此最好将include包含在此文件的开头,以避免在运行时覆盖配置更改

[l5]相反,如果你有兴趣使用包括覆盖配置选项,最好是使用包括作为最后一道防线。

[l6]网络配置说明

[l7]默认情况下,如果没有指定“bind”配置指令,Redis会监听来自服务器上所有可用网络接口的连接。 可以使用“绑定”配置指令侦听一个或多个选定的接口,然后跟一个或多个IP地址。

[l8]~~~警告~~~如果运行Redis的计算机直接暴露在互联网上,绑定到所有接口是危险的,并且会将实例暴露给互联网上的每个人。因此,在默认情况下,我们取消以下绑定指令,这将迫使Redis的只监听到的IPv4回望接口地址(这意味着Redis的将只能从运行到正在运行在同一台计算机的客户端接受连接)。

[l9]如果你确信你想你的实例能够监听到所有的界面,注释下面一行。

[l10]保护模式是安全的保护层,以避免该Redis的实例留在互联网上公开被访问和利用。

[l11]当保护模式打开时,如果:

[l12]1)服务器没有使用“bind”指令明确绑定到一组地址。

[l13]2)未配置密码。

[l14]服务器只接受来自从IPv4和IPv6环回地址127.0.0.1和:: 1以及从Unix域套接字连接的客户端的连接。

[l15]默认情况下启用保护模式。 只有确保您希望来自其他主机的客户端连接到Redis,即使未配置身份验证,也不会使用“bind”指令明确列出特定的接口集,才应禁用它。

[l16]启用保护模式

[l17]接受指定端口上的连接,默认值为6379(IANA#815344)。如果指定端口0,Redis将不会侦听TCP套接字。

[l18]TCP监听的最大容纳数量

[l19]在高请求每秒环境中,您需要一个高的容纳数量,以避免缓慢的客户端连接问题。注意,Linux内核会将其默认截断为/ proc / sys / net / core / somaxconn的值,因此请务必同时提高somaxconn和tcp_max_syn_backlog的值,以获得所需的效果。

[l20]指定将用于侦听传入连接的Unix套接字的路径。 没有默认值,所以Redis在没有指定的时候不会监听unixsocket

[l21]客户端空闲N秒后关闭连接(0禁用)

[l22]如果非零,则使用SO_KEEPALIVE在没有通信的情况下向客户端发送TCP ACK。这有两个原因:

[l23]1)检测死对等体。
2)从中间的网络设备的角度来看连接活着

[l24]在Linux上,指定的值(以秒为单位)是用于发送ACK的周期。注意,要关闭连接,需要两倍的时间。在其他内核上,周期取决于内核配置。

[l25]此选项的合理值为300秒,这是从Redis 3.2.1开始的新Redis默认值。

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-321460-1-1.html 上篇帖子: redis按下ctrl + c进程就没了 下篇帖子: redis单机搭建
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

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