首页 > 其他 > 详细

Redis 配置

时间:2021-03-29 20:37:54      阅读:33      评论:0      收藏:0      [点我收藏+]

6379

6379是手机按键上MERZ对应的号码
MERZ取自意大利歌女Alessia Merz的名字bind 0.0.0.0 监听地址,多个地址用空格隔开
protected-mode yes 在没有设置bind id和密码的时候,仅允许127.0.0.1 6379 连接
port 6379 默认6379/tcp
timeout 0 客户端和redis服务端超时时间,默认0,永不超时
tcp-keepalive 300 tcp会话保持300s
daemonize no 是否作为守护进程
pidfile
loglevel notice 日志级别
logfile
database 16  0-15


always-show-logo yes 在启动时是否显示或在日志中记录redis logo
save 900 1 在900s内有1个key内容发生变化,就执行快照机制
save 300 10
save 60 10000

stop-write-on-bgsave-errors yes 默认yes时,因为空间满等原因快照无法保存出错时,会禁止redis写入报错,生产环境建议no

rdbcompression yes 持久化到RDB文件时,是否压缩
rdbchecksum yes 是否对备份文件开启RC64检验,默认开启
dbfilename dump.rdb

dir ./ 快照文件保存路径 

###########################
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
# 1gb => 1024*1024*1024 bytes
解释:rdis存储数据的计量单位

设置redis连接密码

redis-cli -h hostname/ip -p port -a password
localhost:6379> config set requirepass 123456
OK
localhost:6379> config get requirepass
(error) NOAUTH Authentication required.
localhost:6379> auth 123456
OK
localhost:6379> config get requirepass
1) "requirepass"
2) "123456"
~]# vim /etc/redis/6379.conf 
requirepass 123456

需要重启redis服务
[root@centos7-1 html]# redis-cli
127.0.0.1:6379> ping
(error) NOAUTH Authentication required.
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

获取当前配置

127.0.0.1:6379> config get *
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) "123456"
  5) "masterauth"
  6) ""
  7) "unixsocket"
  8) ""
  9) "logfile"
 10) "/var/log/redis/redis.log"
 11) "pidfile"
 12) "/var/run/redis_6379.pid"
 13) "slave-announce-ip"
 14) ""
 15) "maxmemory"
 16) "0"
 17) "maxmemory-samples"
 18) "5"
 19) "timeout"
 20) "0"
 21) "auto-aof-rewrite-percentage"
 22) "100"
 23) "auto-aof-rewrite-min-size"
 24) "67108864"
 25) "hash-max-ziplist-entries"
 26) "512"
 27) "hash-max-ziplist-value"
 28) "64"
 29) "list-max-ziplist-size"
 30) "-2"
 31) "list-compress-depth"
 32) "0"
 33) "set-max-intset-entries"
 34) "512"
 35) "zset-max-ziplist-entries"
 36) "128"
 37) "zset-max-ziplist-value"
 38) "64"
 39) "hll-sparse-max-bytes"
 40) "3000"
 41) "lua-time-limit"
 42) "5000"
 43) "slowlog-log-slower-than"
 44) "10000"
 45) "latency-monitor-threshold"
 46) "0"
 47) "slowlog-max-len"
 48) "128"
 49) "port"
 50) "6379"
 51) "tcp-backlog"
 52) "511"
 53) "databases"
 54) "16"
 55) "repl-ping-slave-period"
 56) "10"
 57) "repl-timeout"
 58) "60"
 59) "repl-backlog-size"
 60) "1048576"
 61) "repl-backlog-ttl"
 62) "3600"
 63) "maxclients"
 64) "10000"
 65) "watchdog-period"
 66) "0"
 67) "slave-priority"
 68) "100"
 69) "slave-announce-port"
 70) "0"
 71) "min-slaves-to-write"
 72) "0"
 73) "min-slaves-max-lag"
 74) "10"
 75) "hz"
 76) "10"
 77) "cluster-node-timeout"
 78) "15000"
 79) "cluster-migration-barrier"
 80) "1"
 81) "cluster-slave-validity-factor"
 82) "10"
 83) "repl-diskless-sync-delay"
 84) "5"
 85) "tcp-keepalive"
 86) "300"
 87) "cluster-require-full-coverage"
 88) "yes"
 89) "no-appendfsync-on-rewrite"
 90) "no"
 91) "slave-serve-stale-data"
 92) "yes"
 93) "slave-read-only"
 94) "yes"
 95) "stop-writes-on-bgsave-error"
 96) "yes"
 97) "daemonize"
 98) "no"
 99) "rdbcompression"
100) "yes"
101) "rdbchecksum"
102) "yes"
103) "activerehashing"
104) "yes"
105) "protected-mode"
106) "yes"
107) "repl-disable-tcp-nodelay"
108) "no"
109) "repl-diskless-sync"
110) "no"
111) "aof-rewrite-incremental-fsync"
112) "yes"
113) "aof-load-truncated"
114) "yes"
115) "maxmemory-policy"
116) "noeviction"
117) "loglevel"
118) "notice"
119) "supervised"
120) "systemd"
121) "appendfsync"
122) "everysec"
123) "syslog-facility"
124) "local0"
125) "appendonly"
126) "no"
127) "dir"
128) "/var/lib/redis"
129) "save"
130) "900 1 300 10 60 10000"
131) "client-output-buffer-limit"
132) "normal 0 0 0 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
133) "unixsocketperm"
134) "0"
135) "slaveof"
136) ""
137) "notify-keyspace-events"
138) ""
139) "bind"
140) "127.0.0.1"

Redis 常用命令

info 显示当前阶段redis运行状态信息
select 切换数据库
keys 查看当前库所有keys
bgsave 手动在后台执行RDB持久化操作
dbsize 分为交互和非交互执行
##################
bgsave
redis-cli -a ‘123456‘ bgsave
##################

dbsize 返回当前库下的所有key数量
flushdb 强制清空当前库中的所有key,慎用
flushall
强制清空所有数据库中的所有key,慎用
shutdown (建议了解其运行过程)
会保证服务器正常关闭而不丢失任何数据

 

Redis 配置

原文:https://www.cnblogs.com/huakai201/p/14593595.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!