幾種Memcache的狀態監控的工具,以及安裝和使用【linux系統】


 

1.Memcache-top的簡介及安裝和用法

簡介:memcache-top是用perl語言編寫的,可以運行在term下。它能夠像top一樣顯示各個memcached節點的狀態變化,其中包括系統管理員最關心的幾個指數,例如:緩存命中率,內存使用率,讀寫QPS等
由於memcached安裝時,需要使用libevent類庫,所以先
安裝libevent
libevent下載網址:https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

本手冊中下載的是 libevent-2.0.21-stable.tar.gz版本安裝步驟如下:

  1. 解壓縮

  tar xzfv libevent-2.0.21-stable.tar.gz

  2. 進入到 libevent-2.0.21-stable目錄

  cd libevent-2.0.21-stable

  3. 編譯,安裝

  ./configure

  make

  make install

  注:默認安裝到/usr/local/lib/ 目錄

安裝memcached

  接下來,安裝memcached

  memcached下載網址:http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz

  本手冊中下載的是 memcached-1.4.15.tar.gz版本

  安裝步驟如下:

  1. 解壓縮

  tar xzfv memcached-1.4.15.tar.gz

  2. 進入到 memcached-1.4.15目錄

  cd memcached-1.4.15

  3. 編譯,安裝

  ./configure –prefix=/local/memcached

  make

  make install

  安裝完成后,會在 usr/local/memcached 出現 bin和share目錄

  進行 bin目錄,啟動 memcache

      ./configure

    Memcache-Top 安裝步驟如下:

 

  mkdir ~/srv/ 
  cd ~/srv/  
  svn checkout http://memcache-top.googlecode.com/svn/trunk/ memcache-top  
  cd memcache-top  
  sudo ln -s ~/srv/memcache-top/memcache-top /usr/bin/memcache-top  
  直接輸入 memcache-top 就可以看到(預設是 localhost:11211)
  多台機器可用 memcache-top --instances localhost:11211,example1.com:11211,example2.com:11211

      下載后只有一個文件,可以打開它並進行memcached集群配置,多個節點之間以逗號分隔。

  # List of servers/ ports to query.
  @default_instances = (
   '127.0.0.1:11211',
  );
執行的時候,找到安裝的位置,執行這個命令./memcache-top

用telnet 127.0.0.1 11211這樣的命令連接上memcache,然后直接輸入stats就可以得到當前memcache的狀態。
這些狀態的說明如下:

pid memcache服務器的進程ID
uptime 服務器已經運行的秒數
time 服務器當前的unix時間戳
version memcache版本
pointer_size 當前操作系統的指針大小(32位系統一般是32bit)
rusage_user 進程的累計用戶時間
rusage_system 進程的累計系統時間
curr_items 服務器當前存儲的items數量
total_items 從服務器啟動以后存儲的items總數量
bytes 當前服務器存儲items占用的字節數
curr_connections 當前打開着的連接數
total_connections 從服務器啟動以后曾經打開過的連接數
connection_structures 服務器分配的連接構造數
cmd_get get命令(獲取)總請求次數
cmd_set set命令(保存)總請求次數
get_hits 總命中次數
get_misses 總未命中次數
evictions 為獲取空閑內存而刪除的items數(分配給memcache的空間用滿后需要刪除舊的items來得到空間分配給新的items)
bytes_read 總讀取字節數(請求字節數)
bytes_written 總發送字節數(結果字節數)
limit_maxbytes 分配給memcache的內存大小(字節)
threads 當前線程數

2.Mc-top的簡介及安裝和用法
mctop 與 memcache-top 相似,主要用於監視 Memcache 的流量,包括 key 的調用次數、對象存儲大小、每秒的請求數、以及消耗的網絡帶寬等。
源代碼:https://github.com/etsy/mctop

安裝指令
  1. [root@ycw-houcm /]#cd usr
  2. [root@ycw-houcm usr]#cd local
  3. [root@ycw-houcm local]# yum install libpcap-devel ruby-devel rubygems git
  4. [root@ycw-houcm local]# gem install ruby-pcap -v '0.7.8'
  5. [root@ycw-houcm local]# gem install bundle
  6. [root@ycw-houcm local]# gem install rake
  7. [root@ycw-houcm local]# git clone git:github.com/etsy/mctop.git 
  8. [root@memcache2 mctop]# cd mctop/
  9. [root@memcache2 mctop]# bundle install 
  10. [root@memcache2 mctop]# rake install 
  11. [root@memcache2 mctop]# mctop -h
  12. [root@ycw-houcm mctop]# mctop -i eth0 -p 11211
使用方法:在安裝目錄執行命令 mctop -i eth0 -p 11211
3.memkeys的簡介及安裝和用法

簡介
memkeys是tumblr開源的類似top的工具,可用於實時查看memcached的key使用情況.

    memkeys安裝

 
         

安裝autoconf(要求版本2.68以上):

 
         

   安裝其它依賴:

  • # yum install libpcap-devel pcre-devel ncurses-devel

   安裝memkeys:

 
         

memkeys使用

 
         
  • # memkeys -h
  • Usage: memkeys -i NIC [options]
  • -d, –discard=THRESH Discard keys where req/s rate is below THRESH
  • -i, –interface=NIC Network interface to capture traffic on (required)
  • -p, –port=PORT Network port to capture memcache traffic on (default 11211)
  • -r, –refresh=INTERVAL Refresh the stats display every INTERVAL ms (default 500)
  • -l, –logfile=FILE Output logs to FILE
  • -R, –report=REPORT Output data in REPORT format (CSV or curses, default curses)
  •  
  • -h, –help This help
  • -v, –verbose Increase verbosity. May be used multiple times.
  • -V, –version Show program info and exit.
 
         

 例子1:

# memkeys -i eth0 -l /tmp/memkeys.log

 
         

 例子2:

# memkeys -i eth0 -d 10.0 -l /tmp/memkeys.log

寫的不全的地方,希望大伙見諒,寫的有錯誤的地方,希望大伙指點一下,我對linux不熟悉,只是最近用到了,就隨便瞄幾眼linux命令,有不了解的問題,大伙共同探討一下O(∩_∩)O~


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM