Install Memcache in Linux

Source: Internet
Author: User

Because the libevent class library is required for installing memcached, install libevent first.

Libevent download URL: http://www.monkey.org /~ Provos/libevent/

The installation steps for the libevent-1.4.8-stable.tar.gz version downloaded in this manual are as follows:

1. Extract

Tar xzfv libevent-1.4.8-stable.tar.gz

2. Go to the libevent-1.4.8-stable directory

Cd libevent-1.4.8-stable

3. Compile and install

./Configure

Make

Make install

Note: the/usr/local/lib/directory is installed by default.

Next, install memcached

Memcached download URL: http://www.danga.com/memcached/download.bml

The memcached-1.2.6.tar.gz version is downloaded in this manual

The installation procedure is as follows:

1. Extract

Tar xzfv memcached-1.2.6.tar.gz

2. Go to the memcached-1.2.6 directory

Cd memcached-1.2.6

3. Compile and install

./Configure -- prefix =/local/memcached

Make

Make install

After the installation is complete, the bin and share directories will appear in/local/memcached.

Run the bin directory to start memcache.

The method is as follows:

./Memcached-d-u nobody-m 512 127.0.0.1-p 11211

An exception is reported.

Error while loading shared libraries: libevent-1.4.so.2: cannot open shared object file: No such file or directory

The reason is that the libevent-1.4.so.2 class library cannot be found, the solution is as follows:

Use LD_DEBUG = help./memcached-v to determine the path of the loaded class library. The method is as follows:

LD_DEBUG = libs./memcached-v 2> & 1>/dev/null | less

The system displays:

Linux:/local/memcached/bin # LD_DEBUG = libs./memcached-v 2> & 1>/dev/null | less

20421: find library = libevent-1.4. so. 2; searching

20421: search cache =/etc/ld. so. cache

20421: search path =/lib/tls/i686/sse2:/lib/tls/i686:/lib/tls/sse2:/lib/tls:/lib/i686/sse2: /lib/i686:/lib/sse2:/lib:/usr/lib/tls/i686

/Sse2:/usr/lib/tls/i686:/usr/lib/tls/sse2:/usr/lib/tls:/usr/lib/i686/sse2: /usr/lib/i686:/usr/lib/sse2:/usr/lib (system search path)

20421: trying file =/lib/tls/i686/sse2/libevent-1.4. so. 2

20421: trying file =/lib/tls/i686/libevent-1.4. so. 2

20421: trying file =/lib/tls/sse2/libevent-1.4. so. 2

20421: trying file =/lib/tls/libevent-1.4. so. 2

20421: trying file =/lib/i686/sse2/libevent-1.4. so. 2

20421: trying file =/lib/i686/libevent-1.4. so. 2

20421: trying file =/lib/sse2/libevent-1.4. so. 2

20421: trying file =/lib/libevent-1.4. so. 2

20421: trying file =/usr/lib/tls/i686/sse2/libevent-1.4. so. 2

20421: trying file =/usr/lib/tls/i686/libevent-1.4. so. 2

20421: trying file =/usr/lib/tls/sse2/libevent-1.4. so. 2

20421: trying file =/usr/lib/tls/libevent-1.4. so. 2

20421: trying file =/usr/lib/i686/sse2/libevent-1.4. so. 2

20421: trying file =/usr/lib/i686/libevent-1.4. so. 2

20421: trying file =/usr/lib/sse2/libevent-1.4. so. 2

20421: trying file =/usr/lib/libevent-1.4. so. 2

20421:

./Memcached: error while loading shared libraries: libevent-1.4. so. 2: cannot open shared object file: No such file or directory

We can see that memcached will be found in many places, so based on other requirements, we only need to create a soft link and specify it to the class library we have installed.

The method is as follows:

Ln-s/usr/local/lib/libevent-1.4.so.2/lib/libevent-1.4.so. 2

Now memcached can be started normally.

./Memcached-d-u nobody-m 512 127.0.0.1-p 11211

Here, we can see that memcached has been started, indicating that the installation is successful.

To end the Memcache process, run:

# Kill 'cat/tmp/memcached. Pi'

You can also start multiple daemon processes, but the ports cannot be repeated.

Memcache startup parameters:

-D option is to start a daemon,

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

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

-L is the IP address of the listening server. If there are multiple IP addresses, I have specified the IP address 192.168.0.200,

-P is the port for Memcache listening. I have set port 12000 here, preferably port 1024 or above,

-The "c" option is the maximum number of concurrent connections. The default value is 1024. I have set 256 here, which is based on the load of your server,

-P is the pid file for saving Memcache. Here I am saving it in/tmp/memcached. pid
 

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.