Install memcached and unixmemcached on unix
Install libevent before installing memcached
Libevent from external
Install libevent
(1)decompress libevent-2.0.22-stable.tar.gz
tar -xvf libevent-2.0.22-stable.tar.gz
(2) Compile libevent
cd libevent-2.0.22-stablesudo ./configure -prefix=/usr/local/libevent
(3) install 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)decompress memcached-1.2.7.tar.gz
tar -xvf memcached-1.2.7.tar.gz
(2) Compile memcached-1.2.7
sudo ./configure -with-libevent=/usr/local/libevent/
(3) install memcached
sudo makesudo make install
(4) Start the 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 allocated to Memcache. The unit is MB. Here I am going to 10 MB. The default value is 64M-u, which is the user who runs Memcache, here I am root and-l is the IP address of the server to listen to. If there are multiple IP addresses, I have specified the IP address 192.168.0.200 for the server, the default value is "Native-p", which is the port for Memcache listening. I have set 12000 here, preferably over 1024. The default value is "Running 11-c", which is the maximum number of concurrent connections. The default value is 1024, I set 256 here based on the load of your server.-P is the pid file for saving Memcache, and I saved it in/tmp/memcached. pid,-h print help information-v output warning and error information-vv print client request and return information
To end the Memcache process, run:
kill 'cat /tmp/memcached.pid'
You can also start multiple daemon processes, but the ports cannot be repeated.
Shell script checks whether 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 "'# Run the ps command to view the memcached process MM = 'ps-aux | grep" memcached "| grep" 11211 "| grep-v" grep "| wc-l '# if statement to determine whether a process exists, if it does not exist, output the log and restart the memcached service if ["$ MM" = "0"]; then echo "$ DATE The memcached is problem and restart">/root/sh/memcached_check.logs/opt/env/memcache/bin/memcached-t 8-d-m 2048-p 11211-u nobody else # echo "$ DATE The memcached is OK">/root/sh/memcached_check.logsfi