Memcached and memcache extension Installation

Source: Internet
Author: User

System: centos6.3 _ x64


Memcache uses the libevent library for Socket processing, so you also need to install libevent

1) install libevent first:

Wget http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.20-stable.tar.gz

# Tar-zxvf libevent-2.0.20-stable.tar.gz

# Cd libevent-2.0.20

#./Configure -- prefix =/usr

# Make

# Make install

2) install memcached

Wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz

# Tar zxvf memcached-memcached-1.4.15.tar.gz

# Cd memcached-memcached-1.4.15

#./Configure -- prefix =/usr/local -- with-libevent =/usr

# Make

# Make install

Start memcached

#/Usr/local/bin/memcached-d-m 2048-l 172.18.1.250-p 11211-u root

-D option is to start a daemon,

-M indicates the amount of memory allocated to Memcache. The unit is MB,

-U is the user who runs Memcache. Here I am system_u,

-L is the IP address of the listener server. If there are multiple IP addresses, you can use multiple-l YOU_IP addresses.

-P is the port used to set Memcache listening, preferably over 1024,

-The c option is the maximum number of concurrent connections running. The default value is 1024, Which is set based on the load of your server,

-P is the pid file for saving Memcache.

To end the Memcache process, run:

Use # ps-e to view Processes

# Kill pid memcached process number

After running, some systems will prompt-bash: kill: pid: arguments must be process or job IDs

But you can use # ps-e to view the process. There is no memcached process.


3) install the memcache extension of PHP.

# Tar zxvf memcache-2.1.0.tgz

# Cd memcache-2.1.0

#/Usr/local/php/bin/phpize

#./Configure -- enable-memcache -- with-php-config =/usr/local/php/bin/php-config -- with-zlib-dir

# Make

# Make install

In the php. ini (vi/etc/php. ini) file, add:

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20060613 /"

Extension = memcache. so

Session. cookie_lifetime = 86400

Session. gc_maxlife time = 86400

Session. save_handler = memcache

Session. save_path = "tcp: // 192.168.20.243: 11211, tcp: // 192.168.20.244: 11211"

Start memcached

Restart apache


Advantages and disadvantages:

Memcached implements memory space allocation and recovery, as well as storage service monitoring and provision. distributed implementation depends on the use and construction of the client. the client we use fully supports distributed. but some problems may occur.

For example, if a network problem occurs and one of the distributed servers loses contact, the data written to the distributed server cannot be obtained during the period when the server resumes normal operation. the Distributed hash table can be used to solve this problem.



Related Article

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.