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 時關閉) socket
-s <file> 用於監聽的UNIX套接字路徑(禁用網絡支持)ide
-a <mask> UNIX套接字訪問掩碼,八進制數字(默認:0700)memcached
-m 指定最大使用內存大小(默認64MB) oop
-t 線程數(默認4)this
-l <ip_addr> 綁定地址 (默認:全部都容許,不管內外網或者本機更換IP,有安全隱患,若設置爲127.0.0.1就只能本機訪問) spa
-d start 啓動memcached服務 線程
-d restart 重起memcached服務 rest
-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