Memcached启动-配置参数详解

memcached启动参数

 

[root@Betty ~]# memcached -h
memcached 1.4.14
-p <num>      TCP port number to listen on (default: 11211)
-U <num>      UDP port number to listen on (default: 11211, 0 is off)
-s <file>     UNIX socket path to listen on (disables network support)
-a <mask>     access mask for UNIX socket, in octal (default: 0700)
-l <addr>     interface to listen on (default: INADDR_ANY, all addresses)
              <addr> may be specified as host:port. If you don‘t specify
              a port number, the value you specified with -p or -U is
              used. You may specify multiple addresses separated by comma
              or by using -l multiple times
-d            run as a daemon
-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: 64 MB)
-M            return error on memory exhausted (rather than removing items)
-c <num>      max simultaneous connections (default: 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)
-vvv          extremely verbose (also print internal state transitions)
-h            print this help and exit
-i            print memcached and libevent license
-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)
-L            Try to use large memory pages (if available). Increasing
              the memory page size could reduce the number of TLB misses
              and improve the performance. In order to get large pages
              from the OS, memcached will allocate the total item-cache
              in one large chunk.
-D <char>     Use <char> as the delimiter between key prefixes and IDs.
              This is used for per-prefix stats reporting. The default is
              ":" (colon). If this option is specified, stats collection
              is turned on automatically; if not, then it may be turned on
              by sending the "stats detail on" command to the server.
-t <num>      number of threads to use (default: 4)
-R            Maximum number of requests per event, limits the number of
              requests process for a given connection to prevent
              starvation (default: 20)
-C            Disable use of CAS
-b            Set the backlog queue limit (default: 1024)
-B            Binding protocol - one of ascii, binary, or auto (default)
-I            Override the size of each slab page. Adjusts max item size
              (default: 1mb, min: 1k, max: 128m)
-o            Comma separated list of extended or experimental options
              - (EXPERIMENTAL) maxconns_fast: immediately close new
                connections if over maxconns limit
              - hashpower: An integer multiplier for how large the hash
                table should be. Can be grown at runtime if not big enough.
                Set this based on "STAT hash_power_level" before a
                restart.
[root@Betty ~]#


-p 指定端口号(默认11211)  

-U <num> UDP监听端口 (默认: 11211, 0 时关闭) 

-s <file>     用于监听的UNIX套接字路径(禁用网络支持)

-a <mask>     UNIX套接字访问掩码,八进制数字(默认:0700)

-m 指定最大使用内存大小(默认64MB)   

-t 线程数(默认4)

 

-l <ip_addr> 绑定地址 (默认:所有都允许,无论内外网或者本机更换IP,有安全隐患,若设置为127.0.0.1就只能本机访问) 

-d start 启动memcached服务   

-d restart 重起memcached服务   

-d stop|shutdown 关闭正在运行的memcached服务   

-u <username> 绑定使用指定用于运行进程 <username>  (只有root用户可以使用这个参数)

-P <file> 将PID写入文件<file>,这样可以使得后边进行快速进程终止, 需要与 -d 一起使用

-m 最大内存使用,单位MB。默认64MB   

-M 内存耗尽时返回错误,而不是删除项   

-c 最大同时连接数,默认是1024 

-f 块大小增长因子,默认是1.25 

-n <bytes>最小分配空间,key+value+flags默认是48

-k锁定所有内存页。注意你可以锁定的内存上限。

 

试图分配更多内存会失败的,所以留意启动守护进程时所用的用户可分配的内存上限。

(不是前面的 -u <username> 参数;在sh下,使用命令"ulimit -S -l NUM_KB"来设置。)

-v 提示信息(在事件循环中打印错误/警告信息。)

-vv 详细信息(还打印客户端命令/响应)

-vvv 超详细信息(还打印内部状态的变化)

-h 打印这个帮助信息并退出。

-i  打印memcached和libevent的许可。

-L 尝试使用大内存页(如果可用的话)。提高内存页尺寸可以减少"页表缓冲(TLB)"丢失次数,提高运行效率。

              为了从操作系统获得大内存页,memcached会把全部数据项分配到一个大区块。

-D <char>     使用 <char> 作为前缀和ID的分隔符。

              这个用于按前缀获得状态报告。默认是":"(冒号)。

              如果指定了这个参数,则状态收集会自动开启;如果没指定,则需要用命令"stats detail on"来开启。

-t <num>      使用的线程数(默认:4)

-R 每个连接可处理的最大请求数。

-C 禁用CAS。

-b 设置后台日志队列的长度(默认:1024)

-B 绑定协议 - 可能值:ascii,binary,auto(默认)

-I 重写每个数据页尺寸。调整数据项最大尺寸。

 

常用组合:

/usr/local/memcached/bin/memcached -d -m 256 -p 11211 -u www -l 127.0.0.1


郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。