Installation of memcached (server, client)

Source: Internet
Author: User

Disclaimer: This article is based on the article on the Web (90%), the basic is to put my installation steps to write, encountered problems recorded

1, background: The project needs more than server load balancing, our application has paid members, can not let an account random landing, a time period can only one account, which involves several independent Web reference sharing session,

2, Program: 1) tomat its own configuration, realize the session sharing, disadvantage: Each tomcat is a full session, performance is the bottleneck

2) Find the Distributed Cache tool (Ehcahe, memcached, etc.), and finally determine the use of memcache, the reason is: the director, these tools are useless

3, Environment: The current test environment:

Server side: Lenovo's T100 G11,centos 6.4 64-bit, memcached-1.4.22

Client side: None (not yet installed there)

4, server-side installation (network reference, here copy, original address: http://www.cnblogs.com/zgx/archive/2011/08/10/2134097.html):

Download and install the Memcache server side
Server side is mainly installed Memcache server side.
Download: http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz
In addition, Memcache used the libevent this library for socket processing, so you also need to install the latest version of Libevent,libevent is libevent-1.3. (If your system already has libevent installed, you can not install it)
Official website: http://www.monkey.org/~provos/libevent/
Download: http://www.monkey.org/~provos/libevent-1.3.tar.gz

The

uses the wget directive to download these two items directly. After downloading back to the source file.
1. Install Libevent first. This thing needs to be configured with an installation path, i.e../configure–prefix=/usr; then make; then make install;
2. Install the memcached, just need to specify the installation path of libevent when configuring ./configure–with-libevent=/usr; then make; then make install;
This completes the installation of Linux under Memcache server. The detailed method is as follows:

1. Download memcached and libevent, and put them in the/tmp directory: # 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.gz2. First install libevent:# tar zxvf libevent-1.2.tar.gz# cd libevent-1.2# ./configure–prefix=/usr# make# make install this may go wrong (./configure-prefix=/usr this step), indicating GCC and other error errors, this is the GCC library is not installed Yum Install GCC If you have Yum prompt all the mirror error, to see if your DNS is set to succeed, Ping www.baidu.com test, appear unknown explain your DNS error refer to my other article http// WWW.CNBLOGS.COM/AISHANGYIZHIHU/P/4233251.HTML3. Test whether the libevent was installed successfully: # Ls-al/usr/lib | grep libeventlrwxrwxrwx 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.lalrwxrwxrwx 1 root root 21 11?? 17:38 libevent.so-libevent-1.2.so.1.0.3 is also good, all installed. 4. Install the memcached, and you need to install the installation location of the specified libevent: # 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 carefully check the errors and configure or add the appropriate libraries or paths according to the error message. When the installation is complete, the memcached will be put into/usr/local/bin/memcached, 5. Test for successful installation memcached:# 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 start memcached Service: 1. Start the server side of the Memcache: #/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/ Memcached.pidd option is to start a daemon,-M is allocated to memcache use the amount of memory, the unit is MB, I here is 10mb,-u is running memcache user, I here is root,-l is listening to the server IP address, if there are multiple addresses, I specify the service here IP address 192.168.0.200,-p is set memcache listening port, I set up here 12000, preferably more than 1024 of the port, the-C option is the maximum number of concurrent connections, the default is 1024, I set up here 256, according to your server load amount to set,-P is set to save me Mcache pid file, I am here to save in/tmp/memcached.pid,2. If you want to end the memcache process, execute: # kill ' Cat/tmp/memcached.pid ' can also start multiple daemons, but the ports cannot be duplicated. Test memcached:[[email protected]/]# telnet 192.168.141.64 12000 to memcached installation success! FAQ: 1. If the memcached service is started Usr/local/bin/memcached:error while loading shared libraries:libevent-1.2.so.1:cannot open sHared object File:no such file or directory; solution: [[email protected] bin]# ld_debug=libs memcached-v [[EMAIL PR] Otected] bin]# ln-s/usr/lib/libevent-1.2.so.1/usr/lib64/libevent-1.2.so.1[[email protected] bin]#/usr/local/ Bin/memcached-d-M 100-u root-p 12000-c 1000-p/tmp/memcached.pid[[email protected] bin]# ps-aux2. Add the memcached service Boot to Linux. In case the machine is powered down, the system restarts. Then memcached will start automatically. If the command to start Memcache server is: #/usr/local/bin/memcached-d-M 10-u root-l 192.168.141.64-p 12000-c 256-p/tmp/memcached.pid want to boot automatically, just add a row in/etc/rc.d/rc.local, the following command/usr/local/memcached/ Bin/memcached-d-M 10-p 12000-u apache-c 256 above Some things can refer to: That is, IP is not specified, the default is the local, users: the best choice is: Apache or Deamon This, that is, which user's service, by which user Start.

Not to be continued ...

Installation of memcached (server, client)

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.