memcached command and distributed clusters

Memcache cluster
memcached command and distributed clustersmemcached command and distributed clusters
Memcached is a high-performance distributed memory object caching system for dynamic Web applications to reduce database load. It passes the buffer memory
to reduce the number of stored data read from the database and the object, thereby increasing the speed of the dynamic database-driven site. Memcached based on a store key / value
hashmap pairs. Its daemon (daemon) is written in C, but the client can be written in any language, and by the memcached protocol
and daemon communication.
memcached command and distributed clusters

One. Software installation
1. Four libevent installed software
memcached command and distributed clusters
memcached command and distributed clusters
21 is the tar-2.0.22-stable.tar.gz zxf libevent
22 is the stable-2.0.22-CD libevent /
23 is ./configure && && the make the make the install

  1. Keepalived install software (both the front keepalived server)
    (1) is mounted
    memcached command and distributed clusters
    16 zxf keepalived the tar-1.2.13.tar.gz
    . 17 keepalived CD-1.2.13 /
    18 is the install OpenSSL -Y-devel yum
    . 19 ./configure --prefix = / && make && make install compiled and installed
    (2) modify /etc/keepalived/keepalived.conf Vim
    global_defs {
    the router_id of the LVS_DEVEL_1
    }

vrrp_instance VI_1 {
state MASTER
interface ens33
virtual_router_id 51
priority 100
advert_int 1
authentication {
auth_type PASS
auth_pass 1111
}
virtual_ipaddress {
192.168.1.254
}
}

memcached command and distributed clusters
(3)启动并查看IP地址
memcached command and distributed clusters

  1. 安装 magent 软件(Magent 服务器 前两台)
    22 mkdir /usr/magent 创建所需文件夹
    23 tar zxf magent-0.6.tar.gz -C /usr/magent/
    24 cd /usr/magent/
    25 vim ketama.h
    memcached command and distributed clusters
    memcached command and distributed clusters
    memcached command and distributed clusters

    27 ln -s /usr/lib64/libevent-2.0.so.5 /usr/lib64/libevent.a
    28 ln -s /usr/lib64/libm.so /usr/lib64/libm.a
    29 make
    30 ln -s /usr/magent/magent /usr/local/bin/
    31 magent -u root -n 51200 -l 192.168.1.254 -p 1200 -s 192.168.1.30:11211 -b 192.168.1.40:11211
    32 netstat -anpt | grep 1200

4 .安装 memcached 软件(Memcached 服务器后 2 台)
memcached command and distributed clusters
21 tar zxf memcached-1.4.33.tar.gz
22 cd memcached-1.4.33/
23 ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local && make && make install
memcached command and distributed clusters
25 ln -s /usr/local/memcached/bin/memcached /usr/local/bin/
26 memcached -d -m 512 -l 192.168.1.30 -p 11211 -c 1024 -P /usr/local/memcached/memcached.pid -u root
27 netstat -anpt |grep 11211
28 yum -y install telnet

三,telnet测试
指令格式:
<命令> <键> <标记> <有效期> <数据长度>
<命令> - command name
主要是三个储存数据的三个命令, set, add, replace
set 命令是保存一个叫做 key 的数据到服务器上
add 命令是添加一个数据到服务器,但是服务器必须保证这个 key 是不存在的,能够保证数据不会被覆盖
replace 命令是替换一个已经存在的数据,如果数据不存在,就是类似 set 功能
get 查看键数据
gets 命令获取带有 CAS 令牌存 的 value(数据值) ,如果 key 不存在,则返回空。
stats 当前所有 Memcache 服务器运行的状态信息
stats <参数> 这个指令将只返回指定参数的项目状态信息。
version 将返回以 VERSION 开头的版本信息
flush_all 这个指令执行后,服务器上所有缓存的数据都被删除,并且返回:OK
delete <键> <超时时间> 删除数据的 key 键
append 向已存在 key(键) 的 value(数据值) 后面追加数据
prepend 用于向已存在 key(键) 的 value(数据值) 前面追加数据
CAS 通过令牌来修改内容
incr 与 decr 命令
Memcached incr 与 decr :命令用于对已存在的 key(键) 的数字值进行自增或自减操作。
quit to exit telnet mode

memcached command and distributed clusters
memcached command and distributed clusters
memcached command and distributed clusters

2. test at 192.168.1.10 magent
memcached command and distributed clusters
tested on 192.168.1.30 memcached
memcached command and distributed clusters

3. Test drift address
192.168.1.10
memcached command and distributed clusters
192.168.1.20
memcached command and distributed clusters
192.168.1.10
memcached command and distributed clusters
192.168.1.20
memcached command and distributed clusters

Summary: The
advantages of memcache: You can do more or more from the main
disadvantage of memcache: When the primary cache node crash resumed before the cached data will be lost

Guess you like

Origin blog.51cto.com/14320361/2446762