博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
memcached(三)--参数
阅读量:6246 次
发布时间:2019-06-22

本文共 7855 字,大约阅读时间需要 26 分钟。

  memcached的一些启动参数,举个例子:

memcached -p 11212 -d -u root

启动memcached的时候,这些-p,-d,-u参数。 

 

  从源码中看得出来,启动参数有下面这些: 

-p 
TCP port number to listen on (default: 11211) --U
UDP port number to listen on (default: 11211, 0 is off) --s
UNIX socket path to listen on (disables network support) --A enable ascii \"shutdown\command --a
access mask for UNIX socket, in octal (default: 0700) --l
interface to listen on (default: INADDR_ANY, all addresses)
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
assume identity of
(only when run as root) --m
max memory to use for items in megabytes (default: 64 MB) --M return error on memory exhausted (rather than removing items) --c
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
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 --V print version and exit --P
save PID in
, only used with -d option --f
chunk size growth factor (default: 1.25) --n
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
Use
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
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)); -S Turn on Sasl authentication); -F Disable flush_all command); -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. - tail_repair_time: Time in seconds that indicates how long to wait before forcefully taking over the LRU tail item whose refcount has leaked. Disabled by default; dangerous option. - hash_algorithm: The hash table algorithm default is jenkins hash. options: jenkins, murmur3 - lru_crawler: Enable LRU Crawler background thread - lru_crawler_sleep: Microseconds to sleep between items default is 100. - lru_crawler_tocrawl: Max items to crawl per slab per run default is 0 (unlimited) - lru_maintainer: Enable new LRU system + background thread - hot_lru_pct: Pct of slab memory to reserve for hot lru. (requires lru_maintainer) - warm_lru_pct: Pct of slab memory to reserve for warm lru. (requires lru_maintainer) - expirezero_does_not_evict: Items set to not expire, will not evict. (requires lru_maintainer)

 以下是鄙人的翻译:

参数名 说明 重要性 特别说明
-p <num> TCP监听端口(default: 11211)  
-U <num> UDP监听端口(default: 11211, 0 is off)  广播,不太符合使用场景。
-s <file>

用于监听的UNIX套接字路径(禁用网络支持)

 
-A nc/telnet 到memcached后,输入“shutdown”关闭memcached进程  如果线上可以外网访问,被别人这样子shutdown了。。。
-a <mask> UNIX套接字访问掩码,八进制数字(默认:0700)  
-l <addr> 监听哪一块网卡(default: INADDR_ANY, all addresses)  
-d 以守护进程的方式运行 高   一般memcached都是守护进程的。
-r 最大核心文件限制。 较少使用 
-u <username>  assume identity of <username> (仅当root权限运行的时候)

 设定进程所属用户。

root权限启动mc的时候一定要输入这个参数。

一般就是: -u root

-m <num> memcached的内存大小 (default: 64 MB)  生产环境一般都改大,例如2G 4G。
-M 内存耗尽的时候返回错误,而不是lru 一般不用。 
 -c <num> 最大连接数 (default: 1024) 中 

 较少设置这个参数。

要设置这个参数

不如多个MC实例跑一致性hash。

-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

-vv

-vvv

-h

-i

-V

 

 输出日志 print errors/warnings

 输出详细日志 client commands/reponses
 输出超级详细日志^_^ internal state transitions
 print this help and exit
 print memcached and libevent license
 print version and exit

 中

 

研发环境可以玩玩;

线上影响性能

 -P <file>  -d的时候才会配套使用,输出pid文件  中  有点用
 -f <factor>     chunk大小的增长因子(default: 1.25)  高

线上不一定使用;

但是这个参数对于理解memcached的内存模型很有意义,

对于memcached的内存利用率很大影响。

 -n <bytes>    

minimum space allocated for key+value+flags (default: 48)

chunk的最小大小

 高

与-f参数类似,对于理解memcached的内存模型很有意义,

对于内存利用率较大影响

 -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>  使用多少个线程 (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   不允许CAS  低  一般不用这个参数
 -b 

backlog队列大小(linux socket三次握手后,socket进入的队列大小)

(default: 1024)

 中

可以研发环境玩玩。

线上出现要调整这个参数的时候, 不如增加memcached实例。 

 -B 

二进制协议(默认文本协议,1.4以前的MC只支持文本协议)

one of ascii, binary, or auto (default)

 中  追求点性能可以用二进制协议。mc的客户端也要使用二进制。
 -I 

Override the size of each slab page. Adjusts max item size

(default: 1mb, min: 1k, max: 128m)

 高  调优指令
 -S 

Turn on Sasl authentication

 中

 需要安装mc的时候,configure命令中有enable-sasl

否则后面想开启Sasl的时候启动mc失败的,日志会显示:

This server is not built with SASL support.

  -F  不允许flush_all命令  中 看情况使用 
 -o   逗号切割多个,实验参数
- (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.
- tail_repair_time: Time in seconds that indicates how long to wait before
forcefully taking over the LRU tail item whose refcount has leaked.
Disabled by default; dangerous option.
- hash_algorithm: The hash table algorithm
default is jenkins hash. options: jenkins, murmur3
- lru_crawler: Enable LRU Crawler background thread
- lru_crawler_sleep: Microseconds to sleep between items
default is 100.
- lru_crawler_tocrawl: Max items to crawl per slab per run
default is 0 (unlimited)
- lru_maintainer: Enable new LRU system + background thread
- hot_lru_pct: Pct of slab memory to reserve for hot lru.
(requires lru_maintainer)
- warm_lru_pct: Pct of slab memory to reserve for warm lru.
(requires lru_maintainer)
- expirezero_does_not_evict: Items set to not expire, will not evict.
(requires lru_maintainer)
 低  

  蓝色加粗的参数是我觉得比较重要/有用的参数。

 

转载于:https://www.cnblogs.com/ELMND/p/4533838.html

你可能感兴趣的文章
互联网分布式微服务云平台规划分析--平台整体规划
查看>>
Swift对象转为C指针
查看>>
Spring Cloud构建微服务架构:服务容错保护(Hystrix服务降级)
查看>>
ThinkSNS系统升级,版本多样化
查看>>
ecshop使用smtp发送邮件
查看>>
RubyInstaller
查看>>
21. SQL -- TSQL架构,系统数据库,文件,SQL 认证,TSQL语句
查看>>
CentOS6.0添加163和epel源
查看>>
使用组策略与脚本发布Office 2010
查看>>
Open××× 分配固定IP
查看>>
elk+redis centos6.6安装与配置
查看>>
linux下svn命令大全
查看>>
windows server 2008 在vm上安装
查看>>
我的友情链接
查看>>
谷果等手机刷机build.prop解析
查看>>
Vbox虚拟机下 Linux网络配置
查看>>
Vmware vsphere知识中易混淆和忽略的多个概念
查看>>
Android客户端和服务端如何使用Token和Session
查看>>
Python Pycharm导入第三方包
查看>>
Nginx源码安装
查看>>