Install libevent before installing memcached
Libevent Download from http://jaist.dl.sourceforge.net/project/levent/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
Installing Libevent
(1) Decompression libevent-2.0.22-stable.tar.gz
tar -xvf libevent-2.0.22-stable.tar.gz
(2) Compiling libevent
cd libevent-2.0.22-stable.-prefix=/usr/local/libevent
(3) Installation libevent
sudo makesudo make install
After installing Libevent
Next Install memcached
Download memcached
: http://www.danga.com/memcached/dist/memcached-1.2.7.tar.gz
(1) Decompression memcached-1.2.7.tar.gz
tar -xvf memcached-1.2.7.tar.gz
(2) Compiling memcached-1.2.7
.-with-libevent=/usr/local/libevent/
(3) Installation memcached
sudo makesudo make install
(4) Start memcached service
/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid
-the D option is to start a daemon,-M is the amount of memory that is allocated to Memcache , in megabytes, I am here is tenmb , the default is M-U is the user running Memcache , I am here root,-L is the server IP address of the listener, if there are more than one address, I specify the IP address of the server 192.168. 0. The default is native-p is set Memcache listening port, I set the 12000here, preferably more than a minimum of more than the port, the default is 11211 -The c option is the maximum number of concurrent connections to run, the default is 1024x768, I set up here, according to the load of your server to set,- P is set to save Memcache pid file, I am here to save in/tmp/memcached.pid,-h Printing Help information-v output Warning and error messages-the request and return information of the VV print client
If you want to end the memcache process, execute:
kill‘cat /tmp/memcached.pid‘
You can also start multiple daemons, but the ports cannot be duplicated.
Shell script detects if the memcached process is started
#!/bin/sh#check memcached Process and restart if downPath=$PATH:/opt/env/memcache/bin/memcacheddate= ' Date- D "Today"+"%y-%m-%d-%h:%m"`#用ps命令查看memcached进程Mm= ' Ps-aux |grep"memcached"|grep"11211"|grep-v"grep"|wc- L`#if语句判断进程是否存在, if not present, output logging and restart the memcached serviceif["$MM"=="0"]; Then Echo "$DATE the memcached is problem and restart">>/root/sh/memcached_check.logs/opt/env/memcache/bin/memcached-t8 - D-M2048-P11211-U NobodyElse#echo "$DATE the memcached is OK" >>/root/sh/memcached_check.logsfi
UNIX installation memcached