Installation of memcached

Source: Internet
Author: User

Installation of memcached

1. Install libevent
Libevent is an event-triggered network library for a variety of platforms such as Windows, Linux, BSD, and other systems that use Select, Epoll, and kqueue to manage event mechanisms internally. Memcached is also libevent based, and libevent can be used on the cross-platform, and according to the official website of the Libevent published data statistics, it seems to have extraordinary performance.
The Libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor Or after a timeout has been reached. Furthermore, Libevent also support callbacks due to signals or regular timeouts.
Libevent is meant to replace the event loop found in event driven network servers. An application just needs to call Event_dispatch () and then add or remove events dynamically without have to change the Event loop.
You need to install libevent,:http://libevent.org/
[[email protected] home]# tar zxvf before installing memcached Libevent-2.0.21-stable.tar.gz
[[email protected] home]# cd libevent-2.0.21-stable
[[email  Protected] libevent-2.0.21-stable]#/configure
[[email protected] libevent-2.0.21-stable] #make && Make install

2. Install memcached
: http://memcached.org/
[[email protected] home]# tar zxvf memcached-1.4.15.tar.gz
[ [email protected] home]# cd memcached-1.4.15
[[email protected] memcached-1.4.15]#./configure
[[ Email protected] memcached-1.4.15]# make && make install
After the installation is complete, the default installation directory for memcached is/usr/local/bin/ memcached

3. Start memcached
[[email protected] run]#/usr/local/bin/memcached-m 32m-p 11211-d-u root-p/var/run/memcached.pid-c 256
The following error may occur at startup:
[[email protected] run]#/usr/local/bin/memcached-m 32m-p 11211-d-u root-p/var/run/memcached.pid-c 256
/usr/local/bin/memcached:error while loading shared libraries:libevent-2.0.so.5:cannot open shared object File:no such File or directory
Tip The libevent-2.0.so.5 file cannot be found, the solution is to put/usr/local/lib
Added to/etc/ld.so.conf, the/etc/ld.so.conf store is the directory where the dynamic libraries that you want to read into the cache are located, as follows:
[Email protected] run]# echo "/usr/local/lib" >>/etc/ld.so.conf
[[email protected] run]# ldconfig #利用ldconfig这个可执行文件将/etc/ld.so.conf data is read into the cache,
[[email protected] script]# ldconfig-p|grep libevent-2.0.so.5 #ldconfig-P View the Libevent-2.0.so.5 library has been read into the cache.
Libevent-2.0.so.5 (LIBC6) =/usr/local/lib/libevent-2.0.so.5
Start Process parameter Description:

-P: Use a TCP port. The default is 11211.
-M: the maximum memory size. The default is 64M.
-VV: Starts in very vrebose mode, outputting debugging information and errors to the console.
-D: Run as daemon in the background.
-C: The maximum number of concurrent connections to run, default is 1024, according to the server load amount to set.
-P: Sets the PID file to save memcached.
-L: Listens for the server IP address if there are multiple addresses.
-U: The user running memcached, by default, cannot be started by the root user, so the current user must be root with the-u parameter to specify.
All available options can be displayed through the/usr/local/bin/memcached-h command:
[Email protected] run]#/usr/local/bin/memcached-h
Memcached 1.4.15
-P <num> TCP port number to listen on (default:11211)
-U <num> UDP port number to listen on (default:11211, 0 is off)
-S <file> UNIX socket path to listen on (disables network support)
-A <mask> access mask for UNIX sockets, in octal (default:0700)
-L <addr> interface to listen in (Default:inaddr_any, all addresses)
<addr> may specified as Host:port. If you don ' t specify
A port number, the value of specified With-p or-u is
Used. Specify multiple addresses separated by comma
or by using-l multiple times
-D Run as a daemon
-R Maximize Core file limit
-U <username> assume identity of <username> (only if run as root)
-M <num> max memory to use for items in megabytes (default:64 MB)
-M return error on memory exhausted (rather than removing items)
-C <num> Max simultaneous connections (default:1024)
-K Lock down all paged memory. Note that there is a
Limit on how much memory you may lock. Trying to
Allocate more than this would fail, so is sure you
Set the limit correctly for the user started
The daemon with (not for-u <username> user;
Under SH This is do with ' ulimit-s-l num_kb ').
-V Verbose (print errors/warnings while in event loop)
-VV very verbose (also print client commands/reponses)
-VVV extremely verbose (also print internal state transitions)
-H Print this help and exit
-I print memcached and libevent license
-P <file> Save PID in <file>, only used with-d option
-F <factor> Chunk size growth factor (default:1.25)
-N <bytes> minimum space allocated for key+value+flags (default:48)
-L Try to use large memory pages (if available). Increasing
The memory page size could reduce the number of TLB misses
and improve the performance. In order to get large pages
From the OS, memcached'll allocate the total Item-cache
In one large chunk.
-D <char> use <char> as the delimiter between key prefixes and IDs.
This is used for Per-prefix stats reporting. The default is
":" (colon). If This option is specified, stats collection
is turned on automatically; If not and then it is turned on
By sending the ' Stats detail on ' command to the server.
-T <num> number of threads to use (Default:4)
-R Maximum Number of requests per event, limits the number of
Requests process for a given connection to prevent
Starvation (DEFAULT:20)
-c Disable use of CAS
-B Set The backlog queue limit (default:1024)
-B Binding Protocol-one of ASCII, binary, or auto (default)
-I Override the size of each slab page. Adjusts max item size
(DEFAULT:1MB, min:1k, max:128m)
-O Comma separated list of extended or experimental options
-(experimental) maxconns_fast:immediately close new
Connections if over Maxconns limit
-Hashpower:an integer multiplier for how large the hash
Table should be. Can is grown at runtime if not big enough.
Set this based on "STAT Hash_power_level" before a
Restart.

4. Close memcached

The command to close memcached is as follows:
[email protected] script]# kill ' Cat/var/run/memcached.pid ' #注意是返单引号.

5. Installing PHP extensions for Memcache

: Http://pecl.php.net/package/memcache i downloaded the memcache-2.2.7.tgz stable version
[Email protected] home]# tar zxvf memcache-2.2.7.tgz
[Email protected] home]# CD memcache-2.2.7
Execute the phpize extension installer, assuming that the path to Phpzie is/usr/local/php/bin/phpize, and that the specific path is modified according to your environment.
/usr/local/php/bin/phpize

Reference reading:

Memcached installation and startup scripts http://www.linuxidc.com/Linux/2013-07/87641.htm

Performance issues with memcached in PHP http://www.linuxidc.com/Linux/2013-06/85883.htm

Ubuntu installation memcached and command explanation http://www.linuxidc.com/Linux/2013-06/85832.htm

Installation of memcached

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.