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默认值。



转载于:https://blog.51cto.com/lqyan/1887425