NOSQL1 install memcached on Linux (CentOS) and use

Source: Internet
Author: User
Tags memcached

Objective:

today is the Duanwu, the basic life must return to the normal life from the New Year rhythm, therefore thinks also should think about the work related matter. I used to use memcached and Redis in my work, but I never had the time to look at the basics of this part of the system, so now I'm going to make a good view of the two parts. I will see the things hard to record down, to myself to leave a reference, if can help everyone, nature is better ~.

1. Install memcached and use on Linux (CentOS). Http://www.cnblogs.com/PurpleDream/p/4298208.html

=============================================================== Long split-line ========================================== ==========================

Body:

The first step is to determine the target:

The current environment is Linux CentOS, install memcached, and then learn the basic usage below.

The second step is to download the installation package:

Since installing libevent is a prerequisite for installing memcached, here we need to download two installation packages, namely Libevent and memcached.

1. Download libevent, I downloaded the latest version here in http://libevent.org/libevent-2.0.22-stable.tar.gz

2. Download memcached, I downloaded the latest version here in http://memcached.org/memcached-1.4.22.tar.gz

3. Upload the downloaded installation package to my Linux environment via FTP tools such as FileZilla,/myself_settings/libevent and/myself_settings/memcached directories respectively

In the third step, you are ready to install libevent and memcached in turn:

1. Use the CD command to open to/myself_settings/libevent.

2. Using the command TAR-XZVF libevent-2.0.22-stable.tar.gz, unzip the installation package and then CD to the extracted Libevent-2.0.22-stable folder.

3. We want to use the Configure command installation, the installation directory should be in the/usr/lib, for later management convenience, here I in advance in the/usr/lib file set up a new folder Libevent

4. Execute command:./configure--prefix=/usr/lib/libevent (function is configuration)

5. Execute command: Make (function is compile)

6. Execute command: Make install (function is install)

7. At this point, the libevent should be installed, and we can use the command ls-al/usr/lib/libevent/lib to see if the Libevent installation was successful.

1 drwxr-xr-x 3 root root 4096 Feb 17:06.2 drwxr-xr-x 5 root root 4096 Feb 17:06.3 lrwxrwxrwx 1 root root 17:06 libevent-2.0.so.5-libevent-2.0.so.5.1.94 -rwxr-xr-x 1 root root 975704 Feb 17:06 libevent-2.0.so.5.1.95 -rw-r--r--1 root root 1586288 Feb 17:06 libevent.a6 lrwxrwxrwx 1 root root 17:06 libevent_core-2.0.so.5-libevent_core-2.0.so.5.1.97 -rwxr-xr-x 1 root root 578875 Feb 17:06 libevent_core-2.0.so.5.1.98 -rw-r--r--1 root root 968792 Feb 17:06 libevent_core.a9 -rwxr-xr-x 1 root root 970 Feb 17:06 libevent_core.laTen lrwxrwxrwx 1 root root 17:06 libevent_core.so-libevent_core-2.0.so.5.1.9 One lrwxrwxrwx 1 root root 17:06 libevent_extra-2.0.so.5-libevent_extra-2.0.so.5.1.9 A -rwxr-xr-x 1 root root 417629 Feb 17:06 libevent_extra-2.0.so.5.1.9 - -rw-r--r--1 root root 617568 Feb 17:06 libevent_extra.a - -rwxr-xr-x 1 root root 977 Feb 17:06 libevent_extra.la the lrwxrwxrwx 1 root root 17:06 libevent_extra.so-libevent_extra-2.0.so.5.1.9 - -rwxr-xr-x 1 root root 935 Feb 17:06 libevent.la - lrwxrwxrwx 1 root root 17:06 libevent_pthreads-2.0.so.5-libevent_pthreads-2.0.so.5.1.9 - -rwxr-xr-x 1 root root 18142 Feb 17:06 libevent_pthreads-2.0.so.5.1.9 + -rw-r--r--1 root root 18806 Feb 17:06 libevent_pthreads.a - -rwxr-xr-x 1 root root 998 Feb 17:06 libevent_pthreads.la + lrwxrwxrwx 1 root root 17:06 libevent_pthreads.so-libevent_pthreads-2.0.so.5.1.9 A lrwxrwxrwx 1 root root 17:06 libevent.so-libevent-2.0.so.5.1.9 atDrwxr-xr-x 2 root root 4096 Feb 17:06 pkgconfig

