Redis配置文件

原文链接:Redis配置文件 – 编程屋

1 Redis配置文件

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

#

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

默认情况下bind=127.0.0.1 只能接受本机的访问请求,不写的情况下,无限制接受任何ip地址的访问

# 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

yes允许远程访问 no只能本地访问

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

# you are sure you want clients from other hosts to connect to Redis

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

# are explicitly listed using the "bind" directive.

protected-mode yes

端口号 默认6379

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

# If port 0 is specified Redis will not listen on a TCP socket.

port 6379

tcp的backlog,backlog其实是一个连接队列,backlog队列总和=未完成三次握手队列+已经完成三次握手队列

# TCP listen() backlog.

#

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

# to avoid slow clients connection 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

一个空闲客户端维持多少秒会关闭,0表示关闭该功能,即永不关闭

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

timeout 0

心跳机制,每隔300秒检测一次

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

# Redis default starting with Redis 3.2.1.

tcp-keepalive 300

存放pid文件的位置,每个实例会产生一个不同的pid文件

# Note that on modern Linux systems "/run/redis.pid" is more conforming

# and should be used instead.

pidfile /var/run/redis_6379.pid

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

logfile "" 设置日志文件的输出路径 默认为空

# Specify the log file name. Also the empty string can be used to force

# Redis to log on the standard output. Note that if you use standard

# output for logging but daemonize, logs will be sent to /dev/null

logfile ""

databases 16 redis有16个库 默认使用0号库

# Set the number of databases. The default database is DB 0, you can select

# a different one on a per-connection basis using SELECT <dbid> where

# dbid is a number between 0 and 'databases'-1

databases 16

maxclients 10000 redis客户端最大连接数(默认没有设置) 如果达到了此限制,redis则会拒绝新的连接请求,并向这些连接请求方发出"max number of clients reached"

# IMPORTANT: When Redis Cluster is used, the max number of connections is also

# shared with the cluster bus: every node in the cluster will use two

# connections, one incoming and another outgoing. It is important to size the

# limit accordingly in case of very large clusters.

#

# maxclients 10000

maxmemory 设置redis可以使用的内存量。一旦到达内存上线,redis将会试图移除内部数据,移除规则可以通过maxmemory-policy来指定

以上只是部分内容,为了维护方便,本文已迁移到新地址:Redis配置文件 – 编程屋

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值