Redis配置文件详解

  • 单位
# 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 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. redis配置文件对大小写不敏感
  • 包含
################################## INCLUDES ###################################

# 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.
#
# Notice 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 127.0.0.1 #绑定ip
protected-mode no #保护模式
port 6379 #端口设置
  • 通用
daemonize yes #以守护进程的方式运行,默认是no,我们需要手动开启
pidfile /var/run/redis_6379.pid #如果以守护进程的方式运行,我们需要指定一个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)
loglevel notice #日志级别
logfile "" #日志生成的文件名
databases 16 #默认16个数据库
always-show-logo yes #是否显示logo
  • 快照
    持久化,在规定时间内执行多少次操作就会持久化到文件。.rdb .aof
#900秒内,至少有一个key修改,进行持久化
save 900 1
#300秒内,至少有10个key修改,进行持久化
save 300 10
#60秒内,至少有10000key修改,进行持久化
save 60 10000

stop-writes-on-bgsave-error yes #如果持久化出错是否继续工作

rdbcompression yes #是否压缩rdb文件

rdbchecksum yes #保存rdb文件时,进行错误校验

dir ./ #rdb文件保存目录
  • 安全
requirepass 123456 #设置密码
  • 限制
maxclients 10000 #最大客户端连接数
maxmemory <bytes> #配置redis最大的内存容量
maxmemory-policy noeviction #内存到达上限之后的处理策略
  • AOF配置
appendonly no #默认是不开启aof的,大部分情况下,rdb完全够用
appendfilename "appendonly.aof" #持久化的文件名字
#appendfsync always #每次修改都会sync,消耗性能
appendfsync everysec #每秒执行一次sync,可能会丢失一秒数据
#appendfsync no #不执行sync,这个时候操作系统自己同步数据,速度最快。
Redis 是一个开源的内存数据存储系统,主要用作缓存和数据库。Redis 配置文件Redis 服务器的配置文件,它包含了 Redis 服务器的所有配置选项。 Redis 配置文件的位置在 Redis 安装目录下的 redis.conf 文件中,可以通过修改该文件来配置 Redis 服务器。下面是 Redis 配置文件的一些常用配置选项的详解: 1. bind:Redis 服务器的绑定地址,在默认情况下,Redis 服务器会绑定所有可用的网络接口,可以通过设置 bind 选项来指定 Redis 服务器的绑定地址。 2. port:Redis 服务器的监听端口,默认情况下,Redis 服务器会监听 6379 端口,可以通过设置 port 选项来指定 Redis 服务器的监听端口。 3. daemonize:Redis 服务器是否以守护进程的方式启动,默认情况下,Redis 服务器会以前台进程的方式启动,可以通过设置 daemonize 选项来指定 Redis 服务器是否以守护进程的方式启动。 4. logfile:Redis 服务器的日志文件路径,默认情况下,Redis 服务器的日志文件路径为标准输出,可以通过设置 logfile 选项来指定 Redis 服务器的日志文件路径。 5. databases:Redis 服务器的数据库数量,默认情况下,Redis 服务器只有一个数据库,可以通过设置 databases 选项来指定 Redis 服务器的数据库数量。 6. maxclients:Redis 服务器的最大连接数,默认情况下,Redis 服务器的最大连接数为 10000,可以通过设置 maxclients 选项来指定 Redis 服务器的最大连接数。 7. maxmemory:Redis 服务器的最大内存使用量,默认情况下,Redis 服务器不限制最大内存使用量,可以通过设置 maxmemory 选项来指定 Redis 服务器的最大内存使用量。 以上是 Redis 配置文件的一些常用配置选项的详解,通过修改这些配置选项,可以对 Redis 服务器进行各种配置和优化。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值