日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

查看Redis集群所有节点内存工具

發(fā)布時(shí)間:2025/3/15 数据库 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 查看Redis集群所有节点内存工具 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

指定集群中任意一個(gè)節(jié)點(diǎn),查看集群中所有節(jié)點(diǎn)當(dāng)前已用物理內(nèi)存、配置的最大物理內(nèi)存和系統(tǒng)物理內(nèi)存。
?
?源碼(可從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.56GREDIS_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 usageexit 1 fieval $(echo "$1" | awk -F[\:] '{ printf("REDIS_IP=%s\nREDIS_PORT=%s\n",$1,$2) }') if test -z "$REDIS_IP" -o -z "$REDIS_PORT"; thenecho "Parameter error"usageexit 1 fi# 確保redis-cli可用 which "$REDIS_CLI" > /dev/null 2>&1 if test $? -ne 0; thenecho "\`redis-cli\` not exists or not executable"exit 1 firedis_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# clusterfor redis_node in $redis_nodes;doif test ! -z "$redis_node"; theneval $(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=0maxmemory_human=0total_system_memory_human=0for item in "${items[@]}"doeval $(echo "$item" | awk -F[\:] '{ printf("name=%s\nvalue=%s\n",$1,$2) }')if test "$name" = "used_memory_rss_human"; thenused_memory_rss_human=$valueelif test "$name" = "maxmemory_human"; thenmaxmemory_human=$valueelif test "$name" = "total_system_memory_human"; thentotal_system_memory_human=$valuefidoneecho -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" fifidone fi

?

轉(zhuǎn)載于:https://www.cnblogs.com/aquester/p/9891479.html

總結(jié)

以上是生活随笔為你收集整理的查看Redis集群所有节点内存工具的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。