CentOS 6.4 Installation Memcached Service

Source: Internet
Author: User
Tags cas touch command

Environment:

 CentOS 6.4

Libevent-1.4.14b-stable

memcached-1.4.21

See if Libevent is installed
[Email protected] ~]# Rpm-qa |grep libevent

First, download Memcache server side

Memcache Official website: http://memcached.org/

Libevent Official website: http://www.monkey.org/~provos/libevent/

Memcache used the libevent this library for socket processing, so you must first install Libevent.

Download

Second, installation

1, respectively, the memcached and libevent download down, put in the/tmp directory:
[Email protected]/]# cd/tmp

2, first install Libevent:
[Email protected] tmp]# tar zxvf libevent-1.4.14b-stable.tar.gz
[Email protected] libevent-1.4.14b-stable]# CD libevent-1.4.14b-stable
[Email protected] libevent-1.4.14b-stable]#./configure–prefix=/usr
[[email protected] libevent-1.4.14b-stable]# make
[[email protected] libevent-1.4.14b-stable]# make install

3. Test whether the Libevent is installed successfully:
[Email protected] libevent-1.4.14b-stable]# Ls-al/usr/lib | grep libevent

Good, all installed.

4, install memcached, also need to install in the specified Libevent installation location:
[Email protected] libevent-1.4.14b-stable]# cd/tmp
[Email protected] tmp]# tar zxvf memcached-1.4.21.tar.gz
[Email protected] tmp]# CD memcached-1.4.21
[Email protected] memcached-1.4.21]#./configure–with-libevent=/usr
[[email protected] memcached-1.4.21]# make
[[email protected] memcached-1.4.21]# make install
If there is an error in the middle, please carefully check the errors, follow the error message to configure or add the appropriate library or path.
When the installation is complete, the memcached will be placed on the/usr/local/bin/memcached

5, test whether the successful installation of memcached:

[Email protected] memcached-1.4.21]# ls-al/usr/local/bin/mem*
-rwxr-xr-x. 1 root root 340316 Dec 14:41/usr/local/bin/memcached

Third, start memcached service

1, start the server side of the memcache:
#/usr/local/bin/memcached-d-M 10-u root-l localhost-p 11211-c 256-p/tmp/memcached.pid

The-D option is to start a daemon,
-M is the amount of memory allocated to Memcache, in megabytes, I'm 10MB,
-U is the user running memcache, I am root here,
-L is the server IP address of the listener, if there are multiple addresses, I specify the server IP address 192.168.0.200,
-P is the port that sets Memcache listening, I set here 11211, preferably more than 1024 ports,
The-c option is the maximum number of concurrent connections to run, the default is 1024, I set the 256 here, according to the load of your server to set,
-P is set to save memcache 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 '

You can also start multiple daemons, but the ports cannot be duplicated.

Iv. Test memcached

This step requires the installation of Telnet, if the following steps are problematic, please refer to: http://www.cnblogs.com/yangxia-test/p/4159891.html

[[Email protected] memcached-1.4.21]# telnet localhost 11211
Trying:: 1 ...
Connected to localhost.
Escape character is ' ^] '.

This memcached installation is successful!

V. View the status of Memcached

[[Email protected] memcached-1.4.21]# telnet localhost 11211
Trying:: 1 ...
Connected to localhost.
Escape character is ' ^] '.
Stats
STAT PID 3401 The process ID of the//memcache server
STAT uptime 1481//number of seconds the server has been running
STAT time 1418368595//server current UNIX timestamp
STAT version 1.4.21//memcache version
STAT libevent 1.4.14b-stable//libevent version
STAT pointer_size 64//Current operating system pointer size (32-bit system is generally 32bit,64 is 64-bit operating system)
STAT Rusage_user 0.014997//process Cumulative User Time
STAT Rusage_system 0.022996//Process Cumulative system time
STAT curr_connections 10//The number of items currently stored by the server
STAT total_connections 12//Total number of items stored since server startup
STAT connection_structures 11//Number of connection constructs allocated by the server
STAT Reserved_fds 20
STAT cmd_get 0//get command (GET) total number of requests
STAT cmd_set 0//set command (save) The total number of requests www.2cto.com
STAT cmd_flush 0//flush command Request count
STAT cmd_touch 0//touch command Request count
STAT get_hits 0//Total hit count
STAT get_misses 0//Total number of misses
STAT delete_misses 0//delete command Miss Count
STAT delete_hits 0//delete command hit count
STAT incr_misses 0//incr command Miss Count
STAT incr_hits 0//incr command hit count
STAT decr_misses 0//DECR command Miss Count
STAT decr_hits 0//DECR command hit count
STAT cas_misses 0//cas command Miss Count
STAT cas_hits 0//cas command hit count
STAT Cas_badval 0//Use wipe count
STAT touch_hits 0//touch command Miss Count
STAT touch_misses 0//touch command hit count
STAT AUTH_CMDS 0//Number of authentication command processing
STAT auth_errors 0//Authentication failure number
STAT Bytes_read 13//Total Read bytes (number of requests bytes)
STAT Bytes_written 0//Total Bytes sent (Result byte count)
STAT limit_maxbytes 10485760//memory size allocated to Memcache (bytes)
STAT Accepting_conns 1//Whether the server has reached the maximum connection (0/1)
STAT Listen_disabled_num 0//number of failed listeners
STAT Threads 4//When the number of front-line
STAT conn_yields 0//Connection operation active Discard number
STAT Hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT Malloc_fails 0
STAT bytes 0//number of bytes currently occupied by storage
STAT Curr_items 0//Total data currently stored
STAT Total_items 0//Total number of data stored since startup
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT Evictions 0//number of items deleted for free memory (allocated to Memcache to remove old items to get space allocated to new items)
STAT reclaimed 0//Expired data entry to store the number of new data
STAT crawler_reclaimed 0
STAT lrutail_reflocked 0
END

Quit: Quit or CTRL +] and then press Q on the line.

Vi. problems encountered

1, if the start of the Memcached service encountered

/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 protected] 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-aux

You can see the memcached service started.

2. Load the memcached service into the Linux startup item. In case the machine is powered down, the system restarts. Then memcached will start automatically.

If the server-side command to start Memcache is:
#/usr/local/bin/memcached-d-M 10-u root-l localhost-p 11211-c 256-p/tmp/memcached.pid capacity from 17jquery

If you want to start the boot automatically, just add a line in the/etc/rc.d/rc.local, the following command
/usr/local/memcached/bin/memcached-d-M 10-p 11211-u apache-c 256
There are some things to refer to: That is, IP is not specified when the default is the local, users: the best choice is: Apache or Deamon
This is the service that belongs to which user and which user starts it.

CentOS 6.4 Installation Memcached Service

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.