Installing memcached steps on Linux

Source: Internet
Author: User
Tags memcached

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
    1. Rpm-qa|grep libevent

If installed, view the installation path of the libevent, which is required for subsequent installations.

Shell Code
    1. RPM-QL libevent

If it is not installed, install Libevent first

Install Libevent:

1. First download the Libevent installation package

Shell Code
    1. wget http://www.monkey.org/~provos/libevent-1.4. 12-stable.tar.gz

2. Unzip the installation package

Shell Code
    1. Tar zxvf libevent-1.4. 12-stable.tar.gz-c/usr/local/

3. Enter the extracted directory

Shell Code
    1. CD libevent-1.4. 12-stable/

4. Configuring compilation, Installation

Shell Code
    1. ./configure-prefix=/usr/libevent
    2. Make
    3. 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
    1. wget http://memcached.googlecode.com/files/memcached-1.4. 15.tar.gz

2. Modify the Execute operation permissions for the installation package

Shell Code
    1. chmod 777 memcached-1.4. 15.tar.gz

3. Unzip the installation package to the specified directory

Shell Code
    1. Tar zxvf memcached-1.4. 15.tar.gz-c/usr/local

4. Enter the extracted directory

Shell Code
    1. 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
    1. ./configure-with-libevent=/usr/libevent/-prefix=/usr/local/memcached
    2. Make
    3. Make install

6. After the installation is successful, start to see if the installation is successful

Shell Code
    1. /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
  1. #!/bin/sh
  2. Echo "Start to start memcached Server $ (date) ..."
  3. Memcached=/usr/local/memcached/bin/memcached
  4. Usage ()
  5. {
  6. echo "Usage: ' basename ' Port"
  7. }
  8. If [-N "$" ]
  9. Then
  10. {
  11. Pid= ' PS aux|grep memcached|grep "$ |grep-v grep|awk ' {print $} '
  12. If [-N "$pid"]
  13. Then
  14. {
  15. Sleep 2
  16. echo "Kill memcached which Port is" begin "
  17. echo "pid: $pid"
  18. Kill-9 $pid
  19. echo "Kill memcached which port is $ end"
  20. Sleep 2
  21. }
  22. Fi
  23. echo "begin to start memcached in Port $"
  24. log_file=/var/log/memcached/memcached_$1.log
  25. Rm-f $LOG _file
  26. $MEMCACHED-D-M 2048-p $1-u root-vv >> $LOG _file 2>&1
  27. Echo "Start memcached End"
  28. Tail-f $LOG _file
  29. }
  30. Else
  31. {
  32. Usage
  33. Exit 1
  34. }
  35. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.