用户工具

站点工具


linux:redis

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

后一修订版
前一修订版
linux:redis [2017/12/11 15:52] – 创建 memorylinux:redis [2023/12/03 10:24] (当前版本) – 外部编辑 127.0.0.1
行 40: 行 40:
 ===== 安全 ===== ===== 安全 =====
  
 +  - 不要暴露 redis 到公网(bind 内网 ip)正确配置 iptables 
 +  - 设置密码 ''requirepass <password>'' 
 +  - 禁用/重命名危险命令:''rename-command CONFIG ""'' 
 +  - Redis Cluster 配置:所有 slaver 节点加上 masterauth;由于 sentinel 会自动选举出新的 master 节点,因此要在所有 redis 集群节点的配置都加上 requirepass 
 +  - Redis sentinel 配置:''sentinel auth-pass <master-group-name> <pass>''
  
 ===== 常用操作 ===== ===== 常用操作 =====
 +
 +查看集群相关信息
 +
 +  info replication
 +
 +删除根据key的前缀删除
 +
 +  EVAL "return redis.call('del', unpack(redis.call('keys', ARGV[1])))" 0 prefix:*
 +
 +==== Export && Import ====
 +
 +Export redis data on ''server1'' and import it on ''server2''.
 +
 +On server1:
 +
 +<code bash>
 +# make a snapshot
 +redis-cli 'save'
 +scp /var/lib/redis/dump.rds server2:/tmp/dump.rds
 +</code>
 +
 +On server2:
 +
 +<code bash>
 +# Stop redis
 +systemctl stop redis
 +chown redis:redis /tmp/dump.rds
 +cp /tmp/dump.rds /var/lib/redis/dump.rds
 +# make sure /etc/redis.conf `appendonly no`
 +systemctl start redis
 +# finish
 +</code>
  
 ===== Reference ===== ===== Reference =====
行 48: 行 84:
   * [[https://redis.io/topics/sentinel|Redis Sentinel Documentation]]   * [[https://redis.io/topics/sentinel|Redis Sentinel Documentation]]
   * [[https://redis.io/topics/security|Redis Security]]   * [[https://redis.io/topics/security|Redis Security]]
 +  * [[https://gnuhpc.gitbooks.io/redis-all-about|Redis开发运维实践指南]]
linux/redis.1512978758.txt.gz · 最后更改: 2023/12/03 10:24 (外部编辑)