layout: post
title: Redis系统配置和系统命令
date: 2018-03-22
tags: [“Redis”,”软件服务”]
一、基本配置
1、Generic Configuration
- daemonize 启用后台守护进程
- supervised 是否由upstart或systemd监管
- loglevel 日志级别
- pidfile pidfile path
- logfile logfile path
- databases set count of databases ,by default is 16
2、Network Configuration
- bind IP bind ip address ,which can remote the redis server
- port PORT listen to zhe port
- protected-mode 默认为"yes"状态,那么"bind" 和 "requirepass"必须至少符合一个条件,才允许该client访问
- tcp-backlog tcp请求后援队列长度
- unixsocket The socket path
- timeout 连接的空闲超时时长
3、Security configuration management
- requirepass
设置访问密码 rename-command 为command重命名,在AOF或Replication环境中,不推荐使用;
4、Resource use restrictions
- maxclients 客户端最大连接数
- maxmemory
最大可用内存数 maxmemory-policy noeviction 淘汰策略: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 maxmemory-samples 5 淘汰算法运行时的采样样本数,如果你将maxmemory-sample设置为10,那么Redis将会增加额外的CPU开销以保证接近真正的LRU性能 hz 10 默认为10,即回收的频率,值越高,回收频率越高,CPU开销越大
5、SlowLog Configuration
- slowlog-log-slower-than 10000 单位是微秒;
- slowlog-max-len 128 SlowLog记录的日志最大条目;
6、Advanced Configuration
- hash-max-ziplist-entries 512 hash类型的value最大为512字节
- hash-max-ziplist-value 64 hash类型的单个value 最大为64个字节
- 设置ziplist的键数量最大值,每个值的最大空间
- #Client buffer can be keeped initially
- client-output-buffer-limit normal 0 0 0
- client-output-buffer-limit slave 256mb 64mb 60
- client-output-buffer-limit pubsub 32mb 8mb 60
- value hard-limit soft-limit limit-second(软限制的宽容期)
二、系统命令
1、连接命令
- redis-cli命令:
- Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
- -h HOST, 127.0.0.1
- -p PORT, 6379/tcp
- -a PASSWORD
- -n DBID #0-15
2、Connection相关命令
- help @connection #@group 查看命令组
- AUTH
ECHO PING QUIT SELECT dbid SHUTDOWN [NOSAVE'SAVE] #保存或不保存数据
3、清空数据库
- FLUSHDB:Remove all keys from the current database 清空当前数据库;
- FLUSHALL:Remove all keys from all databases 清空所有数据库;
4、Server相关的Client命令
- CLIENT GETNAME
- *CLIENT KILL
- CLIENT KILL [ip:port] [ID client-id] [TYPE normal'master'slave'pubsub] [ADDR ip:port] [SKIPME yes/no]
- *CLIENT LIST
- CLIENT PAUSE
- CLIENT PAUSE timeout
- CLIENT REPLY
- CLIENT SETNAME:Set the current connection name
5、配置参数(运行中)
- CONFIG GET
- CONFIG RESETSTAT
- CONFIG REWRITE
- CONFIG SET
文档更新时间: 2018-12-20 15:19 作者:张尚