memcached installation, use

Source: Internet
Author: User
Tags connection pooling memcached

memcached Client 01:xmemcached version selection: 2.0.0 xmemcached: https://github.com/killme2008/xmemcached xmemcached Chinese api:http://blog.csdn.net/yangkai_hudong/article/details/38017553 maven dependencies:<!--xmemcached--<dependency> <groupId>com.googlecode.xmemcached</groupId> <artifactId>xmemcached</artifactId> <version>2.0.0</version></dependency> Xmemcached is also widely used, and has a more detailed Chinese API documentation, with the following features: High performance, support for a complete protocol, support client distribution, allow to set node weights, dynamic addition and deletion of nodes, support JMX, Integration with spring framework and hibernate-memcached, client connection pooling, scalability, and more. version (Pook): Xmemcached package jar, distributed, weight configuration (note differentiated Get/getreal, dependency dom4j, Common-log, SLF, etc. jar packages).... version (personal refactoring version): Xmemcached Tool class, distributed, weight configuration;"Shard, Master and slave" .... The required jar packages are as follows: Xmemcached-1.3.5.jarcommons-logging-1.1.1.jarlog4j-1.2.12.jarslf4j-api-1.6.6.jarslf4j-log4j12-1.6.6.jar Memcached Client 02:memcached-java-client Official website: https://github.com/gwhalin/Memcached-Java-Client/downloads because Memcached Client for Java has released a new version, performance has improved, and is running stably, Therefore, it is recommended to use memcached Client for Java. The 2.6.1 version supports apache-commoms-pool as a connection pool. Support for weight configuration. version (Lvmama): Memcached-java-client tool class, distributed, unauthorized reconfiguration.... version 03:memcached-java-client tool class, distributed, Weight configuration (new version support weights)
.... New Version Official example: Memcached-java-client, Branch distributed, weight configuration.... comparison test: .... actual test, single thread, Cycle set/get 50W times time consuming:Memcached-java-client Way: Checkmemcachedclient cost:7901xmemcached way: checkxmemcached cost : 16072XMemcached Package: checkmyxmemcachedcost:16578 Installing memcached under CentOS

The Yum version is relatively new and stable, and can be installed directly with Yum memcached

1. Find memcached # Yum search memcached# yum list|grep memcachedcentos use Yum to quickly install the Memcached-linux server application-Black bar safety net. htm 2. Install third-party repositories (optional) standard CentOS5 software Warehouse there is no memcache corresponding package, so our first step is to import third-party repositories, Recommended here is Rpmforge (Rpmforge library now has more than 10000 types of CentOS packages, the CentOS community is considered the safest and most stable of a third-party software library), the installation method is as follows: # wget/http DAG.WIEERS.COM/RPM/PACKAGES/RPMFORGE-RELEASE/RPMFORGE-RELEASE-0.5.2-2.RF.SRC.RPM # RPM-IVH RPMFORGE-RELEASE-0.5.2-2.RF.SRC.RPM 3. Installing the Memcached Yum Installation method one:# yum-y Install memcached Source Installation Method two:# yum-y Install gcc # yum-y install gcc-c++ # wget https://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21- Stable.tar.gz then uploads CentOS, gives permission, and then extracts # tar xzvf libevent-2.0.21-stable.tar.gz # #解压 # cd libevent-2.0.21-stable#./config Ure--prefix=/usr/local/libevent/# make && make install# ln-s/usr/local/libevent/lib/libevent-1.4.so.2/lib/ The default prefix in the Libevent-1.4.so.2configure file is/usr/local, so after the installation is complete, you can find/usr/local/lib related files under/usr/local/bin and Libevent # wget http://www.memcached.org/files/memcached-1.4.24.tar.gz# tar xzvf memcached-1.4.24.tar.gz # CD memcached-1.4.24#. /configure--prefix=/usr/local/memcached/--with-libevent=/usr/local/libevent/# make && make install installation result (LS- al/usr/local/bin/memcached) To Configure the self-startup script:# vi/etc/init.d/memcached    # chmod +x/etc/init.d/memcached# chkconfig--add memcached# chkconfig--level 235 memcached on# service memcached start##########################!/bin/bash# author:kuangl# date:2013-05-30# Description:starts and stops the Memcached services.# pidfile:/tmp/memcached1.pid# config:  /usr/local/memcached# Chkconfig:-45# source function library. /etc/rc.d/init.d/functions memcached= "/usr/local/memcached/bin/memcached" pidfile= "/tmp/memcached1.pid"  port=11211user=rootmaxconn=1024cachesize=64options= ""  start () { echo "Starting memcached:"   Daemon $memcached-D-P $PORT-u $USER  -m $CACHESIZE-C $MAXCONN-P $pidfile $OPTIONS} stop () { echo "Shutt ing down memcached " killproc memcached} case" $ instart)  start ;; Stop)  stop ;; Restart)  stop sleep 3 start ;; *)  echo $ "Usage: $ Start|stop|restart}" Exit 1esacexit $?######################### 4. Verifying the installation &NBSp  

