memcached安裝
1. 下載, memcached需要先安裝libevent
memcached的下載地址:http:///memcached/download.bml
libevent的下載地址 :http://www./~provos/libevent/
2. 安裝libevent
java 代碼
- # tar xzvf libevent-1.3c.tar.gz
- # cd libevent-1.3c
- # ./configure --prefix=/home/mahaibo/install
- # make
- # 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
這幾個(gè)文件存在,,說(shuō)明安裝成功
3.安裝memcached
java 代碼
- # tar xzvf memcached-1.2.2.tar.gz
- # cd memcached-1.2.2
- # ./configure --with-libevent=/home/mahaibo/install --prefix=/home/mahaibo/installmemcache
- # make
- # make install
檢查是否安裝成功:
#cd /home/mahaibo/installmemcache/bin
如果memcached memcached-debug這2個(gè)文件存在,,說(shuō)明安裝成功
4.執(zhí)行
java 代碼
- #cd /home/mahaibo/installmemcache/bin
-
- # ./memcached -h
如果出現(xiàn):
java 代碼
- memcached 1.2.2
- -p TCP port number to listen on (default: 11211)
- -U UDP port number to listen on (default: 0, off)
- -s unix socket path to listen on (disables network support)
- -l interface to listen on, default is INDRR_ANY
- -d run as a daemon
- -r maximize core file limit
- -u assume identity of (only when run as root)
- -m max memory to use for items in megabytes, default is 64 MB
- -M return error on memory exhausted (rather than removing items)
- -c max simultaneous connections, default is 1024
- -k lock down all paged memory
- -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 save PID in , only used with -d option
- -f chunk size growth factor, default 1.25
- -n minimum space allocated for key+value+flags, default 48
說(shuō)明安裝成功,,并且路徑配置正確,。
有可能會(huì)出現(xiàn):
java 代碼
- memcached: error while loading shared libraries: libevent-1.3c.so.1: cannot open shared object file: No such file or directory
說(shuō)明 沒(méi)有找到文件:libevent-1.3c.so.1
解決辦法:
第一步. 查看下lib路徑:
java 代碼
- LD_DEBUG=libs /home/mahaibo/installmemcache/bin/memcached -v
結(jié)果為:
java 代碼
- 27515: find library=libevent-1.3c.so.1 [0]; searching
- 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)
- 27515: trying file=tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=tls/i686/libevent-1.3c.so.1
- 27515: trying file=tls/sse2/libevent-1.3c.so.1
- 27515: trying file=tls/libevent-1.3c.so.1
- 27515: trying file=i686/sse2/libevent-1.3c.so.1
- 27515: trying file=i686/libevent-1.3c.so.1
- 27515: trying file=sse2/libevent-1.3c.so.1
- 27515: trying file=libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/tls/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/lib/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/local/BerkeleyDB.4.3/lib/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/tls/sse2/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/i686/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/opt/Ice-3.1/lib/libevent-1.3c.so.1
- 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)
- 27515: trying file=/usr/lib/tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/tls/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/libevent-1.3c.so.1
- 27515: search cache=/etc/ld.so.cache
- 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)
- 27515: trying file=/lib/tls/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/lib/tls/sse2/libevent-1.3c.so.1
- 27515: trying file=/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/lib/i686/sse2/libevent-1.3c.so.1
- 27515: trying file=/lib/i686/libevent-1.3c.so.1
- 27515: trying file=/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/lib/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/tls/i686/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/tls/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/sse2/libevent-1.3c.so.1
- 27515: trying file=/usr/lib/libevent-1.3c.so.1
- 27515:
- /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拷貝到任何一個(gè)列出的lib 下就可以了,。
或者 軟鏈接
java 代碼
- ln -s /Data/libevent/lib/libevent-1.3b.so.1 /usr/lib/libevent-1.3c.so.1
或者 修改vi /etc/profile文件,。
java 代碼
- 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
啟動(dòng)服務(wù) :
java 代碼
- ./memcached -d -m 10 -u root -l 192.168.40.4 -p 12000 -c 256 -P /tmp/memcached.pid
參數(shù)說(shuō)明:
-d選項(xiàng)是啟動(dòng)一個(gè)守護(hù)進(jìn)程 -m是分配給Memcache使用的內(nèi)存數(shù)量,,單位是MB,我這里是10MB -u是運(yùn)行Memcache的用戶(hù),,我這里是root -l是監(jiān)聽(tīng)的服務(wù)器IP地址 -p是設(shè)置Memcache監(jiān)聽(tīng)的端口,最好是1024以上的端口 -c選項(xiàng)是最大運(yùn)行的并發(fā)連接數(shù),,默認(rèn)是1024,按照你服務(wù)器的負(fù)載量來(lái)設(shè)定 -P是設(shè)置保存Memcache的pid文件
|