当前位置:网站首页>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 # 数据不同步,每秒记录一次
边栏推荐
- MIPS assembly language learning-01-sum of two numbers, environment configuration and how to run
- Ros21 lecture
- web Worker 轮询请求
- 分布式理论须知
- ROS knowledge points - definition and use of topic messages
- What! 一条命令搞定监控?
- MIPS汇编语言学习-01-两数求和以及环境配置、如何运行
- ROS knowledge points - ROS create workspace
- Facebook出手!自适应梯度打败人工调参
- Summary of language features of fluent dart
猜你喜欢
C语言基础语法
MIPS汇编语言学习-02-逻辑判断-前台输入
The Web3.0 era is coming. See how Tianyi cloud storage resources invigorate the system to enable new infrastructure (Part 1)
Technical secrets of ByteDance data platform: implementation and optimization of complex query based on Clickhouse
No win32/com in vs2013 help document
Facebook! Adaptive gradient defeats manual parameter adjustment
信创操作系统--麒麟Kylin桌面操作系统 (项目十 安全中心)
【LeetCode】13、罗马数字转整数
Opengauss kernel: analysis of SQL parsing process
Qt create 5.0.3 配置Qt4.8.7
随机推荐
C语言学习-19-全排列
NAACL 2022 | 机器翻译SOTA模型的蒸馏
Talking about open source - Linus and Jim talk about open source in China
如何从零搭建10万级 QPS 大流量、高并发优惠券系统
Installation and use of Jenkins
字节跳动数据平台技术揭秘:基于 ClickHouse 的复杂查询实现与优化
Openharmony - detailed source code of Kernel Object Events
关于针对tron API签名广播时使用curl的json解析问题解决方案及针对json.loads方法的问题记录
Analysis of PostgreSQL storage structure
GBASE南大通用亮相第六届世界智能大会
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?
分布式 CAP 定理的前世今生
扩充C盘(将D盘的内存分给C盘)
New offline retail stores take off against the trend, and consumption enthusiasm under the dark cloud of inflation
国债与定期存款哪个更安全 两者之间有何区别
What! One command to get the surveillance?
Leetcode 48. Rotate image (yes, resolved)
Validate palindrome string
SAP MTS/ATO/MTO/ETO专题之九:M+M模式前后台操作,策略用50,提前准备原材料和半成品
Oracle11g数据库使用expdp每周进行数据备份并上传到备份服务器