Install the memcache server in Linux

Source: Internet
Author: User

Memcache uses the libevent library for socket processing, so you also need to install libevent, the latest version of libevent is the libevent-1.3. (If your system has already installed libevent, you do not need to install it)

 
Use the wget command to directly download these two items.
1. Install libevent first. During configuration, You need to specify an installation path, that is,./configure-Prefix =/usr; then make install;

2. Install memcached again. You only need to specify the installation path of libevent during configuration, that is,./configure-with-libevent =/usr; then make install;

This completes the installation of the memcache server in Linux. The detailed method is as follows:

1. Download memcached and libevent respectively and put them in the/tmp directory:

Java code
  1. # Cd/tmp
  2. # Wget http://www.danga.com/memcached/dist/memcached-1.4.12.tar.gz
  3. # Wget http://www.monkey.org /~ Provos/libevent-1.4.12-stable.tar.gz

 

 

2. Install libevent first:

Java code
  1. # Tar zxvf libevent-1.4.12-stable.tar.gz
  2. # Cd libevent-1.4.12
  3. #./Configure -- prefix =/usr
  4. # Make
  5. # Make install 4. Install memcached and specify the installation location of libevent in installation: Java code
    1. # Cd/tmp
    2. # Tar zxvf memcached-1.4.4.tar.gz
    3. # Cd memcached-1.4.4
    4. #./Configure-with-libevent =/usr or./configure -- prefix =/usr/local/memcached
    5. # Make
    6. # Make install
        

    If an error is reported in the middle, check the error information carefully and configure or add the corresponding library or path according to the error information.
    After the installation is complete, memcached will be put into the basic settings of/usr/local/bin/memcached and memcached:
    1. Start the memcache server: Create a start_memcache.sh script with the following content:

    1. #/Usr/local/bin/memcached-D-M 10-u root-l 192.168.0.200-P 12000-C 256-P/tmp/memcached. PID
    # /usr/local/bin/memcached -d -m 10 -u root -l 192.168.0.200 -p 12000 -c 256 -P /tmp/memcached.pid

    -D option is to start a daemon,
    -M indicates the amount of memory allocated to memcache. The unit is mb. Here I am 10 MB,
    -U is the user who runs memcache. Here I am root,
    -L is the IP address of the listening server. If there are multiple IP addresses, I have specified the IP address 192.168.0.200,
    -P is the port for memcache listening. I have set port 12000 here, preferably port 1024 or above,
    -The "C" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,
    -P is the PID file for saving memcache. Here I save it in/tmp/memcached. PID,

    2. to end the memcache process, run:

    Java code
    1. # Kill 'cat/tmp/memcached. Pi'
     # kill `cat /tmp/memcached.pid`

    You can also start multiple daemon processes, but the ports cannot be repeated.

    Or

    After the installation, start memcached and allocate 32 MB of memory (32 indicates the number of memory used, which can be modified as needed)
    /Usr/local/memcached/bin/memcached-D-M 32-l 127.0.0.1-P 11211-u Root

    Add memcached to the startup Item
    # Vi/etc/rc. d/rc. Local

     

    Press I on the disk to start editing.

    Add at last

    /Usr/local/memcached/bin/memcached-D-M 32-l 127.0.0.1-P 11211-u Root

     

    Press ESC and then enter

    : WQ

    Save and exit

    If needed, you can reboot it, but it should have taken effect without reboot ~

 

What are the common methods to clear memcache items? Killing and restarting? What if I need to restart n apsaradb for memcache instances? One by one?

For example, if memcached runs on the local port 11211, run the following command:

$ echo ”flush_all” | nc localhost 11211

Note: flush does not delete items, but marks all items as expired.

 

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.