1. Download and install
wget HTTP://WWW.MEMCACHED.ORG/FILES/MEMCACHED-1.5.3.TAR.GZTAR-ZXVF MEMCACHED-1.5.3.TAR.GZCD memcached-1.5.3./ Configure--prefix=/data/program/memcachedmake && make install
2. Start Memcache
./memcached-d-U root-l 127.0.0.1-m 50-p 11211-c 512-p/data/program/memcached/logs/memcached.pid
Parameters:
-U Running identity
-P Specify port number (default 11211)
-m specifies the maximum amount of memory to use (default 64MB)
-T thread count (default 4)
-L connected IP address, default is native
-D starts with the daemon process
-c Maximum number of simultaneous connections, default is 1024
-P Develop memecache PID file
-H Printing Help information
3. Connection test
[[Email protected] bin]# telnet 127.0.0.1 11211Trying 127.0.0.1...Connected to 127.0.0.1.Escape character is ' ^] '. Add test 1 0 5helloSTORED
Operation of the 4.memcache cluster
4.1 Download API Module python-memcached
wget https://pypi.python.org/packages/f7/62/14b2448cfb04427366f24104c9da97cf8ea380d7258a3233f066a951a8d8/ Python-memcached-1.58.tar.gz
Linux Environment:
Tar python-memcached-1.58.tar.gzcd python-memcached-1.58python setup.py Install
Reference Links: https://www.cnblogs.com/xiao1/p/5858967.html
4.2 Start
./memcached-d-U root-p 11211./memcached-d-u root-p 11212./memcached-d-u root-p 11213
Example:
#!/usr/bin/env Pythonimport memcache# Initializes a memcache client object with a port weight of 1:2:1 and an open error debug display MC = Memcache. Client (["192.168.2.230:11211", 1), ("192.168.2.230:11212", 2), ("192.168.2.230:11213", 1)],debug=true) mc.set ("Name "," huangzhenping ") Print (Mc.get (" name ")) MC1 = Memcache. The Client (["192.168.2.230:11211"],debug=true) print (Mc1.get ("name")) MC2 = Memcache. The Client (["192.168.2.230:11212"],debug=true) print (Mc1.get ("name")) MC3 = Memcache. Client (["192.168.2.230:11213"],debug=true) print (Mc3.get ("name"))
Operation Result:
Huangzhenping
None
None
Huangzhenping
Python connection memcached