Memcached has been fire for many years, and now online about memcached Resources quite a lot, I will not waste words. Simply write a combat series, adhere to all with the implementation of speaking.
Environment Introduction
Linux virtual machines
Kernel information
[Email protected] ~]# uname-a
Linux HADOOP1 2.6.32-358.el6.i686
Memory: 1G
installation process
1. Prepare the compilation environment, install the necessary gcc,make tools, if not installed Yum, preferably installed. There are many shared Yum sources on the web.
2. Download the latest version of Libevent
# wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz
3. Unzip the libevent corresponding compression package
# tar ZXVF libevent-2.0.22-stable.tar.gz
File path after decompression:/u01/software/libevent-2.0.22-stable
3. Compiling libevent
# cd/u01/software/libevent-2.0.22-stable#./configure-prefix=/usr/local/libevent# make# make install confirm installation result # LS-AL/US R/local/lib |grep libevent
4. Download the latest version of memcached
# wget Http://memcached.org/latest
5. Unzip the memcached corresponding compression package
Tar zxvf memcached-1.4.29.tar.gz
File path after decompression:/u01/software/memcached-1.4.29
6. Compiling memcached
# cd /u01/software/memcached-1.4.29# [[email protected] memcached-1.4.29]# ./ Configure -help ' Configure ' configures memcached 1.4.29 to adapt to many kinds of systems. Usage: ./configure [option]... [var=value] ... configuration: -h, --help display this help and exit --help= Short display options specific to this package --help=recursive display the short help of all the included packages -v, --version display version information And exit -q, --quiet, --silent do not print ' checking  ... ' messages --cache-file=file cache test results in file [ disabled] -c, --config-cache alias for '-- Cache-file=config.cache ' -n, --no-create do not create output files --srcdir=dir find the sources in DIR [configure dir or ' ... ' installation directories: --prefix=prefix install architecture-independent files in PREFIX [/usr/locAl] ... fine tuning of the installation directories: --bindir=dir user executables [EPREFIX/bin] --sbindir=DIR system admin executables [eprefix/sbin] --libexecdir=dir program executables [eprefix/libexec] --sysconfdir=dir read-only single-machine data [prefix/etc] --sharedstatedir=dir modifiable architecture-independent data [prefix/com] -- Localstatedir=dir modifiable single-machine data [prefix/var] --libdir=DIR object Code libraries [eprefix/lib] --includedir=dir c header files [ Prefix/include] --oldincludedir=dir c header files for non-gcc [/usr/include] --datarootdir=DIR read-only arch.-independent data root [prefix/share] --datadir=dir read-only architecture-independent data [ Datarootdir] --infodir=dir info documentation [DATAROOTDIR/info] --localedir=DIR locale-dependent data [DATAROOTDIR/locale] --mandir=DIR man documentation [datarootdir/man] --docdir=DIR documentation root [datarootdir/doc/ Memcached] --htmldir=dir html documentation [DOCDIR] --dvidir=DIR dvi documentation [DOCDIR] --pdfdir=DIR pdf documentation [docdir] --psdir=dir ps documentation [ docdir] optional packages: --with-package[=arg] use package [arg=yes] --without-package do not use package (Same as --with-package=no) --with-libevent=PATH specify path to libevent installation # ./configure --prefix=/usr/local/ Memcached --with-libevent=/usr/local/lib/ # make # make install
This time memcached installation was successful.
Start memcached
#/usr/local/memcached/bin/memcached Error
Error while loading shared Libraries:libevent-2.0.so.5:cannot open Shared object file:no such file or directory
Solution Ideas
# #跟踪运行memcached所有加载库文件的路径
LD_DEBUG=libs LD_DEBUG=libs ./memcached -v 15862: find library=libevent-2.0.so.5 [0]; searching 15862: search cache=/etc/ld.so.cache 15862: 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) 15862: trying file=/lib/tls/i686/sse2/libevent-2.0.so.5 15862: trying file=/lib/tls/i686/libevent-2.0.so.5 15862: trying file=/lib/tls/sse2/libevent-2.0.so.5 15862: trying file=/lib/tls/libevent-2.0.so.5 15862: trying file=/lib/i686/sse2/ libevent-2.0.so.5 15862: trying file=/lib/i686/libevent-2.0.so.5 15862: trying file=/lib/sse2/libevent-2.0.so.5 15862: trying file=/lib/libevent-2.0.so.5
First confirm that a soft connection is established
# ls/usr/local/lib/libevent-2.0.so.5/usr/local/lib/libevent-2.0.so.5#ln-s/usr/local/lib/libevent-2.0.so.5/usr/ Lib/i686/libevent-2.0.so.5
If logged in as root, you must specify the-u parameter
/usr/local/memcached/bin/memcached-u Hadoop
Confirm that the memcached is starting successfully
# ps -ef |grep memcachedhadoop 15891 4034 0 22:45 pts/4 00:00:00 /usr/local/memcached/bin/memcached -u hadooproot 15899 15561 0 22:45 pts/5 00:00:00 grep memcached# netstat -tlnp |grep memcachedtcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 15891/memcached tcp 0 0 :::11211 :::* LISTEN 15891/memcached
Finally, Telnet confirms that the
# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. Statsstat pid 15891STAT Uptime 86STAT Time 1470494793
Ok. This memcached1.4.9 version has been successfully installed on the machine. The most troublesome part of personal feeling is to deal with Libevent.
We have consulted a lot of resources to solve the problem.
memcached setting up self-booting
For convenience, the memcached will now be executed under the Change permissions
The simplest way to start
Simply add a row to the/etc/rc.d/rc.local
/usr/local/memcached/bin/memcached-d-M 20-p 11211-u Hadoop
Attention
-D: Set as background process
-U: Point to User
-P: Port
-M: Memory
Recommended Way
2.1. Copy the MEMCACHED.SYSV copy of the memcached source package to/ETC/INIT.D as a memcached startup script
# cp/u01/software/memcached-1.4.29/scripts/memcached.sysv/etc/init.d/memcached
[[Email protected] bin]# vi /etc/init.d/memcached #! /bin/sh## chkconfig: - 55 45# description: The memcached daemon is a network memory cache service.# processname: memcached# config: /etc/ Sysconfig/memcached# source function library. /etc/rc.d/init.d/functionsport=11211user=nobodymaxconn=1024cachesize=64options= "" if [ -f /etc/sysconfig/memcached ];then . /etc/sysconfig/memcachedfi# check that networking is up.if [ "$NETWORKING" = "no" ]then exit 0firetval=0prog= "memcached" start () { echo - n $ "starting $prog: " # insure that /var/run/memcached has proper permissions chown $USER /var/run/memcached daemon memcached -d -p $PORT -u $USER -m $CACHESIZE -c $MAXCONN -p /var/run/memcached/memcached.pid $ options retval=$? echo [ $RETVAL -eq 0 ] && touch /var/lock/subsys/memcached}stop () { echo -n $ "stopping $prog: " killproc memcached retval=$? echo if [ $ retval -eq 0 ] ; then rm -f /var/lock/subsys/memcached rm -f /var/run/memcached/ memcached.pid fi}restart () { stop start}# see how we were called.case "$" in start) start ;; stop) stop ;; status) status memcached ;; restart|reload) restart ;; condrestart) [ -f /var/lock/subsys/memcached ] && restart | | : ;; *) echo $ "usage: $0 {start|stop|status|restart| Reload|condrestart} " exit 1esacexit $?
Modify the following sentence (in fact, the memcached command points to our full path)
Daemon memcached -d-p $PORT-u $USER-M $CACHESIZE-C $MAXCONN-P/var/run/memcached/memcached.pid $OPTIONS
Daemon /usr/local/memcached/bin/memcached -d-p $PORT-u $USER-M $CACHESIZE-C $MAXCONN-P/var/run/memcached /memcached.pid $OPTIONS
Configuring self-booting
[[email protected] bin]# chkconfig memcached on[[email protected] bin]# chkconfig |grep memcachedmemcached 0:off 1 : Off 2:on 3:on 4:on 5:on 6:off
Installing NC
[[email protected] yum.repos.d]# Yum install NC
Memcached comes with the stats command, not very friendly to the search. For a good search, use the NC tool.
For example, to find connection-related parameters
[Email protected] yum.repos.d]# echo Stats | NC 127.0.0.1 11211 |grep connectionstat curr_connections 10STAT total_connections 13STAT connection_structures 11
With the form of NC use, personal reference online resources, a simple list of
Watch "Echo Stats | NC 127.0.0.1 11211 "printf" stats\r\n "| NC 127.0.0.1 11211echo Stats | NC 127.0.0.1 11211
------------------------------------------------------------
The End
Next, the walkthrough is to access Memcachd through the Telnet command line and the Java Client tool.
This article is from a "simple" blog, so be sure to keep this source http://dba10g.blog.51cto.com/764602/1835163
memcached Walkthrough (1) Build memcached service