当前位置:网站首页>REDIS00_详解redis.conf配置文件
REDIS00_详解redis.conf配置文件
2022-06-28 15:34:00 【所得皆惊喜】
文章目录
①. Units - 单位
- Units:单位,Redis配置文件中的单位对大小写不敏感
单位不区分大小写,所以1GB 1Gb 1gB都是一样的
# Redis configuration file example
# 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.
# [翻译]单位不区分大小写,所以1GB 1Gb 1gB都是一样的。
②. includes - 包括
- includes:包含,可以在Redis启动的时候再加载一些除了Redis.conf之外的其他的配置文件,和Spring的import,jsp的include类似
################################## 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 c:\path\to\other.conf
③. NETWORK - 网络
①. bind:网络,表示Redis启动时开放的端口默认与本机绑定
②. protected-mode:yes 是否开启保护模式,Redis默认开启,如果没有设置bind的IP地址和Redis密码,那么服务就会默认只能在本机运行
################################## NETWORK #####################################
# By default, ...
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ ...
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# [作用]网络,表示Redis启动时开放的端口默认与本机绑定
bind 127.0.0.1
# Protected mode is a layer of security protection, in order to avoid that
# ...
# [作用]是否开启保护模式,Redis默认开启,如果没有设置bind的IP地址和Redis密码,那么服务就会默认只能在本机运行
protected-mode yes
# [翻译]接受指定端口上的连接,默认为6379 (IANA #815344)。
# [翻译]如果端口0被指定,Redis将不会监听TCP套接字。
# [作用]Redis指定监听端口,默认为6379
port 6379
# ...
# [作用]表示服务器闲置多长时间(秒)后被关闭,如果这个这个数值为0,表示这个功能不起作用
timeout 0
④. GENERAL - 守护线程
- daemonize yes:以守护进程的方式运行,默认是 no,我们需要自己开启为yes
daemonize yes # 以守护进程的方式运行,默认是 no,我们需要自己开启为yes!
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
⑤. SNAPSHOTTING - 持久化
①. 中文翻译为快照,如果在规定的时间内,数据发生了几次更新,那么就会将数据同步备份到一个文件中
②. Redis的持久化有两种方式,一种是RDB,一种是AOF。SNAPSHOTTING主要针对的是Redis持久化中的RDB
③. Redis是一个内存数据库,如果不采用持久化对数据进行保存,那么就会出现断电即失的尴尬场面
################################ SNAPSHOTTING ################################
# ...
# 在900秒内,至少有一个key被修改(添加),就会进行持久化操作
save 900 1
# 在300秒内,至少有10个key被修改,就会进行持久化操作
save 300 10
# 在60秒内,至少有1万个key被修改,就会进行持久化操作
save 60 10000
# 如果Redis在进行持久化的时候出现错误,是否停止写入,默认为是
top-writes-on-bgsave-error yes
#是否在进行数据备份时压缩持久化文件,默认为是,这个操作会耗费CPU资源,可以设置为no
rdbcompression yes
# 在保存持久化文件的同时,对文件内容进行数据校验
rdbchecksum yes
# 持久化文件保存的目录,默认保存在当前目录下
dir ./
⑥. REPLICATION - 主从复制
# 复制主机上的数据,当前配置所指定的IP和端口号即为主机
################################# REPLICATION #################################
# Redis在配置文件中将此配置注释,默认不使用,下同
# replicaof <masterip> <masterport>
# 如果配置的主机有密码,需要配置此密码以通过master的验证
# masterauth <master-password>
⑦. SECURITY - 密码
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> config get requirepass # 获取redis的密码
1) "requirepass"
2) ""
127.0.0.1:6379> config set requirepass "123456" # 设置redis的密码
OK
127.0.0.1:6379> config get requirepass # 发现所有的命令都没有权限了
(error) NOAUTH Authentication required.
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456 # 使用密码进行登录!
OK
127.0.0.1:6379> config get requirepass
1) "requirepass"
2) "123456"
⑧. CLIENT - 客户端
- volatile-lru:只对设置了过期时间的key进行LRU(默认值)
allkeys-lru: 删除lru算法的key
volatile-random:随机删除即将过期key
allkeys-random:随机删除
volatile-ttl: 删除即将过期的
noeviction: 永不过期,返回错误
# Redis允许存在的客户端的最大数量,默认有一万个
################################### CLIENTS ####################################
# Redis允许存在的客户端的最大数量,默认有一万个
# maxclients 10000
############################## MEMORY MANAGEMENT ################################
# Redis配置最大的内存容量
# maxmemory <bytes>
# 内存达到上限之后默认的处理策略
# maxmemory-policy noeviction
⑨. APPEND - 持久化
- ①. 这是Redis持久化的另一种方式,AOF,AOF模式默认不开启,Redis默认开启的是持久化模式是RDB,在大部分情况下,RDB的模式完全够用
appendonly no
# AOF持久化的文件名称
appendfilename "appendonly.aof"
# 每秒执行一次同步,但是可能会丢失这一秒的数据
# 对于 appendfsync 它有以下几个属性
# appendfsync always 表示每次修改都会进行数据同步,速度较慢,消耗性能
# appendfsync no 不执行同步,不消耗性能
appendfsync everysec # 数据不同步,每秒记录一次
边栏推荐
- The past and present life of distributed cap theorem
- C语言学习-19-全排列
- See how the interface control devaxpress WinForms creates a virtual keyboard
- 如何从零搭建10万级 QPS 大流量、高并发优惠券系统
- MySQL主从切换的超详细步骤
- Web worker poll request
- R语言ggplot2可视化:使用patchwork包将两个ggplot2可视化结果纵向堆叠起来(stacking)形成组合图、一个可视化结果堆叠在另外一个可视化结果上
- C#/VB.NET 将PDF转为Excel
- Complete model training routine (I)
- R language ggplot2 visualization: use the patchwork package (directly use the plus sign +) to horizontally combine a ggplot2 visualization result and a data table to form a final result graph
猜你喜欢

Not being a meta universe now is like not buying a house 20 years ago!

Fleet |「後臺探秘」第 3 期:狀態管理

Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
PostgreSQL实现按年、月、日、周、时、分、秒的分组统计

Fleet | "backstage exploration" issue 3: status management

经典模型——Transformer

What useful supplier management systems are available

MIPS汇编语言学习-03-循环

Application of mongodb in Tencent retail premium code

Installation and use of Jenkins
随机推荐
Leetcode 705. Design hash collection
How can the digital intelligent supply chain management platform of the smart Park optimize process management and drive the development of the park to increase speed and quality?
spark sql 生成 json
Leetcode 48. Rotate image (yes, resolved)
Leike defense: 4D millimeter wave radar products are expected to be mass produced and supplied by the end of the year
MIPS assembly language learning -02- logic judgment - foreground input
Experiment 6 8255 parallel interface experiment [microcomputer principle] [experiment]
买卖股票的最佳时机
如何从零搭建10万级 QPS 大流量、高并发优惠券系统
Installation and use of Jenkins
Practice of curve replacing CEPH in Netease cloud music
实验6 8255并行接口实验【微机原理】【实验】
In depth learning foundation summary
What! 一条命令搞定监控?
环保产品“绿色溢价”高?低碳生活方式离人们还有多远
Validate palindrome string
看界面控件DevExpress WinForms如何创建一个虚拟键盘
OpenHarmony—内核对象事件之源码详解
Fleet |「後臺探秘」第 3 期:狀態管理
Web worker poll request