Redis.conf文件

大小写

# 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,监听IPv4IPv6环回

# 开启保护模式
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

// config中
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配置

// 是否开启aof持久化,默认是不开启的,默认是rdb方式持久化,在大部分情况下rdb够用了
appendonly no
// 每秒执行一次同步,可能会丢失1s的数据。always每次修改都会,消耗性能。no不执行
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值