Download and install the Memcache server side
Server side is mainly installed Memcache server side.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used the libevent this library for socket processing, so you also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system already has libevent installed, you can not 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.
1. Install Libevent first. This thing needs to be configured with an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Install the memcached again, just need to specify the installation path of libevent when configuring the./configure–with-libevent=/usr; then make; then make install;
This completes the installation of Linux under the Memcache server side. The detailed methods are 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 http://www.monkey.org/~provos/libevent-1.2.tar.gz
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
Good, all installed.
4. Install the memcached and require the installation location of the specified libevent in the installation:
# 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 carefully check the errors, follow the error message to configure or add the appropriate library or path.
When the installation is complete, the memcached will be put into/usr/local/bin/memcached,
5. Test whether the memcached is installed successfully:
# 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
To start the memcached service :
1. Start the server side of the memcache:
#/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'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,
-P is the port that sets Memcache listening, I set here 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 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,
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:
[[Email protected]/]#Telnet192.168.141.6412000
Trying192.168.141.64...
Connected to192.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 encounter a memcached service when you start the
/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:
[[email protected] bin]#Ld_debug=Libs Memcached-v
[[email protected] bin]#Ln-s/Usr/Lib/libevent-1.2.So.1/Usr/Lib64/libevent-1.2.So.1
[[email protected] bin]#/usr/local/bin/memcached -d -m 100 -u root - P 12000 -c 1000 -p /< Span style= "color: #000000;" >tmp/memcached.pid
[[Email protected] bin]# ps -aux
You can see the memcached service started.
2. Load the memcached service into the Linux startup item. In case the machine loses power, the system restarts. Then memcached will start automatically.
If the server-side command to start Memcache is:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid capacity from 17jquery
If you want to start the boot automatically, just add a line in the/etc/rc.d/rc.local, 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, IP is not specified when the default is the local, users: the best choice is: Apache or Deamon
This is the service that belongs to which user and which user starts it.
Principle and scheme of distributed system design