忘记密码   免费注册 查看新帖 | 论坛精华区

ChinaUnix.net

  平台 论坛 博客 认证专区 大话IT 视频 徽章 文库 沙龙 自测 下载 频道自动化运维 虚拟化 储存备份 C/C++ PHP MySQL 嵌入式 Linux系统
最近访问板块 发新帖
查看: 5755 | 回复: 5

计算cluster的内存使用量 [复制链接]

论坛徽章:
0
发表于 2011-11-17 13:28 |显示全部楼层
执行效果这样的
  1. ndb_memsize.sh  11
  2. KB:1024 MB:1048576 GB:1073741824
  3. MaxNoOfAttributes........................ (MB): 156
  4. MaxNoOfTables............................ (MB): 160
  5. MaxNoOfOrderedIndexes.................... (MB): 195
  6. MaxNoOfUniqueHashIndexes................. (MB): 80
  7. MaxNoOfConcurrentOperations.............. (MB): 2048
  8. TransactionBufferMemory.................. (MB): 1
  9. IndexMemory.............................. (MB): 1200
  10. DataMemory............................... (MB): 12000
  11. UndoIndexBuffer.......................... (MB): 2
  12. UndoDataBuffer........................... (MB): 16
  13. RedoBuffer............................... (MB): 32
  14. LongMessageBuffer........................ (MB): 4
  15. DiskPageBufferMemory..................... (MB): 64
  16. SharedGlobalMemory....................... (MB): 20
  17. BackupMemory............................. (MB): 32

  18. ******Total Memory size: 15.63GB******
复制代码

论坛徽章:
0
发表于 2011-11-17 13:29 |显示全部楼层
本帖最后由 枫影谁用了 于 2011-11-17 13:50 编辑
  1. #!/bin/bash

  2. usage()
  3. {
  4.    echo "-----------------------------"
  5.    echo "Usage:$(basename $0) NodeId"
  6.    echo "-----------------------------"
  7.    echo
  8.    exit 1
  9. }

  10. print_size ()
  11. {
  12. string1=$(echo $1|sed -e :a -e 's/^.\{1,40\}$/&./;ta')
  13. echo -e "$string1 (MB):\t$2"
  14. }



  15. if [ "$1" == "" ]; then
  16.     usage
  17. fi
  18. string1=$(echo $1|egrep "^[0-9]+$")
  19. if [ "$1" != "$string1" ]; then
  20.     usage
  21. fi



  22. GETVAL="ndb_config  --id=$1 -q"
  23. #ndb_config  --id=12 -q MaxNoOfAttributes
  24. ksize=1024
  25. msize=$(echo "scale=2; 1024*1024" | bc -l 2>/dev/null)
  26. gsize=$(echo "scale=2; 1024*1024*1024" | bc -l 2>/dev/null)
  27. echo "KB:$ksize MB:$msize GB:$gsize"

  28. MEMSIZE=0

  29. #Attributes
  30. TSIZE=$($GETVAL MaxNoOfAttributes)
  31. TSIZE=$(echo "scale=0; $TSIZE*200" | bc -l 2>/dev/null)
  32. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  33. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  34. print_size "MaxNoOfAttributes" $TSIZE


  35. #Attributes
  36. TSIZE=$($GETVAL MaxNoOfTables)
  37. TSIZE=$(echo "scale=0; $TSIZE*20*$ksize" | bc -l 2>/dev/null)
  38. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  39. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  40. print_size "MaxNoOfTables" $TSIZE


  41. #Attributes
  42. TSIZE=$($GETVAL MaxNoOfOrderedIndexes)
  43. TSIZE=$(echo "scale=0; $TSIZE*10*$ksize" | bc -l 2>/dev/null)
  44. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  45. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  46. print_size "MaxNoOfOrderedIndexes" $TSIZE

  47. #Attributes
  48. TSIZE=$($GETVAL MaxNoOfUniqueHashIndexes)
  49. TSIZE=$(echo "scale=0; $TSIZE*10*$ksize" | bc -l 2>/dev/null)
  50. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  51. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  52. print_size "MaxNoOfUniqueHashIndexes" $TSIZE



  53. #Attributes
  54. TSIZE=$($GETVAL MaxNoOfConcurrentOperations)
  55. TSIZE=$(echo "scale=0; $TSIZE*1*$ksize" | bc -l 2>/dev/null)
  56. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  57. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  58. print_size "MaxNoOfConcurrentOperations" $TSIZE

  59. #Attributes
  60. TSIZE=$($GETVAL TransactionBufferMemory)
  61. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  62. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  63. print_size "TransactionBufferMemory" $TSIZE

  64. #Attributes
  65. TSIZE=$($GETVAL IndexMemory)
  66. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  67. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  68. print_size "IndexMemory" $TSIZE

  69. #Attributes
  70. TSIZE=$($GETVAL DataMemory)
  71. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  72. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  73. print_size "DataMemory" $TSIZE

  74. #Attributes
  75. TSIZE=$($GETVAL UndoIndexBuffer)
  76. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  77. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  78. print_size "UndoIndexBuffer" $TSIZE

  79. #Attributes
  80. TSIZE=$($GETVAL UndoDataBuffer)
  81. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  82. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  83. print_size "UndoDataBuffer" $TSIZE

  84. #Attributes
  85. TSIZE=$($GETVAL RedoBuffer)
  86. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  87. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  88. print_size "RedoBuffer" $TSIZE

  89. #Attributes
  90. TSIZE=$($GETVAL LongMessageBuffer)
  91. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  92. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  93. print_size "LongMessageBuffer" $TSIZE

  94. #Attributes
  95. TSIZE=$($GETVAL DiskPageBufferMemory)
  96. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  97. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  98. print_size "DiskPageBufferMemory" $TSIZE

  99. #Attributes
  100. TSIZE=$($GETVAL SharedGlobalMemory)
  101. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  102. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  103. print_size "SharedGlobalMemory" $TSIZE

  104. #Attributes
  105. TSIZE=$($GETVAL BackupMemory)
  106. MEMSIZE=$(echo "scale=2; $MEMSIZE+$TSIZE" | bc -l 2>/dev/null)
  107. TSIZE=$(echo "scale=0; $TSIZE/$msize" | bc -l 2>/dev/null)
  108. print_size "BackupMemory" $TSIZE

  109. MEMSIZE=$(echo "scale=2; $MEMSIZE/$gsize" | bc -l 2>/dev/null)

  110. echo
  111. echo  "******Total Memory size: ${MEMSIZE}GB******"
复制代码

评分

参与人数 1可用积分 +10 收起 理由
枫影谁用了 + 10 好工具

查看全部评分

论坛徽章:
0
发表于 2011-11-17 13:31 |显示全部楼层
说明下,计算公式是飞龙无痕提供的

论坛徽章:
0
发表于 2011-11-17 14:09 |显示全部楼层
不错啊,很实用的一个工具!

论坛徽章:
0
发表于 2011-11-17 14:37 |显示全部楼层
呵呵,加精了!
晕,是飞鸿无痕,飞龙在天用多了

论坛徽章:
0
发表于 2011-11-17 14:40 |显示全部楼层
回复 5# kerlion


    恭喜恭喜,哈哈!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

  

北京皓辰网域网络信息技术有限公司. 版权所有 京ICP证:060528号 北京市公安局海淀分局网监中心备案编号:1101082001
广播电视节目制作经营许可证(京) 字第1234号 中国互联网协会会员  联系我们:
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP