zoukankan      html  css  js  c++  java
  • java使用memcached2--集群部署

    一、集群安装

      1.编译安装magent-0.5到/usr/local/下

    # cd /usr/local
    # mkdir magent
    # cd magent/
    # wget http://memagent.googlecode.com/files/magent-0.6.tar.gz
    # tar zxvf magent-0.6.tar.gz

      2. # vim ketama.h

      开头添加

    #ifndef SSIZE_MAX
    # define SSIZE_MAX      32767
    #endif

      3. # vim Makefile

    CFLAGS = -Wall -O2 -g 改为 CFLAGS = -lrt -Wall -O2 -g

      4.编译

    # cp /usr/lib/libevent.a /usr/lib64
    # ln -s /usr/lib64/libm.so /usr/lib64/libm.a
    # /sbin/ldconfig
    # sed -i "s#LIBS = -levent#LIBS = -levent -lm#g" Makefile
    # make
    # cp magent /usr/bin/magent
    # cd ..

    二、使用实例

    memcached -m 1 -u root -d -l 127.0.0.1 -p 11211
    memcached -m 1 -u root -d -l 127.0.0.1 -p 11212
    memcached -m 1 -u root -d -l 127.0.0.1 -p 11213
    magent -u root -n 51200 -l 127.0.0.1 -p 12000 -s 127.0.0.1:11211 -s 127.0.0.1:11212 -b 127.0.0.1:11213 

    三、测试

      # telnet 127.0.0.1 12000

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    set test1 0 0 5
    test1
    STORED
    set test2 0 0 5
    test2
    STORED
    quit
    Connection closed by foreign host.

      # telnet 127.0.0.1 11211

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    get test1
    VALUE test1 0 5
    test1
    END
    get test2
    END
    quit
    Connection closed by foreign host.

      # telnet 127.0.0.1 11212

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    get test1
    END
    get test2 
    VALUE test2 0 5
    test2
    END
    quit
    Connection closed by foreign host.

      # telnet 127.0.0.1 11213

    Trying 127.0.0.1...
    Connected to 127.0.0.1.
    Escape character is '^]'.
    get test1
    VALUE test1 0 5
    test1
    END
    get test2
    VALUE test2 0 5
    test2
    END
    quit
    Connection closed by foreign host.

     四、java应用

      与非集群模式一致,参考

      http://www.cnblogs.com/yangmengdx3/p/4716388.html

  • 相关阅读:
    C#学习笔记
    Visual Studio 快捷键
    java 8 中lambda表达式学习
    Spfa算法
    dijkstra算法
    topSort
    并查集--学习详解
    trie树--详解
    POJ1988 并查集的使用
    Mybatis的一级缓存和二级缓存
  • 原文地址:https://www.cnblogs.com/yangmengdx3/p/4717985.html
Copyright © 2011-2022 走看看