Linux Memcached 安裝指南

來源:互聯網
上載者:User

八、 Memcached安裝
8.1. 準備工作
8.1.1.1. 準備安裝檔案
下載memcached與libevent的安裝檔案

http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz(memcached)

https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz(libevent)

8.2. 具體安裝步驟
8.2.1. 具體安裝步驟
1.由於memcached依賴於libevent,因此需要安裝libevent。由於linux系統可能預設已經安裝libevent,執行命令:
rpm -qa|grep libevent
查看系統是否帶有該安裝軟體,如果有執行命令:
rpm -e libevent-1.4.13-4.el6.x86_64 --nodeps(由於系統內建的版本舊,忽略依賴刪除)
2. 安裝libevent命令:
tar zxvf libevent-2.0.21-stable.tar.gz
  cd libevent-2.0.21-stable
  ./configure --prefix=/usr/local/libevent
  make
  make install
至此libevent安裝完畢;
3. 安裝memcached命令:
tar zxvf memcached-1.4.2.tar.gz
  cd memcached-memcached-1.4.2
        ./configure --prefix=/usr/local/memcached --with-libevent=
/usr/local/libevent/
make
make install
  至此memcached安裝完畢;
8.2.2. 可能存在的錯誤以及解決方案

如果出現用戶端串連不上memcached的情況,請將防火牆關閉或將防火牆中的memcached連接埠(11211連接埠)開啟。

9.1.1. 啟動memcached
1.開啟一個終端,輸入以下命令:
/usr/local/memcached/bin/memcached -d -m 256 -u root -p 11211 -c 1024 –P /tmp/memcached.pid

啟動參數說明:
-d 選項是啟動一個守護進程。
-u root 表示啟動memcached的使用者為root。
-m 是分配給Memcache使用的記憶體數量,單位是MB,預設64MB。
-M return error on memory exhausted (rather than removing items)。
-u 是運行Memcache的使用者,如果當前為root 的話,需要使用此參數指定使用者。
-l 是監聽的伺服器IP地址,預設為所有網卡。
-p 是設定Memcache的TCP監聽的連接埠,最好是1024以上的連接埠。
-c 選項是最大啟動並執行並發串連數,預設是1024。
-P 是設定儲存Memcache的pid檔案。
-f <factor> chunk size growth factor (default: 1.25)。
-I Override the size of each slab page. Adjusts max item size(1.4.2版本新增)。
  也可以啟動多個守護進程,但是連接埠不能重複
2.查看memcached啟動命令
ps aux|grep memcached
 
9.1.2. 停止memcached
開啟一個終端,輸入以下命令:
ps -ef | grep memcached
在服務開啟的狀態下,會出現如所示的提示:
 
其中5929為memcached服務的pid
輸入一下命令終止memcached服務
kill -9 5929

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.