指定集群中任意一个节点,查看集群中所有节点当前已用物理内存、配置的最大物理内存和系统物理内存。



​源码(可从https://github.com/eyjian/redis-tools下载):

#!/bin/bash
# Query the memory of all nodes in a cluster
#
# Output example:
# $ ./query_redis_cluster.sh 192.168.0.31.21:6379
# [192.168.0.31.21:6379] Used: 788.57M Max: 15.00G System: 125.56G
# [192.168.0.31.22:6380] Used: 756.98M Max: 15.00G System: 125.56G
# [192.168.0.31.23:6380] Used: 743.93M Max: 15.00G System: 125.56G
# [192.168.0.31.24:6380] Used: 21.73M Max: 15.00G System: 125.56G
# [192.168.0.31.25:6380] Used: 819.11M Max: 15.00G System: 125.56G
# [192.168.0.31.24:6379] Used: 771.70M Max: 15.00G System: 125.56G
# [192.168.0.31.26:6379] Used: 920.77M Max: 15.00G System: 125.56G
# [192.168.0.31.27:6380] Used: 889.09M Max: 15.00G System: 125.27G
# [192.168.0.31.28:6379] Used: 741.24M Max: 15.00G System: 125.56G
# [192.168.0.31.29:6380] Used: 699.55M Max: 15.00G System: 125.56G
# [192.168.0.31.27:6379] Used: 752.89M Max: 15.00G System: 125.27G
# [192.168.0.31.21:6380] Used: 716.05M Max: 15.00G System: 125.56G
# [192.168.0.31.23:6379] Used: 784.82M Max: 15.00G System: 125.56G
# [192.168.0.31.26:6380] Used: 726.40M Max: 15.00G System: 125.56G
# [192.168.0.31.25:6379] Used: 726.09M Max: 15.00G System: 125.56G
# [192.168.0.31.29:6379] Used: 844.59M Max: 15.00G System: 125.56G
# [192.168.0.31.28:6380] Used: 14.00M Max: 15.00G System: 125.56G
# [192.168.0.31.22:6379] Used: 770.13M Max: 15.00G System: 125.56G REDIS_CLI=${REDIS_CLI:-redis-cli}
REDIS_IP=${REDIS_IP:-127.0.0.1}
REDIS_PORT=${REDIS_PORT:-6379} function usage()
{
echo "Usage: `basename $0` redis_node"
echo "Example: `basename $0` 127.0.0.1:6379"
} # with a parameter: single redis node
if test $# -ne 1; then
usage
exit 1
fi eval $(echo "$1" | awk -F[\:] '{ printf("REDIS_IP=%s\nREDIS_PORT=%s\n",$1,$2) }')
if test -z "$REDIS_IP" -o -z "$REDIS_PORT"; then
echo "Parameter error"
usage
exit 1
fi # 确保redis-cli可用
which "$REDIS_CLI" > /dev/null 2>&1
if test $? -ne 0; then
echo "\`redis-cli\` not exists or not executable"
exit 1
fi redis_nodes=`redis-cli -h $REDIS_IP -p $REDIS_PORT cluster nodes | awk -F[\ \:\@] '!/ERR/{ printf("%s:%s\n",$2,$3); }'`
if test -z "$redis_nodes"; then
# standlone
$REDIS_CLI -h $REDIS_IP -p $REDIS_PORT FLUSHALL
else
# cluster
for redis_node in $redis_nodes;
do
if test ! -z "$redis_node"; then
eval $(echo "$redis_node" | awk -F[\:] '{ printf("redis_node_ip=%s\nredis_node_port=%s\n",$1,$2) }') if test ! -z "$redis_node_ip" -a ! -z "$redis_node_port"; then
items=(`$REDIS_CLI -h $redis_node_ip -p $redis_node_port INFO MEMORY 2>&1 | tr '\r' ' '`) used_memory_rss_human=0
maxmemory_human=0
total_system_memory_human=0
for item in "${items[@]}"
do
eval $(echo "$item" | awk -F[\:] '{ printf("name=%s\nvalue=%s\n",$1,$2) }') if test "$name" = "used_memory_rss_human"; then
used_memory_rss_human=$value
elif test "$name" = "maxmemory_human"; then
maxmemory_human=$value
elif test "$name" = "total_system_memory_human"; then
total_system_memory_human=$value
fi
done echo -e "[\033[1;33m${redis_node_ip}:${redis_node_port}\033[m]\tUsed: \033[0;32;32m$used_memory_rss_human\033[m\tMax: \033[0;32;32m$maxmemory_human\033[m\tSystem: \033[0;32;32m$total_system_memory_human\033[m"
fi
fi
done
fi

查看Redis集群所有节点内存工具的更多相关文章

  1. (转)高性能网站架构之缓存篇—Redis集群增删节点

    标签: 高性能架构集群缓存redis 上一篇文章,我们搭建了Redis-cluster集群,这篇博客跟大家讲一下如何在一个运行的集群上增加节点或者删除节点. Redis集群添加节点 首先我们要新建立一 ...

  2. Redis集群命令行部署工具

    使用之前准备工作: 1)配置好与端口无关的公共redis.conf文件,和工具放在同一目录下 2)配置好与端口相关的模板redis-PORT.conf文件,也和工具放在同一目录下(部署时PORT会被替 ...

  3. redis 集群新增节点,slots槽分配,删除节点, [ERR] Calling MIGRATE ERR Syntax error, try CLIENT (LIST | KILL | GET...

    redis reshard 重新分槽(slots) https://github.com/antirez/redis/issues/5029 redis 官方已确认该bug redis 集群重新(re ...

  4. 查看Redis集群主从对应关系工具

    工具的作用: 1)比"cluster nodes"更为直观的显示结果 2)指出落在同一个IP上的master 3)指出落在同一个IP上的master和slave对 运行效果图: 源 ...

  5. LINUX:关于Redis集群的节点分配

    文章来源:http://www.cnblogs.com/hello-tl/p/7808268.html 根据上述  Redis集群搭建:http://www.cnblogs.com/hello-tl/ ...

  6. Redis集群增加节点和删除节点

    本文主要是承接上一篇文章Redis集群的离线安装成功以后,我们如何进行给集群增加新的主从节点(集群扩容)以及如何从集群中删除节点(集群缩容),也就是集群的伸缩,集群伸缩的原理是控制虚拟槽和数据在节点之 ...

  7. Redis集群之节点管理

    Redis集群一旦启动,就不能轻易删除掉一个节点了. 需要由redis-trib.rg这个ruby脚本行使集群管理的功能.所有的哈希槽都分配于master节点 一.delete master node ...

  8. redis集群部署+节点端口修改+数据恢复

    环境:OS:Centos 7Redis: 3.2.11主 从192.168.1.118:7001 192.168.1.118:8001192.168.1.118:7002 192.168.1.118: ...

  9. Redis单节点数据同步到Redis集群

    一:Redis集群环境准备 1:需要先安装好Redis集群环境并配置好集群 192.168.0.113 7001-7003 192.168.0.162 7004-7006 2:检查redis集群 [r ...

随机推荐

  1. linux 文件搜索

    locate  文件名 在后台数据库中按文件名搜索,搜索速度快,不用遍历整个操作系统 /var/lib/mlocate locate 命令所搜索的后台数据库 updatedb 手动更新数据库 新建的文 ...

  2. C# 使用printDocument1.Print打印时不显示 正在打印对话框

    C#使用printDocument1.Print打印时不显示正在打印对话框有两种方法 第一种,使用PrintController       PrintController printControll ...

  3. 单细胞RNA测序技术之入门指南

    单细胞RNA测序技术之入门指南 [字体: 大 中 小 ] 时间:2018年09月12日 来源:生物通   编辑推荐: 在这个飞速发展的测序时代,DNA和RNA测序已经逐渐成为“实验室中的家常菜”.若要 ...

  4. iOS push新的调用方法

    // IOS8 新系统需要使用新的代码if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){    [[UIAppl ...

  5. Codeforces 787D. Legacy 线段树建模+最短路

    D. Legacy time limit per test:2 seconds memory limit per test:256 megabytes input:standard input out ...

  6. python 日志滚动 分文件

    import logging from logging.handlers import RotatingFileHandler import datetime import os def main() ...

  7. zookeeper和keepalived的区别

    zookeeper主要就是为了保持数据的一致性来的,举个栗子,通俗点就是 本来是存储在各个服务器上的配置文件,现在我不存储在各个服务器上了,我就把全部配置文件都存储在zookeeper服务器上,应用服 ...

  8. 使用flask-alchemy 过程中报错KeyError: 'SQLALCHEMY_TRACK_MODIFICATIONS'

    在网上找了很多, 大多数说是必须要给 SQLALCHEMY_TRACK_MODIFICATIONS 一个默认值,尝试修改alchemy 源码,,但是还是不起作用 最后阅读源码 , self.app = ...

  9. iOS11 适配

    参考:http://kisscu.com/2018/07/01/%E9%80%82%E9%85%8Dios-11%E6%80%BB%E7%BB%93/ self.navigationItem.righ ...

  10. spring学习 四 对象的创建

    spring中,有三种创建对象的方式 (1)构造创建 (2)实例工厂构造 (3)静态工厂构造 一  构造器创建 在构造器创建对象时,有无参构造和有参构造 两种 (1)在spring中,默认的是无参构造 ...