• memcached小试牛刀


    memcached安装

    [root@localhost ~]# cd /usr/local/src

    [root@localhost src]#wget http://www.memcached.org/files/memcached-1.4.34.tar.gz

    [root@localhost memcached-1.4.34]# cd memcached-1.4.34

    [root@localhost src]#wget https://github.com/libevent/libevent/releases/download/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz

    [root@localhost src]# cd libevent-2.0.22

    [root@localhost libevent-2.0.22]# ./configure --prefix=/usr/local/libevent

    [root@localhost libevent-2.0.22]# make && make install

    [root@localhost libevent-2.0.22]# cd /usr/local/src/memcached-1.4.34

    [root@localhost memcached-1.4.34]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent

    [root@localhost memcached-1.4.34]# make && make install

    开启memcached

    [root@localhost memcached-1.4.34]# cd /usr/local/memcached

    memcached不能用root用户去开启,那么用普通用户开启

    [root@localhost memcached]# ./bin/memcached -u xbl &

    ok,memcached安装成功

    pkill memcached

    启动memcached

    # /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d

    -p <num> tcp port number to listen on (default: 11211) // 监听
    的端口
    -u <num> udp port number to listen on (default: 0, off)
    -s <file> unix socket path to listen on (disables network support)
    -a <mask> access mask for unix socket, in octal (default 0700)
    -l <ip_addr> interface to listen on, default is indrr_any
    -d start tell memcached to start
    -d restart tell running memcached to do a graceful restart
    -d stop|shutdown tell running memcached to shutdown
    -d install install memcached service // 把 memcached 注册成服务
    -d uninstall uninstall memcached service
    -r maximize core file limit
    -u <username> assume identity of <username> (only when run as root)
    -m <num> max memory to use for items in megabytes, default is 64
    mb //分配给 memcached 的最大内存
    -m return error on memory exhausted (rather than removing
    items)

    -c <num> max simultaneous connections, default is 1024 // 最大
    的连接数
    -k lock down all paged memory. note that there is a
    limit on how much memory you may lock. trying to
    allocate more than that would fail, so be sure you
    set the limit correctly for the user you started
    the daemon with (not for -u <username> user;
    under sh this is done with 'ulimit -s -l num_kb').
    -v verbose (print errors/warnings while in event loop) //
    输出错误信息
    -vv very verbose (also print client commands/reponses) //
    输出所有信息
    -h print this help and exit
    -i print memcached and libevent license
    -b run a managed instanced (mnemonic: buckets)
    -p <file> save pid in <file>, only used with -d option
    -f <factor> chunk size growth factor, default 1.25 //增长因子
    -n <bytes> minimum space allocated for key+value+flags, default 48

    来个小例子(key value)

    [root@localhost memcached]# /usr/local/memcached/bin/memcached -m 64 -p 11211 -u nobody -d
    [root@localhost memcached]# netstat -tupln|grep 11211
    tcp        0      0 0.0.0.0:11211               0.0.0.0:*                   LISTEN      24244/memcached     
    tcp        0      0 :::11211                    :::*                        LISTEN      24244/memcached     
    udp        0      0 0.0.0.0:11211               0.0.0.0:*                               24244/memcached     
    udp        0      0 :::11211                    :::*                                    24244/memcached     
    [root@localhost memcached]# telnet localhost 11211
    Trying ::1...
    Connected to localhost.
    Escape character is '^]'.
    add name 0 0 5
    xiong
    STORED
    get name
    VALUE name 0 5
    xiong
    END

  • 相关阅读:
    linux-文件
    字符串函数
    函数
    内存管理
    静态库、动态库文件制作
    Makefile 待完善
    指针
    开发板GEC6816环境搭建,使用VS code
    C语言数组
    连接开发板下载程序
  • 原文地址:https://www.cnblogs.com/xiong63/p/6282219.html
Copyright © 2020-2023  润新知