Redis.config详解

Redis.config详解

学习redis的配置文件

使用vim在Linux中打开配置文件

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-NcHL0CqL-1634045953649)(C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20211012205807576.png)]

容量单位不区分大小写,G和GB有区别

网络配置 包括了端口和默认保护模式

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pT5PggZV-1634045953652)(C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20211012205908332.png)]

在配置文件中可以导入其他的配置文件

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-anRrT2r9-1634045953656)(C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20211012210010761.png)]

GENERAL(统用的配置信息)

daemonize yes 以守护进程的方式进行默认为no

pidfile /var/run/redis_6379.pid 以后台的方式运行需要默认的pid

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-GebKOUAF-1634045953660)(C:\Users\Lenovo\AppData\Roaming\Typora\typora-user-images\image-20211012211650582.png)]

databases 16 数据库的数量

always-show-logo yes 是否显示logo

SNAPSHOTTING(快照)

持久化:在规定的时间内执行了多少次的操作会持久化到文件.rdb .aof

由于Redis是基于内存的数据库,需要将数据由内存持久化到文件中

save 900 1 #900秒内至少有一个key进行了修改 我们会进行持久化操作
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes #持久化出错后是否继续工作
rdbcompression yes #是否要压缩rdb文件需要消耗一些cpu的资源
rdbchecksum yes #保存时是否进行检查

主从复制相关的配置信息

################################ REPLICATION #################################

# Master-Replica replication. Use replicaof to make a Redis instance a copy of
# another Redis server. A few things to understand ASAP about Redis replication.
#
#   +------------------+      +---------------+
#   |      Master      | ---> |    Replica    |
#   | (receive writes) |      |  (exact copy) |
#   +------------------+      +---------------+
#
# 1) Redis replication is asynchronous, but you can configure a master to
#    stop accepting writes if it appears to be not connected with at least
#    a given number of replicas.
# 2) Redis replicas are able to perform a partial resynchronization with the
#    master if the replication link is lost for a relatively small amount of
#    time. You may want to configure the replication backlog size (see the next
#    sections of this file) with a sensible value depending on your needs.
# 3) Replication is automatic and does not need user intervention. After a
#    network partition replicas automatically try to reconnect to masters

redis的安全相关的配置

################################## SECURITY ###################################

# Require clients to issue AUTH <PASSWORD> before processing any other
# commands.  This might be useful in environments in which you do not trust
# others with access to the host running redis-server.
#
# This should stay commented out for backward compatibility and because most
# people do not need auth (e.g. they run their own servers).
#
# Warning: since Redis is pretty fast an outside user can try up to
# 150k passwords per second against a good box. This means that you should
# use a very strong password otherwise it will be very easy to break.
#
# requirepass foobared

# Command renaming.

redis获得和设置密码

127.0.0.1:6379> config get requirepass

  1. “requirepass”
  2. “”
    127.0.0.1:6379> config set requirepass

auth 123456 #通过该命令进行登录

客户端的一些配置的信息(对客户端进行限制)

################################### CLIENTS ####################################

# Set the max number of connected clients at the same time. By default
# this limit is set to 10000 clients, however if the Redis server is not
# able to configure the process file limit to allow for the specified limit
# the max number of allowed clients is set to the current file limit
# minus 32 (as Redis reserves a few file descriptors for internal uses).
#
# Once the limit is reached Redis will close all the new connections sending
# an error 'max number of clients reached'.
#
# maxclients 10000

连接客户端的最大限制

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

程序小旭

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值