memcached安裝

rainbowbridg發表於2008-05-07

memcached安裝

關鍵字: memcached安裝

memcached安裝

1. 下載, memcached需要先安裝libevent

memcached的下載地址:memcached/download.bml

libevent的下載地址 :~provos/libevent/

2. 安裝libevent

java 程式碼
  1. # tar xzvf libevent-1.3c.tar.gz
  2. # cd libevent-1.3c
  3. # ./configure --prefix=/home/mahaibo/install
  4. # make
  5. # make install

檢查是否安裝成功:

#cd /home/mahaibo/install/lib

如果有libevent-1.3c.so.1 libevent-1.3c.so.1.0.3 libevent.a libevent.la libevent.so

這幾個檔案存在,說明安裝成功

3.安裝memcached

java 程式碼
  1. # tar xzvf memcached-1.2.2.tar.gz
  2. # cd memcached-1.2.2
  3. # ./configure --with-libevent=/home/mahaibo/install --prefix=/home/mahaibo/installmemcache
  4. # make
  5. # make install

檢查是否安裝成功:

#cd /home/mahaibo/installmemcache/bin

如果memcached memcached-debug這2個檔案存在,說明安裝成功

4.執行

java 程式碼
  1. #cd /home/mahaibo/installmemcache/bin
  2. # ./memcached -h

如果出現:

java 程式碼
  1. memcached 1.2.2
  2. -p TCP port number to listen on (default: 11211)
  3. -U UDP port number to listen on (default: 0, off)
  4. -s unix socket path to listen on (disables network support)
  5. -l interface to listen on, default is INDRR_ANY
  6. -d run as a daemon
  7. -r maximize core file limit
  8. -u assume identity of (only when run as root)
  9. -m max memory to use for items in megabytes, default is 64 MB
  10. -M return error on memory exhausted (rather than removing items)
  11. -c max simultaneous connections, default is 1024
  12. -k lock down all paged memory
  13. -v verbose (print errors/warnings while in event loop)
  14. -vv very verbose (also print client commands/reponses)
  15. -h print this help and exit
  16. -i print memcached and libevent license
  17. -b run a managed instanced (mnemonic: buckets)
  18. -P save PID in , only used with -d option
  19. -f chunk size growth factor, default 1.25
  20. -n minimum space allocated for key+value+flags, default 48

說明安裝成功,並且路徑配置正確。

有可能會出現:

java 程式碼
  1. memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory

說明 沒有找到檔案:libevent-1.3c.so.1

解決辦法:

第一步. 檢視下lib路徑:

java 程式碼
  1. LD_DEBUG=libs /home/mahaibo/installmemcache/bin/memcached -v

結果為:

