一:安裝memcached
1.下載memcached包
下載地址:http://www.memcached.org (最新包就在首頁,點擊下載就OK)
解壓包:# tar -zxvf memcached-1.4.13.tar.gz (根據自身的狀況解壓到目錄)
進入目錄:# cd memcached-1.4.13
2.安裝libevent
檢查一下有沒有安裝libevent: ls -al /usr/lib |grep libevent
若是沒有就安裝libevent ,下載地址:http://www.libevent.org (首頁 Download–Stable releases)
解壓:# tar -zxvf libevent-***-.tar.gz
#cd libevent-***-
#./configure --prefix=/usr
#make && make install
安裝完檢測下 ls -al /usr/lib |grep libevent
lrwxrwxrwx 1 root root 21 02-06 20:26 libevent-1.4.so.2 -> libevent-1.4.so.2.1.3
.................................
-rw-r--r-- 1 root root 11838 04-13 14:03 libevent_pthreads.a
-rwxr-xr-x 1 root root 996 04-13 14:03 libevent_pthreads.la
lrwxrwxrwx 1 root root 30 04-13 14:03 libevent_pthreads.so -> libevent_pthreads-2.0.so.5.1.6
lrwxrwxrwx 1 root root 21 04-13 14:03 libevent.so -> libevent-2.0.so.5.1.6
3.安裝memcached
預安裝:#./configure --prefix=/usr/local/memcached --with-libevent=/usr
注意:在沒有安裝libevent的狀況下,會報錯( If it's already installed, specify its path using --with-libevent=/dir/);
編譯而且安裝:# make && make install
OK安裝成功.
啓動memcached:
# /usr/local/memcached/bin/memcached -l 192.168.1.144 -d -p 11211 -u nobody -m 1024
說明:上面的命令中-d表示用 daemon 的方式啓動 memcached,-l和-p組合表示監聽在 192.168.1.144 的 11212 端口上(若是不用-p指定端口號,則memcached將運行在11211端口 上),-u表示運行用戶爲 nobody,-m表示爲其分配1024MB 的內存。
鏈接 memcached: # telnet 192.168.1.144 11211
到這裏 memcached就已經安裝好了。
增長到開機啓動
# vi /etc/rc.local
增長:
/usr/local/memcached/bin/memcached -l 192.168.1.144 -d -p 11211 -u nobody -m 1024
二:安裝memcacheq
1.下載memcacheq包
下載地址:http://code.google.com/p/memcacheq/downloads/list
解壓包:# tar -zxvf memcacheq.0.2.tar.gz (根據自身的狀況解壓到目錄)
進入目錄:# cd memcacheq-0.2.0
2.安裝 BerkeleyDB
下載地址:http://www.oracle.com/technetwork/products/berkeleydb/downloads/index.html
解壓包:# tar -zxvf db-5.3.15.tar.gz (根據自身的狀況解壓到目錄)
進入目錄:# cd db-5.3.15
# cd build_unix
#../dist/configure --prefix=/usr/local/BerkeleyDB.5.3
# make && make install
#vi /etc/ld.so.conf
增長:
/usr/local/lib
/usr/local/BerkeleyDB.5.3/lib
#vi /etc/profile
增長
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib:/usr/local/BerkeleyDB.5.3/lib
3.安裝memcacheq (注: 下文中的5.3是berkeleyDB的版本 請根據實際狀況操做)
預安裝:./configure --prefix=/usr/local/memcacheq --enable-threads
注意:在沒有安裝BerkeleyDB的狀況下,會報錯( configure: error: cannot find libdb.so in /usr/local/BerkeleyDB.5.3/lib);
# make && make install
測試:/usr/local/memcacheq/bin/memcachq -h
運行報:
memcacheq: error while loading shared libraries: libdb-5.3.so: cannot open shared object file: No such file or directory
解決方法:ln -s /usr/local/BerkeleyDB.5.3/lib/libdb-5.3.so /usr/lib/libdb-5.3.so
鏈接:/usr/local/memcacheq/bin/memcacheq -d -r -uroot -p11212 -H /var/mcq/data -N -R -v -L 1024 -B 1024 > /var/mcq/logs/mq_error.log 2>&1
(/var/mcq/data 必須本身建立)
# ps -ef |grep memcacheq
root 11908 1 4 18:06 ? 00:00:00 /usr/local/memcacheq/bin/memcacheq -d -r -uroot -p11212 -H /var/mcq/data -N -R -v -L 1024 -B 1024
已經開始運行 .
鏈接到memcacheq:#telnet 192.168.1.144 11212
增長到開機啓動
# vi /etc/rc.local
增長:/usr/local/memcacheq/bin/memcacheq -d -r -uroot -p11212 -H /var/mcq/data -N -R -v -L 1024 -B 1024 > /var/mcq/logs/mq_error.log 2>&1