二、Redis配置文件解析

配置文件解析
/etc/redis/6379.conf 修改端口和ip后连接需加端口、ip参数才能连接;停止用shutdown停止服务
计量单位
# 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.
常用配置选项
port 6379 // 端口
bind 127.0.0.1 //IP 地址
tcp-backlog 511 //tcp 连接总数
timeout 0 // 连接超时时间
tcp-keepalive 300 // 长连接时间
daemonize yes // 守护进程方式运行
databases 16 // 数据库个数
logfile /var/log/redis_6379.log //pid 文件
maxclients 10000 // 并发连接数量,默认10000
dir /var/lib/redis/6379 // 数据库目录
日志级别
163 # debug (a lot of information, useful for development/testing)
164 # verbose (many rarely useful info, but not a mess like the debug level)
165 # notice (moderately verbose, what you want in production probably)
166 # warning (only very important / critical messages are logged)
167 loglevel notice
187 databases 16
172 logfile /var/log/redis_6379.log
533 # maxclients 10000
264 dir /var/lib/redis/6379
# requirepass foobared 设置登陆密码 设置密码后的登陆方式AUTH <PASSWORD>
MEMORY MANAGEMENT 内存管理
560 # maxmemory <bytes> // 最大内存
内存清除策略
565 # volatile-lru -> Evict using approximated LRU among the keys with an expire set.最近最少使用 (针对设置了过期时间的key)
566 # allkeys-lru -> Evict any key using approximated LRU. 删除最少使用的key
569 # volatile-random -> Remove a random key among the ones with an expire set. 在设置了过期的key里随机移除
570 # allkeys-random -> Remove a random key, any key. 随机移除key
571 # volatile-ttl -> Remove the key with the nearest expire time (minor TTL) 移除最近过期的key
572 # noeviction -> Don't evict anything, just return an error on write operations. 不删除 写满时报错,默认
591 # maxmemory-policy noeviction 定义使用的策略
602 # maxmemory-samples 5 选取模板数据的个数 (针对lru 和 ttl 策略)

posted @ 2021-06-30 10:44  落樰兂痕  阅读(41)  评论(0编辑  收藏  举报