大小写
# 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.
配置文件
# 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
网络
# bind 192.168.1.100 10.0.0.1 # listens on two specific IPv4 addresses
# bind 127.0.0.1 ::1 # listens on loopback IPv4 and IPv6
# bind * -::* # like the default, all available interfaces
#
# 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 # 绑定ip,监听IPv4和IPv6环回
# 开启保护模式
protected-mode yes
# 默认端口
port 6379
通用配置
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
# When Redis is supervised by upstart or systemd, this parameter has no impact.
# 以守护进程的方式运行(后台运行),默认是no,要改为yes
daemonize no
# When the server runs non daemonized, no pid file is created if none is
# specified in the configuration. When the server is daemonized, the pid file
# is used even if not specified, defaulting to "/var/run/redis.pid".
#
# Creating a pid file is best effort: if Redis is not able to create it
# nothing bad happens, the server will start and run normally.
#
# Note that on modern Linux systems "/run/redis.pid" is more conforming
# and should be used instead.
# 如果以守护进程的方式运行,需要指定一个pid文件
pidfile /var/run/redis_6379.pid
# 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)
# 日志级别 debug(测试开发环境用),verbose(详细),notice(生产环境用),warning
loglevel notice
# 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 ""
# 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
# 默认16个数据库
databases 16
快照(SNAPSHOTTING)
# Redis will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
# 禁用快照
# save ""
# save <seconds> <changes>
# save 3600 1
# save 300 100
# save 60 10000
# 持久化出现错误之后是否继续工作
stop-writes-on-bgsave-error yes
# Compress string objects using LZF when dump .rdb databases?
# By default compression is enabled as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
# 是否压缩rdb文件,需要消耗CPU资源
rdbcompression yes
# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
# 保存rdb文件时,进行错误校验
rdbchecksum yes
# The filename where to dump the DB
dbfilename dump.rdb
# rdb文件是否删除同步锁
rdb-del-sync-files no
# rdb文件地址
dir ./
复制(REPLICATION)
主从复制
安全security
requirepass foobared
config set requirepass 1111
config get requirepass
auth 1111
客户端client
maxclients 10000
maxmemory <bytes>
maxmemory-policy noeviction
volatile-lru -> 只对设置了过期时间的key进行lru
allkeys-lru -> 删除lru算法的key
volatile-random -> 随机删除即将过期的key
allkeys-random -> 随机删除key
volatile-ttl -> 删除即将过期的
noeviction -> 永不过期,返回错误
APPEND ONLY MODE模式 ,aof配置
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
|