Install and set memcache and linuxmemcache in Linux
Memcache is a high-performance, distributed memory object cache system that reduces database loads in dynamic applications and improves access speeds. It is said that its users, including twitter, digg, and flickr, are all Internet giants. Currently, memcache is widely used for reading large users on the Internet.
Download and install
Download, I arrived at its official (http://memcached.org/), the latest download version is 1.4.5
And then install the libevent software from the official (http://monkey.org /~ Provos/libevent/) download. The latest stable version is 1.4.14.
After the download, upload it to/home/blue/
Run the following command:
Cd/home/bluetar zxvf memcached-1.4.5.tar.gztar zxvf libevent-1.4.14b-stable.tar.gz # Install libeventcd libevent-1.4.14b-stable. /configure -- prefix =/home/liuzhy/libevent-1.4.14b-stablemakemake install # install memcachedud/home/blue/memcached-1.4.5. /configure -- prefix =/home/blue/memcached-1.4.5 -- with-libevent =/home/blue/libevent-1.4.14bmake make install
Start memcache Service
Go to the bin directory and run:./Memcached-d-m 1024-u blueBut the system says there is a shared library not loaded, the name of the shared library is: libevent-1.4.so.2
First, check the address of the link library used by the memcached command. Run the following command to View Details:
LD_DEBUG = libs/usr/local/memcached/bin/memcached-v
Shows where memcache looks for the libevent-1.4.so.2 file, so we only need to specify the libevent-1.4.so.2 file to any directory above. Here we specify it to/lib64. Make a soft connection. The command is as follows:
Ln-s/usr/local/lib/libevent-1.4.so.2/usr/lib/libevent-1.4.so.2
Start the memcache service:./Memcached-d-m 1024-u blueYou can.
The following describes the parameters of the memcached command,
#/Usr/local/bin/memcached-d-m 200-u root-l 192.168.1.91-p 12301-c 1000-P/tmp/memcached. the pid is explained as follows: The-d option is to start a daemon.-m is the amount of memory allocated to Memcache. The unit is MB. Here, 200MB-u is the user who runs Memcache, if it is root, you need to use this parameter to specify the user. -L is the IP address of the listening server. If there are multiple IP addresses, I have specified the Server IP address 192.168.1.91-p as the port for setting the Memcache listening, and I have set 12301 here, it is best to set port-c above 1024 to the maximum number of concurrent connections. The default value is 1024. Here, the setting of 256-P is to set the pid file for saving Memcache, I saved it in/tmp/memcached. pid stops the Memcache process: # kill 'cat/tmp/memcached. the pid can also start multiple daemon processes, but the ports cannot be repeated.
The "-d" parameter in the beginning needs further explanation.
-D install memcached-d uninstall memcached-d start memcached service-d restart memcached service-d stop memcached service-d shutdown stop memcached Service
Check service:
1. view the started memcache service:
netstat -lp | grep memcached
2. view the memcache process number (the memcache service can be terminated by the process number: "kill-9 process number ")
ps -ef | grep memcached