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/