centsOs(Linux) memcache 安裝教程

來源:互聯網
上載者:User

安裝

Linux:centOs5.4

安裝libevent庫

cd /usr/local/srcwget http://monkey.org/~provos/libevent-1.3b.tar.gztar zxvf libevent-1.3b.tar.gzcd libevent-1.3b./configuremake && make install

安裝成功
安裝memcache

cd /usr/local/srcwget http://danga.com/memcached/dist/memcached-1.2.5.tar.gztar zxvf memcached-1.2.5.tar.gzcd memcached-1.2.5./configuremake && make install

啟動

cd  usr/local/binbin] # memcached –h出錯memcached: error while loading shared libraries: libevent-1.3b.so.1: cannot open shared object file: No such file or directory

google解決方案: http://bbs.yiwz.net/archiver/?tid-86.html

則運行 LD_DUBUG=libs 就可以知道memcached啟動時庫的載入路徑。具體如下

[root@bogon  usr/local/bin]# LD_DEBUG=libs  memcached –v      5112:     find library=libevent-1.3b.so.1 [0]; searching      5112:      search cache=/etc/ld.so.cache      5112:      search path=/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2:/lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686/sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2:/usr/lib/i686:/usr/lib/sse2:/usr/lib           (system search path)      5112:       trying file=/lib/tls/i686/sse2/libevent-1.3b.so.1      5112:       trying file=/lib/tls/i686/libevent-1.3b.so.1      5112:       trying file=/lib/tls/sse2/libevent-1.3b.so.1      5112:       trying file=/lib/tls/libevent-1.3b.so.1      5112:       trying file=/lib/i686/sse2/libevent-1.3b.so.1      5112:       trying file=/lib/i686/libevent-1.3b.so.1      5112:       trying file=/lib/sse2/libevent-1.3b.so.1      5112:       trying file=/lib/libevent-1.3b.so.1      5112:       trying file=/usr/lib/tls/i686/sse2/libevent-1.3b.so.1      5112:       trying file=/usr/lib/tls/i686/libevent-1.3b.so.1      5112:       trying file=/usr/lib/tls/sse2/libevent-1.3b.so.1      5112:       trying file=/usr/lib/tls/libevent-1.3b.so.1      5112:       trying file=/usr/lib/i686/sse2/libevent-1.3b.so.1      5112:       trying file=/usr/lib/i686/libevent-1.3b.so.1      5112:       trying file=/usr/lib/sse2/libevent-1.3b.so.1      5112:       trying file=/usr/lib/libevent-1.3b.so.1

然後給libevent-1.3b.so.1建立一個連結:

[root@bogon ~]# sudo ln -s /usr/local/lib/libevent-1.3b.so.1 /lib/libevent-1.3b.so.1

檢查是否建立成功

[root@bogon ~]# ls -al /lib|grep libeventlrwxrwxrwx  1 root root      33 Aug 25 19:52 libevent-1.3b.so.1 -> /usr/local/lib/libevent-1.3b.so.1

此時在

bin] # memcached –h

memcached 1.2.5-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

現在memcache成功搞定

預設情況下memcached安裝到/usr/local/bin下。

啟動:

[root@bogon bin]# memcached -d -m 128 -u root -p 11211

檢查是否已經啟動

[root@bogon bin]#  telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.

這裡使用的memcached啟動選項的內容如下。
選項說明
p 使用的TCP連接埠。預設為11211
m 最大記憶體大小。預設為64M
vv 用very vrebose模式啟動,調試資訊和錯誤輸出到控制台
d 作為daemon在後台啟動

查看memcached的內部狀態

[root@bogon bin]# cd /usr/local/bin[root@bogon bin]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to localhost.localdomain (127.0.0.1).Escape character is '^]'.statsSTAT pid 6779STAT uptime 14217STAT time 1314343512STAT version 1.2.5STAT pointer_size 32STAT rusage_user 0.002999STAT rusage_system 0.027995STAT curr_items 0STAT total_items 0STAT bytes 0STAT curr_connections 3STAT total_connections 4STAT connection_structures 4STAT cmd_get 0STAT cmd_set 0STAT get_hits 0STAT get_misses 0STAT evictions 0STAT bytes_read 56STAT bytes_written 482STAT limit_maxbytes 134217728STAT threads 1ENDQuit

到此為止說明你的memcached安裝成功了

相關文章

聯繫我們

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