[Redis]Redis指南二 配置

本文涉及的产品
云数据库 Redis 版,标准版 2GB
推荐场景:
搭建游戏排行榜
云原生内存数据库 Tair,内存型 2GB
简介: 版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SunnyYoona/article/details/73863746 我们可以...
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/SunnyYoona/article/details/73863746

我们可以通过redis-server的启动参数port设置了Redis的端口号,除此之外Redis还支持其他配置选项,如是否开启持久化,日志级别等.由于可以配置的选项较多,通过启动参数设置这些选项并不方便,所以Redis支持通过配置文件来设置这些选项.启动配置文件的方法在启动时将配置文件的路径作为启动参数传递给redis-server:

redis-server /path/to/redis.conf

通过启动参数传递同名的配置选项会覆盖配置文件中相应的参数:

redis-srver /path/to/redis.conf --loglevel warning

Redis提供了一个配置文件的模板redis.conf ,位于源代码目录的根目录中.

除此之外还可以在Redis运行时通过CONFIG SET命令在不重新启动Redis的情况下动态修改部分Redis配置:

redis> CONFIG SET loglevel warning 
ok

并不是所有的配置都可以使用CONFIG SET命令修改,我们可以使用CONFIG GET命令获得Redis当前配置情况,例如:

127.0.0.1:6379> CONFIG GET loglevel
1) "loglevel"
2) "notice"

下面列出了哪些配置能够使用命令修改:

xiaosi@yoona:~$ redis-cli
127.0.0.1:6379>  CONFIG GET *
  1) "dbfilename"
  2) "dump.rdb"
  3) "requirepass"
  4) ""
  5) "masterauth"
  6) ""
  7) "unixsocket"
  8) ""
  9) "logfile"
 10) ""
 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) "yes"
 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) "no"
121) "appendfsync"
122) "everysec"
123) "syslog-facility"
124) "local0"
125) "appendonly"
126) "no"
127) "dir"
128) "/var/redis/6379"
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实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
17天前
|
NoSQL Redis 容器
【Azure Cache for Redis】Redis的导出页面无法配置Storage SAS时通过az cli来完成
【Azure Cache for Redis】Redis的导出页面无法配置Storage SAS时通过az cli来完成
|
18天前
|
缓存 NoSQL 测试技术
【Azure Redis 缓存】Azure Redis 功能性讨论三: 调优参数配置
【Azure Redis 缓存】Azure Redis 功能性讨论三: 调优参数配置
|
18天前
|
存储 缓存 NoSQL
【Azure Redis 缓存】由Azure Redis是否可以自定义密码而引申出Azure PaaS的Redis服务是否可以和自建的Redis进行主从配置呢?
【Azure Redis 缓存】由Azure Redis是否可以自定义密码而引申出Azure PaaS的Redis服务是否可以和自建的Redis进行主从配置呢?
|
18天前
|
缓存 NoSQL 网络协议
【Azure Redis 缓存】如何使得Azure Redis可以仅从内网访问? Config 及 Timeout参数配置
【Azure Redis 缓存】如何使得Azure Redis可以仅从内网访问? Config 及 Timeout参数配置
|
2月前
|
NoSQL Redis 数据安全/隐私保护
Redis主从配置
Redis主从配置
41 5
|
2月前
|
NoSQL Redis
Redis 主从复制架构配置及原理
Redis 主从复制架构配置及原理
43 5
|
20天前
|
缓存 NoSQL 网络协议
【Azure Redis 缓存 Azure Cache For Redis】在创建高级层Redis(P1)集成虚拟网络(VNET)后,如何测试VNET中资源如何成功访问及配置白名单的效果
【Azure Redis 缓存 Azure Cache For Redis】在创建高级层Redis(P1)集成虚拟网络(VNET)后,如何测试VNET中资源如何成功访问及配置白名单的效果
|
2月前
|
NoSQL Redis 数据库
redis 持久化机制及配置
redis 持久化机制及配置
61 4
|
2月前
|
NoSQL Redis
Redis性能优化问题之根据 Redis 的 AOF 配置级别优化性能,如何解决
Redis性能优化问题之根据 Redis 的 AOF 配置级别优化性能,如何解决
|
2月前
|
NoSQL Redis
Redis性能优化问题之为什么配置为 appendfsync everysec 的 AOF 也可能导致 Redis 延迟变大
Redis性能优化问题之为什么配置为 appendfsync everysec 的 AOF 也可能导致 Redis 延迟变大