Redis简介
Redis是流行的开源NoSQL数据库,所有数据加载到内存提供高性能读写请求,并且实现丰富的数据结构。
安装Redis的方法很简单,Ubuntu/Debian系统通过apt-get install redis-server安装,CentOS系统通过yum install redis安装,Linux操作系统还可以通过docker run -d -p 6379:6379 redis来运行。
Redis配置
Redis的配置文件在/etc/redis/redis.conf,例如下面的基本配置。
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 2147483648
loglevel notice
repl-diskless-sync no
repl-diskless-sync-delay 5
配置限制
Redis的配置项有的取值是数字,有的是字符串,而且数字是有大小限制的,一旦使用了超过long型的配置会导致Redis起不来。某颜色云公司的缓存服务由于没有对用户配置组做限制,一旦你使用了超大数字的配置会导致服务起不来,但界面仍显示“活跃”(Bug至今未修复)。
至于Redis配置的取值范围,官网和社区文档都没有记录,我们通过“亲身经验”来测试得到了下面的配置限制。
{"configuration-parameters":[
{
"name": "timeout",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "tcp-keepalive",
"restart_required": false,
"max": 2147483647,
"min": 0,
"type": "integer"
},
{
"name": "repl-diskless-sync-delay",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "repl-ping-slave-period",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "repl-timeout",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "repl-backlog-ttl",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "slave-priority",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "min-slaves-max-lag",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "maxclients",
"restart_required": false,
"max": 10000,
"min": 0,
"type": "integer"
},
{
"name": "maxmemory",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "auto-aof-rewrite-percentage",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "lua-time-limit",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "slowlog-log-slower-than",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "slowlog-max-len",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "latency-monitor-threshold",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "hash-max-ziplist-entries",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "hash-max-ziplist-value",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "list-max-ziplist-entries",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "list-max-ziplist-value",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"max": 9223372036854775807,"name": "set-max-intset-entries",
"min": 0,
"type": "integer"
},
{
"name": "zset-max-ziplist-entries",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "zset-max-ziplist-value",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "hll-sparse-max-bytes",
"restart_required": false,
"max": 15000,
"min": 0,
"type": "integer"
},
{
"name": "hz",
"restart_required": false,
"max": 500,
"min": 1,
"type": "integer"
}]
}
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "zset-max-ziplist-entries",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "zset-max-ziplist-value",
"restart_required": false,
"max": 9223372036854775807,
"min": 0,
"type": "integer"
},
{
"name": "hll-sparse-max-bytes",
"restart_required": false,
"max": 15000,
"min": 0,
"type": "integer"
},
{
"name": "hz",
"restart_required": false,
"max": 500,
"min": 1,
"type": "integer"
}]
}
更好的缓存服务
当然我们不是很无聊就为了写个JSON文件,这是OpenStack Trove的配置文件,我们基于这个文件规范用户可以修改的Redis配置项。
是为了做更好的缓存服务!!
网友评论