Redis.config详解

Redis.config详解

学习redis的配置文件

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

Redis.config详解_第1张图片

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

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

Redis.config详解_第2张图片

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

Redis.config详解_第3张图片

GENERAL(统用的配置信息)

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

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

Redis.config详解_第4张图片

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

连接客户端的最大限制

你可能感兴趣的:(java,redis,linux)