注:ip为安装redis的那台服务器(集群中的其中一台)的ip,password为redis的密码
1. 集群相关信息查看
1.集群状态 redis-cli -h ip -p 6401 -a password cluster info
2.集群节点信息 redis-cli -h ip -p 6401 -a password cluster nodes
3.节点内存、cpu、key数量等信息(每个节点都需查看) redis-cli -h ip -p 6401 -a password info
4.从redis集群中查看key(只需要连接master节点查看) a.查看该节点的所有key redis-cli -h ip -p 6401 -a password keys *
b.查看key的value值 redis-cli -h ip -p 6401 -a password -c get key
c.查看key值得有效期 redis-cli -h ip -p 6401 -a password -c ttl key
2.查看 redis 中存的数据
1.ssh root@ip 2.Password: password 3.keys * 4.查看存储的数据剩余过期时间 ttl key
4.查看key的类型(string,set,list,hash) type key
5.查看key的值(string类型) get key
6.查看key的值(set类型) scard key //获取 set 集合中元素的数量 smembers key //查看 set 中的内容
7.查看key的值(hash类型) hlen key //获取 key 键的字段数量 hgetall key //返回 key 键的所有字段及其值 hkeys key //获取 key 键中所有字段的名字 hvals key //获取 key 键中所有字段的值