redis6.0.5安装部署linux,Linux(Centos7)Redis-6.0.5配置文件介绍

启动---redis启动就是通过配置文件来启动的

./redis-server /path/to/redis.conf

单位---对大小写不敏感

# 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.

包含---就是说可以把多个redis的配置文件包含进来

################################## 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 /path/to/other.conf

网络

bind 127.0.0.1 # 绑定的ip, 如果需要支持远程访问 ip改成* 或者 注释掉这行代码

protected-mode yes # 保护模式

port 6379 #端口设置

通用

daemonize yes # 以守护进程(后台)的方式运行默认为:no, 我们需要手动设置成: yes

supervised no #去管理守护进行的默认为: no ,一般我们不用动

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,默认为yes

快照

# 在规定的时间内,执行了多少次操作,则会把数据持久化到.rdb或者.aof文件内

# redis是内存数据库,如果没有持久化,断电及失

# 持久化规则

# 如果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文件的保存目录

安全

#可以在这里设置密码,redis默认是没有密码的

127.0.0.1:6379> ping

PONG

127.0.0.1:6379> config get requirepass #查询密码

1) "requirepass"

2) ""

127.0.0.1:6379> config set requirepass "123456" #设置密码

OK

127.0.0.1:6379> config get requirepass

1) "requirepass"

2) "123456"

127.0.0.1:6379> exit #退出客户端

[root@Louis bin]# ./redis-cli # 登录客户端

127.0.0.1:6379> ping # 直接ping 报错 需要认证

(error) NOAUTH Authentication required

127.0.0.1:6379> auth 123456 # 密码认证

OK

127.0.0.1:6379> ping

PONG

限制CLIENTS(客户端限制)

maxclients 10000 # 设置能连接redis服务的客户端最大数量

maxmemory # 配置最大的内存容量

maxmemory-policy noeviction # 内存达到上限后的处理策略

**1、volatile-lru:**只对设置了过期时间的key进行LRU(默认值)

**2、allkeys-lru :** 删除lru算法的key

**3、volatile-random:**随机删除即将过期key

**4、allkeys-random:**随机删除

**5、volatile-ttl :** 删除即将过期的

**6、noeviction : **永不过期,返回错误

APPEND ONLY 模式 aof配置

appendonly no # 默认不开启aof模式,默认是使用rdb持久化的,大部分情况下rdb够用

appendfilename "appendonly.aof" # 持久化的文件的名称

appendfsync always # 每次修改都会同步 sync

appendfsync everysec # 每秒执行1次 sync,可能会丢失这1s的数据(默认使用)

appendfsync no # 不执行 sync

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值