Assembly of memcached and new php client memcached (reference)

Source: Internet
Author: User
Tags php memcached
Install memcached and the new php client memcached (refer to) 2010-02-2311: 05web2. 0 is different from web1.0. web1.0 is content-centered. Therefore, web1.0 only needs to cache content for load. using reverse proxy to cache pages can solve most of the problems. Web encourages user interaction, and the content is dynamic. if only reverse proxy is used, the medium rate is low, and memcached, a new php client, are installed frequently on the database. (refer)
2010-02-23 11: 05web2. 0 is different from web1.0. web1.0 is content-centered. Therefore, web1.0 only needs to cache content for load. using reverse proxy to cache pages can solve most of the problems. Web encourages user interaction, and the content is dynamic. if only reverse proxy is used, the rate is low, and the database is frequently written, which puts a lot of pressure on the database. Therefore, web2.0 needs to use the memory cache for web1.0. Memcached's high-performance, distributed memory object cache system reduces database load in Dynamic Applications and improves access speed. Memcached has been widely used in a variety of software, such as nginx, mysql 1, server installation and use weget to download libevent and memcachedlibevent: http://monkey.org/~provos/libevent-1.4.9-stable.tar.gzmemcached : http://www.danga.com/memcached/dist/memcached-1.2.6.tar.gz1 . First install libeventtar zxvf libevent-1.4.9-stable.tar.gz cd libevent-1.4.9-stable. /configure make install tar zxvf libevent-1.4.9-stable.tar.gz cd libevent-1.4.9-stable. /configuremakemake install2. install memcachedtar zxvf memcached-1.2.6.tar.gz cd memcached-1.2.6. /configure -- enable-threads make install tar zxvf memcached-1.2.6.tar.gzcd. /configure -- enable-threadsmakemake install note: if information such as "memcached: error while loading shared libraries: libevent-1.4.so.2: cannot openshared object file: No such file or directory" appears at startup, it indicates that memcached cannot find the libevent location. Therefore, use whereis libevent to obtain the location, and connect to the [root @ localhost tools] # whereis libevent: /usr/local/lib/libevent. la/usr/local/lib/libevent. so/usr/local/lib/libevent. a [root @ localhost tools] # LD_DEBUG = libs memcached-v 2> & 1>/dev/null | less [root @ localhost tools] # ln-s/usr/local/ lib/libevent-1.4.so.2/lib64/2, php installation of memcached support php has two versions of memcached client 1. memcached is a new version of client based on libmemcached. Therefore, libmemcached must be installed first: http://download.tangent.org/libmemcached-0.26.tar.gz [Root @ localhost tools] # tar zxvf libmemcached-0.26.tar.gz [root @ localhost tools] # cd libmemcached-0.26 [root @ localhost libmemcached-0.26] #. /configure -- prefix =/usr/local/libmemcached/-- with-libmemcached-dir =/usr/local/libmemcached/[root @ localhost libmemcached-0.26] # make [root @ localhost libmemcached-0.26] # make install [root @ localhost tools] # tar zxvf libmemcached-0.26.tar.gz [root @ localhost tools] # cd libmemcached-0.26 [root @ localhost libmemcached-0.26] #. /configure -- prefix =/usr/local/libmemcached/-- with-libmemcached-dir =/usr/local/libmemcached/[root @ localhost libmemcached-0.26] # make [root @ localhost libmemcached-0.26] # make install php memcached and the latest client: http://pecl.php.net/get/memcached [Root @ localhost tools] # tar zxvf memcached-0.1.4.tgz [root @ localhost tools] # cd memcached-0.1.4 [root @ localhost memcached-0.1.4] #. /configure -- with-php-config =/usr/local/php/bin/php-config -- with-libmemcached-dir =/usr/local/libmemcached/[root @ localhost memcached-0.1.4] # make [root @ localhost memcached-0.1.4] # make install [root @ localhost tools] # tar zxvf memcached-0.1.4.tgz [root @ localhost tools] # Cd memcached-0.1.4 [root @ localhost memcached-0.1.4] #. /configure -- with-php-config =/usr/local/php/bin/php-config -- with-libmemcached-dir =/usr/local/libmemcached/[root @ localhost memcached-0.1.4] # make [root @ localhost memcached-0.1.4] # make install modify php. add extension = "memcached. so. 1. checking for libmemcached location... configure: error: memcached support requires libmemcached. Use -- with-libmemcached-dir =
 
  
To specify the prefix where libmemcached headers and library are located checking for libmemcached location... configure: error: memcached support requires libmemcached. Use -- with-libmemcached-dir =
  
   
To specify the prefix where libmemcached headers and library are located, first use whereis libmemcached to find the path, and then add the option -- with-libmemcached-dir = libmemcached path 2. memcache: http://pecl.php.net/get/memcache [Root @ localhost tools] # tar zxvf memcache-3.0.3.tgz [root @ localhost tools] # cd memcache-3.0.3 [root @ localhost tools] #/usr/local/php/bin/phpize [root @ localhost tools] #. /configure -- with-php-config =/usr/local/php/bin/php-config [root @ localhost tools] # make [root @ localhost tools] # make install [root @ localhost tools] # tar zxvf memcache-3.0.3.tgz [root @ localhost tools] # cd memcache-3.0.3 [root @ localhos T tools] #/usr/local/php/bin/phpize [root @ localhost tools] #. /configure -- with-php-config =/usr/local/php/bin/php-config [root @ localhost tools] # make [root @ localhost tools] # make install modify php. add extension = "memcache. so. Tip: If the so file cannot be found in php, set extension_dir. Ps: This article has been in the draft box for a long time. Finally, I decided to write more articles. it seems much faster. Source: http://willko.iteye.com/blog/332993NetSeek (11:16:40) when the memcached client libmemcached processes data with a value greater than 8 K, the speed will decrease linearly. http://lists.tangent.org/piperma ... Ovember/000484.html, you can find the answer because the buf of libmemcached is too small. find the source file memcached_constants.h, modify # define MEMCACHED_MAX_BUFFER 8196, change it to a proper size, re-compile, and install it. libmemcached is the interface of the C client library to the memcached server. It is designed for light memory usage, thread security, and provides methods to fully obtain the server. It also uses a variety of command line tools: memcat, memflush, memrm, memstat, and memslap (load generation ). The library has been designed to enable different hash methods to pair keys, split keys, and use uniform hash distribution. License: BSD license (revision) change: key to decreasing the amendment. The corrected assertion is the host_reset () called by memset (). Fixed an issue where the blocked I/O has been removed from stacks. Add memstat. A new method for flushing APIs. Simple use of memcached this is an article of the nature of engineering applications: memcached is a tool for fast data access, and wikipedia and facebook use it to increase the speed. For more information, see Wikipedia. using memcached in c/c ++ is simple, but no one has to say that I have to read the libmemcache instance code, manpage is not clear (but you have to check it ). To use memcached, follow these steps: 1. to install memcached, you can download it from the official website or sudo apt-get install memcached2 to test your installation, for example, running memcached-d-m 64-l 127.0.0.1-p 12300-d indicates the background,-m 64 indicates that 64 MB memory is used, and-l 127.0.0.1-p 12300 indicates listening 127.0.0.1: if there is no message on port 12300, it means it runs successfully. 3. if libmemcached is installed, do not use apt. because there is no precise libmemcached package, please download it from the official website. Libevent is also required for this item, which cannot be apt. it is best to install libevent in/usr/lib, otherwise libmemcached cannot run. 4. test libmemcached to find a file such as test, and then run memcp test -- servers = 127.0.0.1: 12300 to copy the test to the memory managed by memcached. Memcat test -- servers = 127.0.0.1: 12300. check if the file is the one you just created.
  
 

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.