查看Redis集群所有节点内存工具
指定集群中任意一个节点,查看集群中所有节点当前已用物理内存、配置的最大物理内存和系统物理内存。
源码(可从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集群所有节点内存工具的更多相关文章
- (转)高性能网站架构之缓存篇—Redis集群增删节点
标签: 高性能架构集群缓存redis 上一篇文章,我们搭建了Redis-cluster集群,这篇博客跟大家讲一下如何在一个运行的集群上增加节点或者删除节点. Redis集群添加节点 首先我们要新建立一 ...
- Redis集群命令行部署工具
使用之前准备工作: 1)配置好与端口无关的公共redis.conf文件,和工具放在同一目录下 2)配置好与端口相关的模板redis-PORT.conf文件,也和工具放在同一目录下(部署时PORT会被替 ...
- 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 ...
- 查看Redis集群主从对应关系工具
工具的作用: 1)比"cluster nodes"更为直观的显示结果 2)指出落在同一个IP上的master 3)指出落在同一个IP上的master和slave对 运行效果图: 源 ...
- LINUX:关于Redis集群的节点分配
文章来源:http://www.cnblogs.com/hello-tl/p/7808268.html 根据上述 Redis集群搭建:http://www.cnblogs.com/hello-tl/ ...
- Redis集群增加节点和删除节点
本文主要是承接上一篇文章Redis集群的离线安装成功以后,我们如何进行给集群增加新的主从节点(集群扩容)以及如何从集群中删除节点(集群缩容),也就是集群的伸缩,集群伸缩的原理是控制虚拟槽和数据在节点之 ...
- Redis集群之节点管理
Redis集群一旦启动,就不能轻易删除掉一个节点了. 需要由redis-trib.rg这个ruby脚本行使集群管理的功能.所有的哈希槽都分配于master节点 一.delete master node ...
- 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: ...
- Redis单节点数据同步到Redis集群
一:Redis集群环境准备 1:需要先安装好Redis集群环境并配置好集群 192.168.0.113 7001-7003 192.168.0.162 7004-7006 2:检查redis集群 [r ...
随机推荐
- go语言log包的学习(log,Logger)
package main; import ( "log" "os" "time" "fmt" ) func main() ...
- vuex写法
<template> <div class="hello"> <p>{{count}}</p> <p> <butt ...
- win7系统 无线上网卡 共享网络,设置成wifi热点
给家人买了一个新的智能手机,用的移动神州行套餐,没有开通3G,想更新一些应用软件,于是想到能不能用电脑上的无线上网卡. 在网上找到了一方法,试了一下,还真是可以. 步骤如下: 用无线上网卡拨号上网,并 ...
- Java.FamousBlogs
本文总结在工作/学习中发现的Java相关的blogs. 1. java code geeks (jcg) http://www.javacodegeeks.com/join-us/jcg/ 2. ht ...
- CSharp陷阱1
CSharp陷阱1 环境:sharpdevelop 3 .net 2.0 正确的 internal static readonly string[] string_2 = new ...
- How to convert a PDF file to JPEGs using PHP
Hey, Today I would like to show you how we can convert PDF to JPEG using imagick extension. Imagick ...
- PhpStorm 为 Laravel 搭建 PhpUnit 单元测试环境
1.PhpStorm 中打开项目的路径为 Laravel 安装的根目录 2.点击右下角 EventLog 提示按钮, 初始化 Composer 的设置 3.打开单元单测试示例类,按提示点击 Fix . ...
- JVM 目录
JVM 目录 走进 JVM Java 虚拟机规范(Oracle 官网) Java 虚拟机规范(Java SE 7 中文版) (周志明等译) 周志明,深入理解Java虚拟机[M],机械工业出版社,201 ...
- 如何利用Photoshop进行快速切图
在UI设计中我们常常使用Ai来进行矢量图的绘制,然后导入Ps中进行设计.排版和导出. 在以前的版本中,切图一直是个很麻烦的事情,要么依托于脚本,要么手动一张张导出,很不方便,这种窘况在Photosho ...
- Python3实战系列之二(获取印度售后数据项目)
问题:续接上一篇.说干咱就干呀,勤勤恳恳写程序呀! 目标:安装python和pycharm.要编写并运行python程序就需要电脑有开发工具和运行环境,所以此篇就是安装编辑和运行python程序的软件 ...