Install using Memcache on a Linux server

Source: Internet
Author: User
Server side is mainly installed Memcache server side, the latest version is memcached-1.3.0.

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.
1. Install Libevent first. This thing needs to be configured to specify an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Reinstall the memcached, just need to specify the Libevent installation path in the configuration, that is./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:

The code is as follows:

# 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:

The code is as follows:

# 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:

The code is as follows:

# 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

It's all right, it's all set up.
4. Install memcached, also need to install the designated Libevent installation location:

The code is as follows:

# 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 in the/usr/local/bin/memcached,
5. Test for successful installation of memcached:

The code is as follows:

# 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

Basic use
To view the current number of memcache connections:

The code is as follows:

[Root@mem1 ~]# Netstat-n | grep:11211 | Wc-l

15752

To view the number of connections that are allowed by default:

The code is as follows:

[Root@mem1 ~]# cat/etc/rc.local

#!/bin/sh
#
# This script would be executed *after* all the other init scripts.
# You can put your own initialization stuff with If you don ' t
# want to does the full Sys V style init stuff.

Touch/var/lock/subsys/local
/usr/local/bin/memcached-d-M 15360-u root-l 172.20.1.54-p 11211-c 40960
/usr/local/bin/memcached-d-M 512-u root-l 172.20.1.54-p 11212-c 10000

The 11211-Port default connection number set here is 40960

On the web, Memcache also has its own viewing tools:
How to view the Memcache server-side version:./memcached-h
The running state of the memcache can be easily displayed with the stats command.
First connect memcache with a command such as Telnet 127.0.0.1 11211, and then enter stats directly to get the status of the current memcache.
These states are described as follows:

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.