http://chenzhou123520.iteye.com/blog/1933489
http://chenzhou123520.iteye.com/blog/1925209
Recently installed on the company server memcached a lot of times, every time you have to go online to check the steps, today simply write a detailed step to record, stay as a memo.
First, check the Libevent
First check if Libevent is installed in the system.
Shell Code
- Rpm-qa|grep libevent
If installed, view the installation path of the libevent, which is required for subsequent installations.
Shell Code
- RPM-QL libevent
If it is not installed, install Libevent first
Install Libevent:
1. First download the Libevent installation package
Shell Code
- wget http://www.monkey.org/~provos/libevent-1.4. 12-stable.tar.gz
2. Unzip the installation package
Shell Code
- Tar zxvf libevent-1.4. 12-stable.tar.gz-c/usr/local/
3. Enter the extracted directory
Shell Code
- CD libevent-1.4. 12-stable/
4. Configuring compilation, Installation
Shell Code
- ./configure-prefix=/usr/libevent
- Make
- Make install
After installing libevent, in order for the dynamic link library to be shared with the system, you need to perform the following management commands for the dynamic link library ldconfig
However, you need to be aware of the following Libevent installation directories before executing the ldconfig command. See also: http://chenzhou123520.iteye.com/blog/1925196
After installing Libevent, the installation of memcached is officially started.
1. First, download the memcached installation package
Shell Code
- wget http://memcached.googlecode.com/files/memcached-1.4. 15.tar.gz
2. Modify the Execute operation permissions for the installation package
Shell Code
- chmod 777 memcached-1.4. 15.tar.gz
3. Unzip the installation package to the specified directory
Shell Code
- Tar zxvf memcached-1.4. 15.tar.gz-c/usr/local
4. Enter the extracted directory
Shell Code
- cd/usr/local/memcached-1.4. 15/
5. Configuring, Compiling, installing
Note: You need to specify the installation path of libevent when configure
Shell Code
- ./configure-with-libevent=/usr/libevent/-prefix=/usr/local/memcached
- Make
- Make install
6. After the installation is successful, start to see if the installation is successful
Shell Code
- /usr/local/memcached/bin/memcached-d-M 2048-p 11211-u root
The startup parameters are described below:
The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, 10MB,
-U is the user running memcache, this is root,
-L is the server IP address of the listener, if there are multiple addresses, this specifies the IP address of the server 192.168.0.200,
-P is the port that sets Memcache listening, which is set to 12000, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, where 256 is set, according to the server load,
-P is set to save memcache pid file, I here is saved in/tmp/memcached.pid, can also start multiple daemons, but the port can not be duplicated.
If you want to configure the log on memcached, see: http://chenzhou123520.iteye.com/blog/1925209
PS: Attach a memcached startup shell script
Shell Code
- #!/bin/sh
- Echo "Start to start memcached Server $ (date) ..."
- Memcached=/usr/local/memcached/bin/memcached
- Usage ()
- {
- echo "Usage: ' basename ' Port"
- }
- If [-N "$" ]
- Then
- {
- Pid= ' PS aux|grep memcached|grep "$ |grep-v grep|awk ' {print $} '
- If [-N "$pid"]
- Then
- {
- Sleep 2
- echo "Kill memcached which Port is" begin "
- echo "pid: $pid"
- Kill-9 $pid
- echo "Kill memcached which port is $ end"
- Sleep 2
- }
- Fi
- echo "begin to start memcached in Port $"
- log_file=/var/log/memcached/memcached_$1.log
- Rm-f $LOG _file
- $MEMCACHED-D-M 2048-p $1-u root-vv >> $LOG _file 2>&1
- Echo "Start memcached End"
- Tail-f $LOG _file
- }
- Else
- {
- Usage
- Exit 1
- }
- Fi
Name the script startup.sh
Execution:./startup.sh 11211
Where 11211 is the boot port of memcached, or it can be started by a custom port
View version:./memcached-h or:
[Email protected] ~]# telnet 127.0.0.1 11211 Trying 127.0.0.1 ... Connected to 127.0.0.1. Escape character is ' ^] '. Stats
Installing memcached steps on Linux