Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used libevent This library for socket processing, so also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system has libevent installed, you may not need to install it)
Official website: http://www.monkey.org/~provos/libevent/
Download: http://www.monkey.org/~provos/libevent-1.3.tar.gz
Download these two items directly with the wget command. After downloading back to the source file.
Install Libevent first. This thing needs to be configured to specify an installation path, that is./configure–prefix=/usr; then make; then make install;2. Then install memcached, just need to specify the Libevent installation path when configuring. CONFIGURE–WITH-LIBEVENT=/USR; then make; then make install;
This completes the Linux Memcache server-side installation. The detailed approach is as follows:
1. Download the memcached and libevent separately and put them in the/tmp directory:
# cd/tmp
# wget http://www.danga.com/memcached/dist/memcached-1.2.0.tar.gz
# wget
2. Install Libevent First:
# tar ZXVF libevent-1.2.tar.gz
# CD libevent-1.2
#./CONFIGURE–PREFIX=/USR
# make
# make Install
3. Test whether the Libevent is installed successfully:
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent-1.2.so.1-> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root root 263546 11?? 17:38 libevent-1.2.so.1.0.3
-rw-r–r–1 root root 454156 11?? 17:38 LIBEVENT.A
-rwxr-xr-x 1 root root 811 11?? 17:38 libevent.la
lrwxrwxrwx 1 root root 21 11?? 17:38 libevent.so-> libevent-1.2.so.1.0.3
4. Install memcached, also need to install the designated Libevent installation location:
# cd/tmp
# tar ZXVF memcached-1.2.0.tar.gz
# CD memcached-1.2.0
#./CONFIGURE–WITH-LIBEVENT=/USR
# make
# make Install
If there is an error in the middle, please check the errors carefully, and configure or add the corresponding libraries or paths according to the error message. When the installation is complete, the memcached will be placed on the/usr/local/bin/memcached
5. Test for successful installation of memcached:
# ls-al/usr/local/bin/mem*
-rwxr-xr-x 1 root root 137986 11?? 17:39/usr/local/bin/memcached
-rwxr-xr-x 1 root root 140179 11?? 17:39/usr/local/bin/memcached-debug
Start the memcached service:
1. Start the Memcache server side:
#/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, in megabytes, I am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.0.200,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 256 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which I am here to save in/tmp/memcached.pid,
2. 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.
Test memcached:
[root@localhost/]# telnet 192.168.141.64 12000
Trying 192.168.141.64 ...
Connected to 192.168.141.64 (192.168.141.64).
Escape character is ' ^] '.
Set Key1 0 60 4
Zhou
STORED
Get Key1
VALUE Key1 0 4
Zhou
End
This memcached installation is successful!
Problems:
1. If you start the memcached service, you encounter
/usr/local/bin/memcached:error while loading shared libraries:libevent-1.2.so.1:cannot open shared object File:no such file or directory;
Solution:
[Root@localhost bin]# ld_debug=libs memcached-v
[Root@localhost bin]# ln-s/usr/lib/libevent-1.2.so.1/usr/lib64/libevent-1.2.so.1
[Root@localhost bin]#/usr/local/bin/memcached-d-M 100-u root-p 12000-c 1000-p/tmp/memcached.pid
[Root@localhost bin]# Ps-aux
You can see the memcached service started.
2. Load the memcached service into the Linux startup entry. In case the machine loses power and the system reboots. Then the memcached will start automatically.
If the server-side command that starts the memcache is:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid
If you want to start up automatically, just add one line to the/etc/rc.d/rc.local and the following command
/usr/local/memcached/bin/memcached-d-M 10-p 12000-u apache-c 256
There are some things to refer to: That is, the IP is not specified, the default is this machine, the user: the best choice is: Apache or Deamon
In this way, which user is the service, by which user to start.