8. The next thing we want to install is memcache, first of all, the same as the top processing libevent, first unpack the installation package, and then CD to the extracted memcached-1.4.22 folder.

9. Execute the command:./configure--with-libevent=/usr/lib/libevent (The role is configuration, here to note the path of the Libevent before the association is installed/usr/lib/libevent)

10. Execute command: Make (function is compile)

11. Execute Command: Make install (function is install)

12. At this point, memcached installation is complete, you can use the command ls-al/usr/local/bin/mem* to see if the memcached installed successfully.

1 -rwxr-xr-x 1 root root 325816 Feb 17:10 memcached

The fourth step, start the memcached service, the command is as follows:

1 /usr/local/bin/memcached-d-M 10-u root-l 192.168.25.26-p 14885-c 256-p/tmp/memcached.pid-vv >>/ Tmp/memcached.log 2>&1  

For the start command above, the parameters are explained in detail as follows:

-D is to start a daemon,-m is allocated to the amount of memory used by Memcache, the unit is MB, I here is 10mb,-u is running memcache user, I here is Root,-l is the server IP address of the listener, If there are more than one address, we can use commas to separate IP addresses or use multiple-l, where I specify the server's IP address 192.168.25.26,-p is set memcache listening port, I set up here 14885, preferably more than 1024 ports,-C is the maximum number of concurrent connections running, the default is 1024, I set up here 256, according to the load of your server to set,-P is set to save memcache pid file, I here is saved in/tmp/memcached.pid

If memcached starts successfully, we can use Ps-ef|grep memcached to see if it starts, as follows:

1 root     14742     1  0 18:59?        00:00:00/usr/local/bin/memcached-d-M 10-u root-l 192.168.25.26-p 14885-c 256-p/tmp/memcached.pid-vv2 6> root     14806  3537  0 19:46 pts/2    00:00:00 grep memcached

Fifth step, close the memcached service, the command is as follows:

1 kill ' Cat/tmp/memcached.pid '

Sixth step, test memcached, here are two questions to say:

1. If you have not used memcached before, you can refer to http://www.cnblogs.com/jeffwongishandsome/archive/2011/11/06/2238265.html or http:// Www.yiibai.com/memcached/memcached_clear_data.html These two articles to learn the basic commands of memcached.

2. When we test below, we will use the Telnet command, many Linux environment default is no Telnet environment, if we enter the Telnet command is likely to encounter such as-bash:telnet:command not found error, We can install the Telnet environment by using the following steps:

(1). by Rpm-qa|grep telnet and rpm-qa|grep telnet-server both commands to confirm whether to install the client and server side, in general, there will be a default client, no server side, The server that installs memcached must have Telnet-server installed.

(2). yum-y install Telnet If no client is installed, the client

(3). Yum Install telnet-server installation Server side

(4). Edit /etc/xinetd.d/telnet, change the Disable = yes to No to modify the configuration

(5). Service XINETD Restart Restart services

3. Solve the problem above, we can experiment with a set command, the parameters of the command refer to the two articles I mentioned in 1, in detail as follows:

1 [email protected]/]# telnet 192.168.25.26 148852 Trying 192.168.25.26 ...3 Connected to 192.168.25.26 (192.168.25.26).4 Escape character is ' ^] '.5 Set username 0 0 46 Hero7 STORED8 Get username9 VALUE username 0 4Ten Hero OneEND

NOSQL1 install memcached on Linux (CentOS) and use

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.