#/usr/local/memcached/bin/memcached-d-u root-m 512-p 11211

Start parameter Description: the-D option is to start a daemon. -U root indicates that the user who initiated the memcached is root. -M is the amount of memory allocated to Memcache, in megabytes, by default 64MB. -P is the port that sets the TCP listener for Memcache, which defaults to 11211
# pgrep memcached# NETSTAT-TULPN | grep 11211# Ps-ef | grep memcached # yum install telnet# telnet 127.0.0.1 11211 Yum installation Error:# vi/etc/resolv.confoptions timeout:1 attempts:1 rotatenameserver 10.202.72.116nameserver 10.202.72.118#nameserver 8.8.8.8 Firewall was stopped, the Egg Hurts # service iptables stop# service iptables start 5. View configuration file # cat/etc/sysconfig/memcached can modify the relevant configuration parameters as appropriate: #################### #PORT = "11211" user= "memcached" maxconn= " 1024x768 "cachesize=" "options=" "############### 6. Start memcached #/etc/rc.d/init.d/memcached start 7, boot up # chkconfig --list memcached # chkconfig memcached on or: # vi/etc/rc.local join a line/etc/init.d/nginx start to save and exit and the next reboot will take effect. 8. Open firewall port: 11211 #/sbin/iptables-i input-p tcp--dport 11211-j ACCEPT # service iptables status#/ETC/RC.D/INIT.D/IP Tables Save 9, test whether the installation succeeded: Telnet 192.168.1.15 11211set name 0 0 4 jackget name Ctrl +]Q exit window install memcached Official website (Windows compiled 32-bit): Go to Baidu Version (Windows compilation 32-bit): Memcached-win32-1.4.4-14.zip official website (Windows compiled 64-bit): http://blog.couchbase.com /memcached-windows-64-bit-pre-release-available version (Windows compilation 64-bit): http://s3.amazonaws.com/ Downloads.northscale.com/memcached-win64-1.4.4-14.zip
The Linux version can be compiled directly, installed, the Windows version is not very good to compile, using the post-compiled version of the site; install memcached under Windows 1, download memcached for Win32 (MEMCACHED_EN32OR64), direct decompression;
2, cmd into the command window, CD to unzip the path;
3, installation command: Decompression path under the memcached.exe-d install;
4, start the service (calculator, management, service, manual start can also): "net start memcached (Close Delete, with SVN installation);
5, modify the default "Port 11211" and "Occupy Maximum Memory 64M": Decompression path under "Memcached.exe-p 10000-m 512-d Start (-p to repair the port,-m to modify the maximum memory, unit m);
6. Common commands:
Telnet to the Memcache server, such as: Telnet 192.168.1.120 11211 (11211 is the default port for Memcache)
Stats: View basic information
Stats items: View items
Get key: (Key is the string after item)
-C: Maximum number of simultaneous connections, default is 1024
-F: Block size growth factor, default is 1.25
-N: Minimum allocation space, key+value+flags default is 48
-H: Display Help
END can then be managed in the system service, boot up Win7 A solution that the Telnet command cannot open (not an internal command or external command) " Control Panel", "program", "Turn Windows features on or off", in which you can see many service items, select "Telnet Server" and "Telnet client" to determine. Installation Settings Parameters The above installation and startup are carried out in the default environment, at the time of installation can set the following parameters:-P Listening Port-L connection IP address, default is the native-D start memcached service-D Restart Restart memcached service-D stop| Shutdown close the running memcached service-D install installation memcached service-d Uninstall uninstall memcached service-u Run as (only valid when running as root)-m maximum memory usage, in megabytes. The default 64mb-m memory is exhausted when the error is returned, instead of deleting the item-C maximum number of simultaneous connections, the default is the 1024-F block size growth factor, the default is 1.25-n minimum allocation space, key+value+flags default is 48-h display help such as: "Memcached-d Install-l 127.0.0.1-m 1024-c2048 ". Win8 (64-bit) memcache install times wrong "failed to install service or service already installed" net start memcached prompt for system error 5
WORKAROUND: 1, locate the Cmd.exe file (C:\windows\system32\cmd.exe) 2, right-click Cmd.exe Run as Administrator

memcached installation, use

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.