linux下Memcached的安裝和啟動

來源:互聯網
上載者:User
linux下Memcached的安裝和啟動

原帖地址:http://dapeng725.blog.sohu.com/136682788.html

下載libevent、memcached
wget http://www.danga.com/memcached/dist/memcached-1.4.0.tar.gz
wget http://www.monkey.org/~provos/libevent-1.2.tar.gz

解包

cd /usr/local
tar -xzvf libevent-1.4.tar.gz
tar -xzvf memcached-1.2.5.tar.gz

處理libevent
cd /usr/local/libevent-1.2/
./configure --prefix=/usr/local/libevent
make
make install

處理memcached
cd /usr/local/memcached-1.2.5/
./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent
make
make install

ll/usr/local/libevent/lib/
存在類似如下檔案
libevent-1.4.so.1 -> libevent-1.4.so.1.0.3
libevent-1.4.so.1.0.3
libevent.a
libevent.la
libevent.so -> libevent-1.4.so.1.0.3

添加memcached lib
利用 LD_DEBUG=libs bin/memcached –v 確定lib

32位機
ln -s /usr/local/libevent/lib/libevent-1.4.so.1 /usr/lib
ln -s /usr/local/libevent/lib/libevent-1.4.so.2 /usr/lib

64位機
ln -s /usr/local/libevent/lib/libevent-1.2.so.1 /usr/lib64

cd /usr/local/memcached
/usr/local/memcached/bin/memcached -h

-p <num>      TCP port number to listen on (default: 11211)

-U <num>      UDP port number to listen on (default: 0, off)

-s <file>     unix socket path to listen on (disables network support)

-a <mask>     access mask for unix socket, in octal (default 0700)

-l <ip_addr> interface to listen on, default is INDRR_ANY

-d            run as a daemon

-r            maximize core file limit

-u <username> assume identity of <username> (only when run as root)

-m <num>      max memory to use for items in megabytes, default is 64 MB

-M            return error on memory exhausted (rather than removing items)

-c <num>      max simultaneous connections, default is 1024

-k            lock down all paged memory. Note that there is a

              limit on how much memory you may lock. Trying to

              allocate more than that would fail, so be sure you

              set the limit correctly for the user you started

              the daemon with (not for -u <username> user;

              under sh this is done with 'ulimit -S -l NUM_KB').

-v            verbose (print errors/warnings while in event loop)

-vv           very verbose (also print client commands/reponses)

-h            print this help and exit

-i            print memcached and libevent license

-b            run a managed instanced (mnemonic: buckets)

-P <file>     save PID in <file>, only used with -d option

-f <factor>   chunk size growth factor, default 1.25

-n <bytes>    minimum space allocated for key+value+flags, default 48

出現如上資訊是,表明安裝正常
注意:查看需要加的lib檔案夾,當出現:
memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory

時,利用 LD_DEBUG=libs bin/memcached –v 調試

 

啟動memcache:
./memcached -help
  ./memcached -d -m 1024 -u root -p 11211 -c 1024 -p /tmp/memcached.pid

開機啟動

echo /usr/local/memcached/bin/memcached -d -m 10 -u root -l 218.16.118.105 -p 11211 -c 256 -P /tmp/memcached.pid >> /etc/rc.local

啟動參數說明:
-d   選項是啟動一個守護進程,
  
-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

我正在玩搜狐微博,快來“關注”我,瞭解我的最新動向吧。
http://dapeng725.t.sohu.com/

聯繫我們

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