高效能NoSQL資料庫Redis結合Google開源tcmalloc庫的安裝筆記

來源:互聯網
上載者:User

TCMalloc(Thread-Caching Malloc)是google開發的開源工具──“google-perftools”中的成員。與標準的glibc庫的malloc相比,TCMalloc在記憶體的分配上效率和速度要高得多,可以在很大程度上提高MySQL伺服器在高並發情況下的效能,降低系統負載。

TCMalloc庫的安裝步驟(Linux環境):

1、64位作業系統請先安裝libunwind庫,32位作業系統不要安裝。libunwind庫為基於64位CPU和作業系統的程式提供了基本的堆棧輾轉開解功能,其中包括用於輸出堆疊追蹤的API、用於以編程方式輾轉開解堆棧的API以及支援C++異常處理機制的API。

  1. wget http://download.savannah.gnu.org/releases/libunwind/libunwind-0.99-alpha.tar.gz   
  2. tar zxvf libunwind-0.99-alpha.tar.gz  
  3. cd libunwind-0.99-alpha/  
  4. CFLAGS=-fPIC ./configure  
  5. make CFLAGS=-fPIC  
  6. make CFLAGS=-fPIC install  

2、安裝google-perftools:

  1. wget http://google-perftools.googlecode.com/files/google-perftools-1.7.tar.gz   
  2. tar zxvf google-perftools-1.7.tar.gz  
  3. cd google-perftools-1.7/  
  4. ./configure  
  5. make && make install  
  6.   
  7. echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf  
  8. /sbin/ldconfig  

資料庫redis的安裝步驟

  1. $ curl -O http://redis.googlecode.com/files/redis-2.2.2.tar.gz   
  2. $ tar xzvf redis-2.2.2.tar.gz  
  3. $ cd redis-2.2.2  
  4. $ make USE_TCMALLOC=yes  

檢查tcmalloc是否生效

# lsof -n | grep tcmalloc

出現以下資訊說明生效

redis-ser 13768   root  mem       REG        8,5  1616491     788696 /usr/local/lib/libtcmalloc.so.0.1.0

修改設定檔:

vim redis.conf

找到 daemonize,將後面的no改為yes,讓其可以以服務方式運行

然後啟動 redis:

$ ./redis-server ./redis.conf

串連資料庫進行測試

$ src/redis-cli
redis> set foo bar
OK
redis> get foo
"bar"

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.