深圳网站制作联系电话,济南网站排名公司,做网站没有手机端,公司网页介绍Redis.conf
Redis.conf是Redis的配置文件#xff0c;它包含了一系列用于配置Redis服务器行为和功能的选项。
以下是Redis.conf中常见的一些选项配置#xff1a; bind: 指定Redis服务器监听的IP地址#xff0c;默认为127.0.0.1#xff0c;表示只能本地访问#xff0c;可以…Redis.conf
Redis.conf是Redis的配置文件它包含了一系列用于配置Redis服务器行为和功能的选项。
以下是Redis.conf中常见的一些选项配置 bind: 指定Redis服务器监听的IP地址默认为127.0.0.1表示只能本地访问可以改为0.0.0.0以允许来自任意IP地址的访问。 port: 指定Redis服务器监听的端口号默认为6379。 timeout: 指定客户端连接到Redis服务器的超时时间默认为0表示无限制。 requirepass: 设置连接Redis服务器所需的密码默认为空即不需要密码。 databases: 指定Redis服务器中可以创建的数据库数量默认为16个。 maxclients: 指定Redis服务器同时连接的最大客户端数量默认为10000个。 maxmemory: 指定Redis服务器可以使用的最大内存数量默认为0表示不限制。 logfile: 指定Redis服务器的日志文件路径默认为空即不输出日志。 save: 指定Redis服务器进行持久化的条件默认为三个条件都满足时进行持久化900秒内进行了1次写操作、300秒内进行了10次写操作、60秒内进行了10000次写操作。 rdbcompression: 指定Redis服务器在进行RDB持久化时是否压缩数据默认为yes。 appendonly: 指定是否开启AOF持久化默认为no可以改为yes。 appendfsync: 指定AOF持久化的方式默认为everysec表示每秒钟同步一次。 requirepass: 指定连接Redis服务器所需的密码默认为空表示不需要密码。
这些只是Redis.conf中的一部分选项实际上还有很多其他选项可以进行配置。通过修改Redis.conf可以根据实际需求对Redis服务器进行定制化的配置。 1.容量单位不区分大小写G和GB有区别 2.可以使用 include 组合多个配置问题 3.网络配置 #ip绑定
bind 127.0.0.1
# Protected mode is a layer of security protection, in order to avoid that# Redis instances left open on the internet are accessed and exploited.
# When protected mode is on and if:
# 1) The server is not binding explicitly to a set of addresses using thebind directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the# IPv4 and IPv6 loopback addresses 127.0,0,1 and ::1,and from Unix domain
# sockets.
# By default protected mode is enabled. You should disable it only if# you are sure you want clients from other hosts to connect to Redis# even if no authentication is configured, nor a specific set of interfaces# are explicitly listed using thebind directive.
#保护模式 默认开启
protected-mode yes
# Accept connections on the specified port,default is 6379 (IANA #815344)# If port isspecified Redis will not listen on a TCP socket.
#端口
port 63794.日志输出级别 daemonize yes #以守护进程的方式运行默认是 no我们需要自己开启为yes!
pidfile /var/run/redis_6379.pid # 如果以后台的方式运行我们就需要指定一个 pid 文件!
# 日志
# Specify the server verbosity Teve1
# 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日志输出文件 logleve1 notice
logfile“” # 日志的文件位置名
databases 16 # 数据库的数量默认是 16 个数据库
always-show-logo yes # 是否总是显示LOGO6.持久化规则 (RDB) 由于Redis是基于内存的数据库需要将数据由内存持久化到文件中
AOF
#持久化规则持久化到文件 .rdb .aof
# 如果了900秒内 至少1个key进行了修改就进行持久化
save 900 1
#300秒内 10个key进行了修改
save 300 10
save 60 10000RDB文件相关
#持久化错误是否继续工作
stop-writes-on-bgsave-error yes
#Compress string objects using LZF when dump .rdb databases?
#For default thats set to yes as its 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文件
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 files created with checksum disabled have a checksum of zero that will
#tell the Loading code to skip the check.
#校验校rdb文件
rdbchecksum yes
#The filename where to dump the DB
dbfilename dump.rdb# 如果900s内如果至少有一个1 key进行了修改我们及进行持久化操作
save 900 1
# 如果300s内如果至少10 key进行了修改我们及进行持久化操作
save 300 10
# 如果60s内如果至少10000 key进行了修改我们及进行持久化操作
save 60 10000
# 我们之后学习持久化会自己定义这个测试!
# 持久化如果出错是否还需要继续工作!
stop-writes-on-bgsave-error yes
rdbcompression yes #是否压缩 rdb 文件需要消耗一些cpu资源!
rdbchecksum yes #保存rdb文件的时候进行错误的检查校验!
dir ./ #rdb 文件保存的目录!7.主从复制 replication 8.Security模块中进行密码设置 9.客户端连接相关 maxclients 10000 #设置能连接上redis的最大客户端的数量
maxmemory bytes # redis 配置最大的内存容量
maxmemory-policy noeviction # 内存到达上限之后的处理策略
1、volatile-lru: 只对设置了过期时间的key进行LRu(默认值)
2、allkeys-lru: 删除lru算法的key
3、volatile-random: 随机删除即将过期key
4、allkeys-random: 随机删除
5、volatile-tt1 :删除即将过期的
6、noeviction : 永不过期返回错误maxclients 10000 最大客户端数量
maxmemory bytes 最大内存限制
maxmemory-policy noeviction # 内存达到限制值的处理策略redis 中的默认的过期策略是 volatile-lru 。
设置方式
config set maxmemory-policy volatile-lru 10.AOF相关部分 appendonly no # 默认是不开启aof模式的默认是使用rdb方式持久化的在大部分所有的情况下rdb完全够用!
appendfilename appendonly.aof # 持久化的文件的名字
#appendfsync always # 每次修改都会 sync。消耗性能
appendfsync everysec # 每秒执行一次 sync可能会丢失这1s的数据!
# appendfsync no # 不执行 sync这个时候操作系统自己同步数据速度最快!appendonly no # 默认不开启 aof 使用rdb持久化
# The name of the append only file (default: appendonty.aof)
appendfilenameappendonly.aof# appendfsync always 每次修改进行同步
appendfsync everysec # 每秒执行一次同步
# appendfsync no 不进行同步 由操作系统进行同步 速度最快Redis-浅谈redis.conf配置文件 到此完结笔者归纳、创作不易大佬们给个3连再起飞吧