`
jiangwenfeng762
  • 浏览: 285924 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

redis.conf配置项说明

阅读更多

#是否以后台进程运行,默认为no,如果需要以后台进程运行则改为yes

daemonize no

 

 

#如果以后台进程运行的话,就需要指定pid,你可以在此自定义redis.pid文件的位置。

pidfile /var/run/redis.pid

 

 

#接受连接的端口号,如果端口是0则redis将不会监听TCP socket连接

port 6379

 

# If you want you can bind a single interface, if the bind option is not

# specified all the interfaces will listen for incoming connections.

#

# bind 127.0.0.1

 

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

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

# on a unix socket when not specified.

#

# unixsocket /tmp/redis.sock

# unixsocketperm 755

 

 

#连接超时时间,单位秒。(0 to disable)?

timeout 300000000

 

 

#日志级别,默认是verbose(详细),各种日志级别:

#debug:很详细的信息,适合开发和测试

#verbose:包含许多不太有用的信息,但比debug要清爽一些(many rarely useful info, but not a mess like #the debug level)

#notice:比较适合生产环境

#warning:警告信息

loglevel verbose

 

 

#指定log文件的名字,默认是stdout。stdout会让redis把日志输出到标准输出。但是如果使用stdout而又以后台进#程的方式运行redis,则日志会输出到/dev/null

logfile stdout

 

 

#'syslog-enabled'设置为yes会把日志输出到系统日志,默认是no

# syslog-enabled no

 

 

#指定syslog的标示符,如果'syslog-enabled'是no,则这个选项无效。

# syslog-ident redis

 

 

#指定syslog 设备(facility), 必须是USER或者LOCAL0到LOCAL7.

# syslog-facility local0

 

 

#设置数据库数目。默认的数据库是DB 0。可以通过SELECT <dbid>来选择一个数据库,dbid是[0,'databases'-1]的数字

databases 16

 

################## 快照#################################

#

# 硬盘上保存数据:

#

#   save <seconds> <changes>

#

#   <seconds>和<changes>都满足时就会触发数据保存动作。

#   

#

#   以下面的例子来说明:

#   过了900秒并且有1个key发生了改变 就会触发save动作

#   过了300秒并且有10个key发生了改变 就会触发save动作

#   过了60秒并且至少有10000个key发生了改变 也会触发save动作

#

#   注意:如果你不想让redis自动保存数据,那就把下面的配置注释掉!

 

save 900 1

save 300 10

save 60 10000

 

 

#存储数据时是否压缩数据。默认是yes。

rdbcompression yes

 

# 保存dump数据的文件名

dbfilename dump.rdb

 

# 工作目录.

#

# 数据会被持久化到这个目录下的‘dbfilename’指定的文件中。

# 注意,这里指定的必须是目录而不能是文件。

dir ./

 

######## REPLICATION(复制,冗余)#################################

 

# Master-Slave replication. 使用slaveof把一个 Redis 实例设置成为另一个Redis server的从库(热备). 注意: #配置只对当前slave有效。

# 因此可以把某个slave配置成使用不同的时间间隔来保存数据或者监听其他端口等等。

#命令格式:

# slaveof <masterip> <masterport>

 

 

#如果master有密码保护,则在slave与master进行数据同步之前需要进行密码校验,否则master会拒绝slave的请#求。

#

# masterauth <master-password>

 

#当slave丢失与master的连接时,或者slave仍然在于master进行数据同步时(还没有与master保持一致),#slave可以有两种方式来响应客户端请求:

#

# 1) 如果 slave-serve-stale-data 设置成 'yes' (the default) slave会仍然响应客户端请求,此时可能会有问题。

#

# 2) 如果 slave-serve-stale data设置成  'no'  slave会返回"SYNC with master in progress"这样的错误信息。 但 INFO 和SLAVEOF命令除外。

#

slave-serve-stale-data yes

 

############### 安全 ###################################

 

# 需要客户端在执行任何命令之前指定 AUTH <PASSWORD>

#

# requirepass foobared

 

# 命令重命名.

#

#

# 例如:

#

# rename-command CONFIG b840fc02d524045429941cc15f59e41cb7be6c52

#

# 同样可以通过把一个命令重命名为空串来彻底kill掉这个命令,比如:

#

# rename-command CONFIG ""

 

#################### 限制 ####################################

 

# 设置最大连接数. 默认没有限制,  '0' 意味着不限制.

#

# maxclients 128

 

 

#最大可使用内存。如果超过,Redis会试图删除EXPIRE集合中的keys,具体做法是:Redis会试图释放即将过期的#keys,而保护还有很长生命周期的keys。

#

#如果这样还不行,Redis就会报错,但像GET之类的查询请求还是会得到响应。

#

#警告:如果你想把Redis视为一个真正的DB的话,那不要设置<maxmemory>,只有你只想把Redis作为cache或者

#有状态的server('state' server)时才需要设置。

#

# maxmemory <bytes>

 

#内存清理策略:如果达到了maxmemory,你可以采取如下动作:

# volatile-lru -> 使用LRU算法来删除过期的set

# allkeys-lru -> 删除任何遵循LRU算法的key

# volatile-random ->随机地删除过期set中的key

# allkeys->random -> 随机地删除一个key

# volatile-ttl -> 删除最近即将过期的key(the nearest expire time (minor TTL))

# noeviction -> 根本不过期,写操作直接报错

#

# 默认策略:

#

# maxmemory-policy volatile-lru

 

# 对于处理redis内存来说,LRU和minor TTL算法不是精确的,而是近似的(估计的)算法。所以我们会检查某些样本#来达到内存检查的目的。默认的样本数是3,你可以修改它。

#

# maxmemory-samples 3

 

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

 

#默认情况下,Redis会异步的把数据保存到硬盘。如果你的应用场景允许因为系统崩溃等极端情况而导致最新数据丢失#的话,那这种做法已经很ok了。否则你应该打开‘append only’模式,开启这种模式后,Redis会在#appendonly.aof文件中添加每一个写操作,这个文件会在Redis启动时被读取来在内存中重新构建数据集。

#

#注意:如果你需要,你可以同时开启‘append only’模式和异步dumps模式(你需要注释掉上面的‘save’表达式来禁#止dumps),这种情况下,Redis重建数据集时会优先使用appendonly.aof而忽略dump.rdb

#

appendonly no

 

#  append only 文件名 (默认: "appendonly.aof")

# appendfilename appendonly.aof

 

# 调用fsync()函数通知操作系统立刻向硬盘写数据

#

# Redis支持3中模式:

#

# no:不fsync, 只是通知OS可以flush数据了,具体是否flush取决于OS.性能更好.

# always: 每次写入append only 日志文件后都会fsync . 性能差,但很安全.

# everysec: 没间隔1秒进行一次fsync. 折中.

#

# 默认是 "everysec"

# appendfsync always

appendfsync everysec

# appendfsync no

 

# 当AOF fsync策略被设置为always或者everysec并且后台保存进程(saving process)正在执行大量I/O操作时

# Redis可能会在fsync()调用上阻塞过长时间

#

no-appendfsync-on-rewrite no

 

# append only 文件的自动重写

# 当AOF 日志文件即将增长到指定百分比时,Redis可以通过调用BGREWRITEAOF 来自动重写append only文件。

# 它是这么干的:Redis会记住最近一次重写后的AOF 文件size。然后它会把这个size与当前size进行比较,如果当前# size比指定的百分比大,就会触发重写。同样,你需要指定AOF文件被重写的最小size,这对避免虽然百分比达到了# 但是实际上文件size还是很小(这种情况没有必要重写)却导致AOF文件重写的情况很有用。

#

#

# auto-aof-rewrite-percentage 设置为 0 可以关闭AOF重写功能

 

auto-aof-rewrite-percentage 100

auto-aof-rewrite-min-size 64mb

 

################## SLOW LOG ###################################

 

# Redis slow log用来记录超过指定执行时间的查询。

# 你可以指定两个参数:一个是慢查询的阀值,单位是毫秒;另外一个是slow log的长度,相当于一个队列。

 

# 负数则关闭slow log,0则会导致每个命令都被记录

slowlog-log-slower-than 10000

 

# 不设置会消耗过多内存,所以还是要设置一下。可以使用SLOWLOG RESET命令来回收slow log使用的内存

slowlog-max-len 1024

 

################ 虚拟内存 ###############################

#使用redis 就别用虚拟内存了,绝对不是一个好主意,加个机器吧,所以这里不翻译啦!!

 

### WARNING! Virtual Memory is deprecated in Redis 2.4

### The use of Virtual Memory is strongly discouraged.

 

# Virtual Memory allows Redis to work with datasets bigger than the actual

# amount of RAM needed to hold the whole dataset in memory.

# In order to do so very used keys are taken in memory while the other keys

# are swapped into a swap file, similarly to what operating systems do

# with memory pages.

#

# To enable VM just set 'vm-enabled' to yes, and set the following three

# VM parameters accordingly to your needs.

 

vm-enabled no

# vm-enabled yes

 

# This is the path of the Redis swap file. As you can guess, swap files

# can't be shared by different Redis instances, so make sure to use a swap

# file for every redis process you are running. Redis will complain if the

# swap file is already in use.

#

# The best kind of storage for the Redis swap file (that's accessed at random) 

# is a Solid State Disk (SSD).

#

# *** WARNING *** if you are using a shared hosting the default of putting

# the swap file under /tmp is not secure. Create a dir with access granted

# only to Redis user and configure Redis to create the swap file there.

vm-swap-file /tmp/redis.swap

 

# vm-max-memory configures the VM to use at max the specified amount of

# RAM. Everything that deos not fit will be swapped on disk *if* possible, that

# is, if there is still enough contiguous space in the swap file.

#

# With vm-max-memory 0 the system will swap everything it can. Not a good

# default, just specify the max amount of RAM you can in bytes, but it's

# better to leave some margin. For instance specify an amount of RAM

# that's more or less between 60 and 80% of your free RAM.

vm-max-memory 0

 

# Redis swap files is split into pages. An object can be saved using multiple

# contiguous pages, but pages can't be shared between different objects.

# So if your page is too big, small objects swapped out on disk will waste

# a lot of space. If you page is too small, there is less space in the swap

# file (assuming you configured the same number of total swap file pages).

#

# If you use a lot of small objects, use a page size of 64 or 32 bytes.

# If you use a lot of big objects, use a bigger page size.

# If unsure, use the default :)

vm-page-size 32

 

# Number of total memory pages in the swap file.

# Given that the page table (a bitmap of free/used pages) is taken in memory,

# every 8 pages on disk will consume 1 byte of RAM.

#

# The total swap size is vm-page-size * vm-pages

#

# With the default of 32-bytes memory pages and 134217728 pages Redis will

# use a 4 GB swap file, that will use 16 MB of RAM for the page table.

#

# It's better to use the smallest acceptable value for your application,

# but the default is large in order to work in most conditions.

vm-pages 134217728

 

# Max number of VM I/O threads running at the same time.

# This threads are used to read/write data from/to swap file, since they

# also encode and decode objects from disk to memory or the reverse, a bigger

# number of threads can help with big objects even if they can't help with

# I/O itself as the physical device may not be able to couple with many

# reads/writes operations at the same time.

#

# The special value of 0 turn off threaded I/O and enables the blocking

# Virtual Memory implementation.

vm-max-threads 4

 

################高级配置###############################

 

# Hashes are encoded in a special way (much more memory efficient) when they

# have at max a given numer of elements, and the biggest element does not

# exceed a given threshold. You can configure this limits with the following

# configuration directives.

hash-max-zipmap-entries 512

hash-max-zipmap-value 64

 

# Similarly to hashes, small lists are also encoded in a special way in order

# to save a lot of space. The special representation is only used when

# you are under the following limits:

list-max-ziplist-entries 512

list-max-ziplist-value 64

 

# Sets have a special encoding in just one case: when a set is composed

# of just strings that happens to be integers in radix 10 in the range

# of 64 bit signed integers.

# The following configuration setting sets the limit in the size of the

# set in order to use this special memory saving encoding.

set-max-intset-entries 512

 

# Similarly to hashes and lists, sorted sets are also specially encoded in

# order to save a lot of space. This encoding is only used when the length and

# elements of a sorted set are below the following limits:

zset-max-ziplist-entries 128

zset-max-ziplist-value 64

 

# Active rehashing uses 1 millisecond every 100 milliseconds of CPU time in

# order to help rehashing the main Redis hash table (the one mapping top-level

# keys to values). The hash table implementation redis uses (see dict.c)

# performs a lazy rehashing: the more operation you run into an hash table

# that is rhashing, the more rehashing "steps" are performed, so if the

# server is idle the rehashing is never complete and some more memory is used

# by the hash table.

# The default is to use this millisecond 10 times every second in order to

# active rehashing the main dictionaries, freeing memory when possible.

#

# If unsure:

# use "activerehashing no" if you have hard latency requirements and it is

# not a good thing in your environment that Redis can reply form time to time

# to queries with 2 milliseconds delay.

#

# use "activerehashing yes" if you don't have such hard requirements but

# want to free memory asap when possible.

activerehashing yes

 

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

 

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

# have a standard template that goes to all redis server but also need

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

# other files, so use this wisely.

#

# include /path/to/local.conf

# include /path/to/other.conf


 

 

 

分享到:
评论

相关推荐

    Redis配置文件redis.conf详细配置说明

    redis.conf 配置项说明如下 redis配置文件详解 # vi redis.conf daemonize yes #是否以后台进程运行 pidfile /var/run/redis/redis-server.pid #pid文件位置 port 6379#监听端口 bind 127.0.0.1 #绑定地址,如外网...

    Redis配置文件redis.conf详解

    Linux下的配置文件单独考拷贝出来进行操作,这是一个好习惯!...pidfile /var/run/redis_6379.pid:当Redis以守护进程方式运行时,即使该项没有配置,Redis也会默认把pid写入/var/run/redis.pid文件;而当Redis不是以

    redis 配置文件1

    参数说明redis.conf 配置项说明如下:1. Redis默认不是以守护进程的方式运行,可以通过该配置项修改,使用yes启用守护进程 daemonize

    windows版的redis(3.0.501版)master-slave

    1、windows下redis,版本是3.0.501。...3、redis.conf配置项可参考:http://blog.csdn.net/zhutulang/article/details/51969760 搭建主从复制可参考:http://www.linuxidc.com/Linux/2015-04/116798.htm

    redis服务器配置.pdf

    Redis 服务器命令主要是用于管理 redis 服务。 Redis 的配置文件位于 Redis 安装目录下,文件名为 redis.conf(Windows 名为 redis.windows.conf)。 你可以通过 CONFIG 命令查看或设置配置项

    redis-x64-4.0.2.3,windows版本

    1.配置redis.windows.conf文件,除了port配置为对应的端口外,其他根据需要可更改的配置项说明如下: (1)bind 127.0.0.1 (line:79) # 设置为其他机器可以访问redis服务,如果本机存在多网卡或外网IP,请使用空格...

    redis.conf

    redis的配置文件,redis4.0开始允许使用RDB和AOF混合持久化的方式,结合了两者的优点通过aof-use-rdb-preamble配置项可以打开混合开关。

    Linux下Redis数据库的安装方法与自动启动脚本分享

    安装Redis  (1) 下载Redis wget ...cp redis.conf /etc/redis.conf vi /etc/redis.conf 注意修改以下几项: daemonize yes loglevel warning logfile /var/log/redis.log maxmemory 2GB

    压缩文件 windows redis4.0

    1.配置redis.windows.conf文件,除了port配置为对应的端口外,其他根据需要可更改的配置项说明如下: (1)bind 127.0.0.1 (line:79) # 设置为其他机器可以访问redis服务,如果本机存在多网卡或外网IP,请使用空格...

    redis-7.2.2.tar.gz

    Redis的安装包通常包含了Redis服务器和客户端所需的所有文件和依赖项,使得用户能够轻松地安装和配置Redis。这些安装包通常适用于不同的操作系统和平台,如Windows、Linux等。 在Windows系统下,Redis安装包可能...

    tomcat-redis-session-8.5.5.0

    通过插入以下行来配置全局上下文(CATALINA.HOME / conf / context.xml)或Web应用程序上下文(META-INF / context.xml),以使用Tomcat Redis Session Manager “ ru.zinin.redis.session.RedisManager ” /&gt; ...

    redis使用以及集群部署文档

    redis的各种配置都是在redis.conf文件中进行配置的,有关其每项配置的中文详细解释如下。redis使用以及集群部署文档,作为自己以后使用的文档

    第二节Redis缓存高可用集群1

    第一步:把之前的redis.conf配置文件copy到8001下,修改如下内容: 第三步:把修改后的配置文件,copy到8002,修改第2、3、5项里的端口号,

    kumo-manga:基于网络的漫画阅读器

    设置并运行redis,包括以下/etc/redis.conf行或将其附加到/etc/redis.conf的现有配置。redis.conf maxmemory 500mbmaxmemory-policy allkeys-lrumaxmemory-samples 5Windows安装程序您将需要下载unrar.exe并将其...

    Redis优化经验总结(必看篇)

    Redis Hash是value内部为一个HashMap,如果该Map的成员数比较少,则会采用类似一维线性的紧凑格式来存储该Map, 即省去了大量指针的内存开销,这个参数控制对应在redis.conf配置文件中下面2项: hash-max-zipmap-...

    Zabbix6.0全套方案附件之Agent2客户端一键部署和Linux+Nginx+Mysql+Redis生产级监控模板

    模版导入服务端即可使用,包含80+监控项,60+自动发现监控项,已配置常见图表和触发器,大量采用中文简体,方便非运维识别告警信息。 一键安装包说明: - 根据系统版本选择相对应的"zabbix_agent2-6.0.22-ce-...

    goblog_release.zip

    下载压缩包,修改数据库配置项。 1、创建一个mysql数据库,把sql导入到mysql数据库中,修改一下conf目录下的config.toml文件。 2、运行 先给予tool.sh程序执行权限chmod +x tool.sh,在程序目录输入./tool....

    Redis2.8配置文件中文详解

    采用redis-server xxx.conf 这样的方式可以按照指定的配置文件来运行Redis服务。下面是Redis2.8.9的配置文件各项的中文解释。 #daemonize no 默认情况下, redis 不是在后台运行的,如果需要在后台运行,把该项的值...

    Nginx安装包

    此外,redis能实现的作用很多,诸如队列、缓存之类的,但我也还没使用过,无法在这里为大家说明,但不影响我们今天的session共享功能。 首先我们先下载redis,这是windows版本的下载地址 ...

Global site tag (gtag.js) - Google Analytics