java 程式碼
  1. 27515: find library=libevent-1.3c.so.1 [0]; searching
  2. 27515: search path=tls/i686/sse2:tls/i686:tls/sse2:tls:i686/sse2:i686:sse2::/usr/local/lib/tls/i686/sse2:/usr/local/lib/tls/i686:/usr/local/lib/tls/sse2:/usr/local/lib/tls:/usr/local/lib/i686/sse2:/usr/local/lib/i686:/usr/local/lib/sse2:/usr/local/lib:/usr/local/BerkeleyDB.4.3/lib/tls/i686/sse2:/usr/local/BerkeleyDB.4.3/lib/tls/i686:/usr/local/BerkeleyDB.4.3/lib/tls/sse2:/usr/local/BerkeleyDB.4.3/lib/tls:/usr/local/BerkeleyDB.4.3/lib/i686/sse2:/usr/local/BerkeleyDB.4.3/lib/i686:/usr/local/BerkeleyDB.4.3/lib/sse2:/usr/local/BerkeleyDB.4.3/lib:/opt/Ice-3.1/lib/tls/i686/sse2:/opt/Ice-3.1/lib/tls/i686:/opt/Ice-3.1/lib/tls/sse2:/opt/Ice-3.1/lib/tls:/opt/Ice-3.1/lib/i686/sse2:/opt/Ice-3.1/lib/i686:/opt/Ice-3.1/lib/sse2:/opt/Ice-3.1/lib (LD_LIBRARY_PATH)
  3. 27515: trying file=tls/i686/sse2/libevent-1.3c.so.1
  4. 27515: trying file=tls/i686/libevent-1.3c.so.1
  5. 27515: trying file=tls/sse2/libevent-1.3c.so.1
  6. 27515: trying file=tls/libevent-1.3c.so.1
  7. 27515: trying file=i686/sse2/libevent-1.3c.so.1
  8. 27515: trying file=i686/libevent-1.3c.so.1
  9. 27515: trying file=sse2/libevent-1.3c.so.1
  10. 27515: trying file=libevent-1.3c.so.1
  11. 27515: trying file=/usr/local/lib/tls/i686/sse2/libevent-1.3c.so.1
  12. 27515: trying file=/usr/local/lib/tls/i686/libevent-1.3c.so.1
  13. 27515: trying file=/usr/local/lib/tls/sse2/libevent-1.3c.so.1
  14. 27515: trying file=/usr/local/lib/tls/libevent-1.3c.so.1
  15. 27515: trying file=/usr/local/lib/i686/sse2/libevent-1.3c.so.1
  16. 27515: trying file=/usr/local/lib/i686/libevent-1.3c.so.1
  17. 27515: trying file=/usr/local/lib/sse2/libevent-1.3c.so.1
  18. 27515: trying file=/usr/local/lib/libevent-1.3c.so.1
  19. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/sse2/libevent-1.3c.so.1
  20. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/libevent-1.3c.so.1
  21. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/sse2/libevent-1.3c.so.1
  22. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/libevent-1.3c.so.1
  23. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/i686/sse2/libevent-1.3c.so.1
  24. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/i686/libevent-1.3c.so.1
  25. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/sse2/libevent-1.3c.so.1
  26. 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/libevent-1.3c.so.1
  27. 27515: trying file=/opt/Ice-3.1/lib/tls/i686/sse2/libevent-1.3c.so.1
  28. 27515: trying file=/opt/Ice-3.1/lib/tls/i686/libevent-1.3c.so.1
  29. 27515: trying file=/opt/Ice-3.1/lib/tls/sse2/libevent-1.3c.so.1
  30. 27515: trying file=/opt/Ice-3.1/lib/tls/libevent-1.3c.so.1
  31. 27515: trying file=/opt/Ice-3.1/lib/i686/sse2/libevent-1.3c.so.1
  32. 27515: trying file=/opt/Ice-3.1/lib/i686/libevent-1.3c.so.1
  33. 27515: trying file=/opt/Ice-3.1/lib/sse2/libevent-1.3c.so.1
  34. 27515: trying file=/opt/Ice-3.1/lib/libevent-1.3c.so.1
  35. 27515: search path=/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)
  36. 27515: trying file=/usr/lib/tls/i686/sse2/libevent-1.3c.so.1
  37. 27515: trying file=/usr/lib/tls/i686/libevent-1.3c.so.1
  38. 27515: trying file=/usr/lib/tls/sse2/libevent-1.3c.so.1
  39. 27515: trying file=/usr/lib/tls/libevent-1.3c.so.1
  40. 27515: trying file=/usr/lib/i686/sse2/libevent-1.3c.so.1
  41. 27515: trying file=/usr/lib/i686/libevent-1.3c.so.1
  42. 27515: trying file=/usr/lib/sse2/libevent-1.3c.so.1
  43. 27515: trying file=/usr/lib/libevent-1.3c.so.1
  44. 27515: search cache=/etc/ld.so.cache
  45. 27515: 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:/usr/lib/tls:/usr/lib/sse2:/usr/lib (system search path)
  46. 27515: trying file=/lib/tls/i686/sse2/libevent-1.3c.so.1
  47. 27515: trying file=/lib/tls/i686/libevent-1.3c.so.1
  48. 27515: trying file=/lib/tls/sse2/libevent-1.3c.so.1
  49. 27515: trying file=/lib/tls/libevent-1.3c.so.1
  50. 27515: trying file=/lib/i686/sse2/libevent-1.3c.so.1
  51. 27515: trying file=/lib/i686/libevent-1.3c.so.1
  52. 27515: trying file=/lib/sse2/libevent-1.3c.so.1
  53. 27515: trying file=/lib/libevent-1.3c.so.1
  54. 27515: trying file=/usr/lib/tls/i686/libevent-1.3c.so.1
  55. 27515: trying file=/usr/lib/tls/libevent-1.3c.so.1
  56. 27515: trying file=/usr/lib/sse2/libevent-1.3c.so.1
  57. 27515: trying file=/usr/lib/libevent-1.3c.so.1
  58. 27515:
  59. /home/mahaibo/installmemcache/bin/memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory

第二步. 將libevent-1.3c.so.1複製到任何一個列出的lib 下就可以了。

或者 軟連結

java 程式碼
  1. ln -s /Data/libevent/lib/libevent-1.3b.so.1 /usr/lib/libevent-1.3c.so.1

或者 修改vi /etc/profile檔案。

java 程式碼
  1. export LIBRARY_PATH=:/usr/local/lib:"/usr/local/BerkeleyDB.4.3/lib":/usr/local/lib:/opt/Ice-3.1/lib:/usr/lib:/home/mahaibo/install/lib

其實還有一辦法,用find查詢該so檔案,將存在的路徑加在 LIBRARY_PATH後面就可以的!

啟動服務 :

java 程式碼

  1. ./memcached -d -m 10 -u root -l 192.168.40.4 -p 12000 -c 256 -P /tmp/memcached.pid

引數說明:

-d選項是啟動一個守護程式
-m是分配給Memcache使用的記憶體數量,單位是MB,我這裡是10MB
-u是執行Memcache的使用者,我這裡是root
-l是監聽的伺服器IP地址
-p是設定Memcache監聽的埠,最好是1024以上的埠
-c選項是最大執行的併發連線數,預設是1024,按照你伺服器的負載量來設定
-P是設定儲存Memcache的pid檔案

[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/7916042/viewspace-1003542/,如需轉載,請註明出處,否則將追究法律責任。

相關文章