layout: post
title: Redis系统配置和系统命令
date: 2018-03-22
tags: [“Redis”,”软件服务”]


一、基本配置

1、Generic Configuration

  1. daemonize 启用后台守护进程
  2. supervised 是否由upstartsystemd监管
  3. loglevel 日志级别
  4. pidfile pidfile path
  5. logfile logfile path
  6. databases set count of databases by default is 16

2、Network Configuration

  1. bind IP bind ip address which can remote the redis server
  2. port PORT listen to zhe port
  3. protected-mode 默认为"yes"状态,那么"bind" "requirepass"必须至少符合一个条件,才允许该client访问
  4. tcp-backlog tcp请求后援队列长度
  5. unixsocket The socket path
  6. timeout 连接的空闲超时时长

3、Security configuration management

  1. requirepass 设置访问密码
  2. rename-command command重命名,在AOFReplication环境中,不推荐使用;

4、Resource use restrictions

  1. maxclients 客户端最大连接数
  2. maxmemory 最大可用内存数
  3. maxmemory-policy noeviction
  4. 淘汰策略:volatile-lru remove the key with an expire set using an LRU algorithm
  5. allkeys-lru remove any key according to the LRU algorithm
  6. volatile-random remove a random key with an expire set
  7. allkeys-random remove a random key, any key
  8. volatile-ttl remove the key with the nearest expire time (minor TTL)
  9. noeviction don't expire at all, just return an error on write operations
  10. maxmemory-samples 5 淘汰算法运行时的采样样本数,如果你将maxmemory-sample设置为10,那么Redis将会增加额外的CPU开销以保证接近真正的LRU性能
  11. hz 10 默认为10,即回收的频率,值越高,回收频率越高,CPU开销越大

5、SlowLog Configuration

  1. slowlog-log-slower-than 10000 单位是微秒;
  2. slowlog-max-len 128 SlowLog记录的日志最大条目;

6、Advanced Configuration

  1. hash-max-ziplist-entries 512 hash类型的value最大为512字节
  2. hash-max-ziplist-value 64 hash类型的单个value 最大为64个字节
  3. 设置ziplist的键数量最大值,每个值的最大空间
  4.  
  5. #Client buffer can be keeped initially
  6. client-output-buffer-limit normal 0 0 0
  7. client-output-buffer-limit slave 256mb 64mb 60
  8. client-output-buffer-limit pubsub 32mb 8mb 60
  9. value hard-limit soft-limit limit-second(软限制的宽容期)

二、系统命令

1、连接命令

  1. redis-cli命令:
  2. Usage: redis-cli [OPTIONS] [cmd [arg [arg ...]]]
  3. -h HOST, 127.0.0.1
  4. -p PORT, 6379/tcp
  5. -a PASSWORD
  6. -n DBID #0-15

2、Connection相关命令

  1. help @connection #@group 查看命令组
  2. AUTH
  3. ECHO
  4. PING
  5. QUIT
  6. SELECT dbid
  7. SHUTDOWN [NOSAVE'SAVE] #保存或不保存数据

3、清空数据库

  1. FLUSHDBRemove all keys from the current database 清空当前数据库;
  2. FLUSHALLRemove all keys from all databases 清空所有数据库;

4、Server相关的Client命令

  1. CLIENT GETNAME
  2. *CLIENT KILL
  3. CLIENT KILL [ip:port] [ID client-id] [TYPE normal'master'slave'pubsub] [ADDR ip:port] [SKIPME yes/no]
  4. *CLIENT LIST
  5. CLIENT PAUSE
  6. CLIENT PAUSE timeout
  7. CLIENT REPLY
  8. CLIENT SETNAME:Set the current connection name

5、配置参数(运行中)

  1. CONFIG GET
  2. CONFIG RESETSTAT
  3. CONFIG REWRITE
  4. CONFIG SET

 

 

文档更新时间: 2018-12-20 15:19   作者:张尚