1.(在哪)小技巧 : 不要去修改出厂设置配置文件 , 拷贝文件进行修改(并不能保证一次修改正确)
2,Units单位
配置大小单位,开头定义一些基本的度量单位,只支持bytes,不支持bit
对大小写不敏感
3.includes包含
4.General通用
4.1 出厂默认设置 (
daemonize no) 修改为yes
4.2 pidfile 进程存放目录
4.3 Port(端口号) 6379
4.4 tcp-backlog 511
4.5(IP地址绑定)bind 192.168.1.100 10.0.0.1
bind 127.0.0.1
4.6 # Close the connection after a client is idle for N seconds (0 to disable)
timeout 0
4.7 tcp-keepalive 0 (多台Redis集群配置)
4.8 LogLevel (日志级别)
# 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
4.9 Logfile (日志名字) logfile ""
4.10 Syslog-enabled(是否把日志输出到syslog中)
(默认) syslog-enabled no
(指定syslog里的日志标志) syslog-ident redis
4.11 Syslog-facility(输出日志的设备) 指定syslog设置,值可以是user或local0-local7
syslog-facility local0
4.12 Databases databases 16
5.1Save Save 秒钟 写操作次数
save on disk (保存在磁盘中)
900 (s 15分钟)
save 900 1
save 300 10 (规定范围内改动次数,5分钟修改10次生成dump.rdb)
save 60 10000
Rdb是整个内存的压缩过的Snapshot,RDB的数据结构,可以配置复合的快照触发条件
默认:1分钟内改了1万次或5分钟10次,15分钟1次
5.2 生产机器和备份机器是不同机器
5.3 # The filename where to dump the DB
dbfilename dump.rdb
6.replication复制
访问
7.security安全 /SECURITY
7.1 访问密码的查看、设置和取消 (默认为null)
7.2 设置密码 config set requirepass ‘123456'
7.3 查看密码 config get requirepass
7.4 进入密码 auth 123456
8.limits限制
8.1 Maxclients (最大连接数)
maxclients 10000
8.2 Maxmemory (最大内存存储空间)
512M
8.3 Maxmemory-policy (最大内存策略)
# volatile-lru(最近最少使用) -> remove the key with an expire set using an LRU algorithm
# allkeys-lru -> remove any key according to the LRU algorithm
# volatile-random (随机)-> remove a random key with an expire set
# allkeys-random -> remove a random key, any key
# volatile-ttl (有限时间内)-> remove the key with the nearest expire time (minor TTL)
# noeviction(永不过期) -> don't expire at all, just return an error on write operations