The method of memcache installation configuration under Linux

Source: Internet
Author: User
Tags memcached zts

Installation Configuration Method One

Personal Understanding:

1. It is based on the C language Libevent library for the development of
2.Memcache is a c/s software, this software is the maintenance of memory.
3. The data is used in memory and is faster to read from memory than from the hard disk.
4. Reading memory reduces calls to I/O devices, increasing the speed of access.
5. Memory is a high-speed temporary storage of information hardware, power loss after the information will be cleared.
6. Hard disk is a low speed long-term storage of information hardware, power loss after the information will be retained.

Linux memcache server-side installation

Memcache used libevent This library for socket processing, so need to install libevent (if your system has been installed Libevent, you can not install)

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 instal;

This completes the Linux Memcache server-side installation. The detailed approach is as follows:

2. Install Libevent First:

The code is as follows Copy Code
# 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 Copy Code
# Ls-al/usr/lib | grep libevent
lrwxrwxrwx 1 root 17:38 libevent-1.2.so.1-> libevent-1.2.so.1.0.3
-rwxr-xr-x 1 root 263546 17:38 libevent-1.2.so.1.0.3
-rw-r–r–1 root root 454156 17:38 libevent.a
-rwxr-xr-x 1 root 811 17:38 libevent.la
lrwxrwxrwx 1 root 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 Copy Code
# 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 Copy Code
# ls-al/usr/local/bin/mem*
-rwxr-xr-x 1 root 137986 17:39/usr/local/bin/memcached
-rwxr-xr-x 1 root 140179 17:39/usr/local/bin/memcached-debug

Installing Memcache PHP Extensions

1. Select the Memcache version that you want to download in Http://pecl.php.net/package/memcache.

2. Install the PHP memcache extension

  code is as follows copy code
 tar vxzf Memcache-2.2.1.tgz
CD memcache-2.2.1
/usr/local/php/bin/phpize
./configure–enable-memcache– With-php-config=/usr/local/php/bin/php-config–with-zlib-dir
Make
make install
The code is as follows Copy Code

3. The above installation will have a similar hint:

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/
4. Change the Extension_dir = "./" in php.ini to

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/"
5. Add a row to load the memcache extension: extension=memcache.so

Basic Settings for memcached:
1. Start the Memcache server side:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.0.200-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 am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.0.200,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 256 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which 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.

Note: If you report memcached:error while loading shared libraries:libevent-2.0.so.5:cannot O error when starting Memcache

If the "memcached:error while loading shared Libraries:libevent-2.0.so.5:cannot" occurs at startup
Open Shared object File:no such file or directory, which means that memcached cannot find
Libevent's Location
So, first use the Whereis libevent to get the location, and then connect to the path that memcached is looking for
First Look, where's libevent?
# Whereis Libevent
Libevent:/USR/LOCAL/LIB/LIBEVENT.LA/USR/LOCAL/LIB/LIBEVENT.SO/USR/LOCAL/LIB/LIBEVENT.A
And then, look where memcached is looking for it.
# ld_debug=libs memcached-v 2>&1 >/dev/null | Less
Can see: Is/usr/lib/libevent-2.0.so.5, so, to create a soft chain
[Root@localhost tools]# ln-s/usr/local/lib/libevent-2.0.so.5/usr/lib/libevent-2.0.so.5
Start Www.111cn.net again
Close memcached:p kill memcached
Check if the memcached is running properly
#ps aux | grep memcached
#telnet localhost 11211
....
Stats
...
will display the basic information of the memcached

Installation Configuration Method Two

The code is as follows Copy Code

wget http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz

TAR-ZXVF memcached-1.4.10.tar.gz
CD memcached-1.x.x

./configure #到这一步报错了如下:
#configure: Error:libevent is required. You can get it from http://www.monkey.org/~provos/libevent/
Memcache used libevent This library for socket processing, so also need to install the latest version of Libevent,libevent is libevent-2.0. (If your system has libevent installed, you may not need to install it)
Official website: http://www.monkey.org/~provos/libevent/

It's just libevent.

The code is as follows Copy Code

wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz

Tar zxvf libevent-2.0.10-stable.tar.gz

./configure-prefix=/usr

Make &&make Install

Test whether the Libevent is installed successfully

Ls-al/usr/lib | grep libevent

Come out a big list of things, said the names installed

Next Install Memcache

The code is as follows Copy Code

./configure–with-libevent=/usr
Test whether the memcached was successfully installed

ls-al/usr/local/bin/mem*
-rwxr-xr-x 1 root root 203321 01-05 08:03/usr/local/bin/memcached

Description of Successful Installation

Basic Settings for memcached:
1. Start the Memcache server side:
#/usr/local/bin/memcached-d-M 10-u root-l 192.168.0.200-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 am 10MB here,
-U is the user running memcache, I am here root,
-L is a listening server IP address, if there are more than one address, I specify the IP address of the server 192.168.0.200,
-P is the port that sets the memcache listening, I set 12000 here, preferably 1024 or more ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set 256 here, according to the load of your server to set,
-P is set to save the Memcache pid file, which I am here to save in/tmp/memcached.pid,

2. If you want to end the memcache process, execute:

The code is as follows Copy Code

# Kill ' Cat/tmp/memcached.pid '

You can also start multiple daemons, but the ports cannot be duplicated.

3. Restart Apache,service httpd restart or nginx

Installing Memcache PHP Extensions
1. Select the Memcache version that you want to download in Http://pecl.php.net/package/memcache.
2. Install the PHP memcache extension

The code is as follows Copy Code

wget http://pecl.php.net/get/memcache-2.2.6.tgz

Tar vxzf memcache-2.2.6.tgz

CD memcache-2.2.6.tgz

/usr/local/php/bin/phpize
./configure–enable-memcache–with-php-config=/usr/local/php/bin/php-config–with-zlib-dir
Make
Make install

3. The above installation will have a similar hint:

The code is as follows Copy Code

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/

4. Change the Extension_dir = "./" in php.ini to

The code is as follows Copy Code

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-2007xxxx/"

5. Add a row to load the memcache extension: extension=memcache.so

Memcache Environment test:
Run the following PHP file, if the output is a test!, it means that the environment has been built successfully. Start to appreciate the charm of memcache!

  code is as follows copy code
<? PHP
$ MEM = new Memcache;
$mem->connect ("127.0.0.1″, 11211)";
$mem->set (' key ', ' This is a test! ', 0, 60);
$val = $mem->get (' key ');
Echo $val;
?

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.