xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
add myid 1 0 4
1234
STORED
get myid
VALUE myid 1 4
1234
END
# memcached default config file
# 2003 - Jay Bonci <jaybonci@debian.org>
# This configuration file is read by the start-memcached script provided as
# part of the Debian GNU/Linux distribution.
# Run memcached as a daemon. This command is implied, and is not needed for the
# daemon to run. See the README.Debian that comes with this package for more
# information.
# 以守护进程的形似运行
-d
# Log memcached's output to /var/log/memcached
# 日志文件存放位置
logfile /var/log/memcached.log
# Be verbose
# -v
# Be even more verbose (print client commands as well)
# -vv
# Start with a cap of 64 megs of memory. It's reasonable, and the daemon default
# Note that the daemon will grow to this size, but does not start out holding this much
# memory
# 分配给mencached的内存数目,单位是MB
-m 256
# Default connection port is 11211
# Memcached的监听端口
-p 11211
# Run the daemon as root. The start-memcached will default to running as root if no
# -u command is present in this config file
# 允许memcached的用户
-u memcache
# Specify which IP address to listen on. The default is to listen on all IP addresses
# This parameter is one of the only security measures that memcached has, so make sure
# it's listening on a firewalled interface.
# 监听的服务器IP地址
-l 127.0.0.1
# Limit the number of simultaneous incoming connections. The daemon default is 1024
# -c 1024
# Lock down all paged memory. Consult with the README and homepage before you do this
# -k
# Return error when memory is exhausted (rather than removing items)
# -M
# Maximize core file limit
# -r
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set name 0 0 11
baoqiu.xiao
STORED
get name
VALUE name 0 11
baoqiu.xiao
END
set name 0 0 9
memcached
STORED
get name
VALUE name 0 9
memcached
END
(2).add:只有数据不存在时添加值的add命令
已经存在的key是不能再add
12345678910
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
add sex 0 0 1
f
STORED
add sex 0 0 1
m
NOT_STORED
(3).replace:只有数据存在时替换的replace命令
只有存在才能replace:
123456789101112131415161718192021
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
replace host 0 0 9
localhost
NOT_STORED
add host 0 0 9
127.0.0.1
STORED
get host
VALUE host 0 9
127.0.0.1
END
replace host 0 0 9
localhost
STORED
get host
VALUE host 0 9
localhost
END
4.2删除命令
(1).delete:删除已经存在的数据
1234567891011
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
delete unknow
NOT_FOUND
add unknow 0 0 6
unknow
STORED
delete unknow
DELETED
4.3自增自减命令
incr和decr命令,注意只能在数字类型上进行自增自减操作
123456789101112131415161718
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
set age 2 0 2
25
STORED
incr age 1
26
incr age 3
29
decr age 2
27
set name 1 0 11
baoqiu.xiao
STORED
incr name 1
CLIENT_ERROR cannot increment or decrement non-numeric value
4.4读取命令
(1).get:获取一条或者多条数据
12345678910111213141516
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
add name 1 0 11
baoqiu.xiao
STORED
add age 2 0 2
25
STORED
get name age
VALUE name 1 11
baoqiu.xiao
VALUE age 2 2
25
END
(2).gets:获取一条或者多条数据
gets命令比get返回的值多一个数字(类似于版本号)用来判断数据是否发生过改变.
123456
gets name age
VALUE name 1 11 12
baoqiu.xiao
VALUE age 2 2 13
25
END
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
gets name
VALUE name 1 11 19
baoqiu.xiao
END
cas name 1 0 9 20
memcached
EXISTS
cas name 1 0 9 19
memcached
STORED
xiaobaoqiu@xiaobaoqiu:~$ telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 1241 //memcached服务进程的进程ID
STAT uptime 24026 //memcached服务从启动到当前所经过的时间,单位是秒
STAT time 1411579124 //memcached服务器所在主机当前系统的时间,单位是秒
STAT version 1.4.14 //memcached组件的版本
STAT libevent 2.0.21-stable //libevent版本
STAT pointer_size 64 //服务器所在主机操作系统的指针大小,一般为32或64
STAT rusage_user 0.404722 //进程累计使用用户时间
STAT rusage_system 0.313086 //进程累计使用系统时间
STAT curr_connections 5 //当前系统打开的连接数
STAT total_connections 21 //从memcached服务启动开始,系统打开过的连接总数
STAT connection_structures 6 //从memcached服务启动到现在,被服务器分配的连接结构数量
STAT reserved_fds 20 //
STAT cmd_get 15 //累积get命令次数
STAT cmd_set 22 //累积set命令次数
STAT cmd_flush 0 //累积flush命令次数
STAT cmd_touch 0 //
STAT get_hits 9 //命中次数,即get成功的次数
STAT get_misses 6 //miss次数,即get失败的次数
STAT delete_misses 2 //delete miss次数
STAT delete_hits 5 //delete 命中次数
STAT incr_misses 0 //incr miss次数
STAT incr_hits 2 //incr 命中次数
STAT decr_misses 0 //decr miss次数
STAT decr_hits 1 //decr命中次数
STAT cas_misses 0 //cas命令miss的次数
STAT cas_hits 1 //cas命令命中的次数
STAT cas_badval 1 //使用cas擦拭次数
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 968 //memcached服务器从网络读取的总的字节数
STAT bytes_written 706 //memcached服务器发送到网络的总的字节数
STAT limit_maxbytes 268435456 //memcached允许使用的最大字节,256M,见memcached.conf
STAT accepting_conns 1 //目前使用的连接数
STAT listen_disabled_num 0
STAT threads 4 //工作线程的总数量
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT bytes 373 //系统存储缓存对象所使用的存储空间,单位为字节
STAT curr_items 5 //当前缓存中存放的所有缓存对象的数量,不包括已删除的
STAT total_items 22 //自启动起所有缓存对象的数量,包括已删除的
STAT evictions 0 //从缓存移除的缓存对象数目,包括过期和空间不足时LRU移除
STAT reclaimed 0
END
每帧的内容包括:
(1). 本地局部变量数组(Local variable array)
(2). 返回值
(3). 操作栈(Operand stack)
(4). 当前方法所属类的运行时常量池的引用(Reference to runtime constant pool for class of the current method)
其中异常表中包含一些列的异常处理器(exception handler),每个异常处理器包含:起点(start point),终点(end point),处理程序代码的偏移(PC offset for handler code),被捕获异常类的常量池序号(Constant pool index for exception class being caught).
标志字符 | 含义
—- | ———–
B | 基本类型byte
C | 基本类型char
D | 基本类型double
F | 基本类型float
I | 基本类型int
J | 基本类型long
S | 基本类型short
Z | 基本类型bboolean
V | void
对于数组,每一维度将使用一个前置的"[“字符描述,如
0:new#2// Class java/lang/Object1:dup2:invokespecial#3// Method java/lang/Object "<init>"( ) V
new操作之后紧接一个#2操作数,这个操作数是常量池中的一个下标,因此表示引用的是常量池中的第二个数据实体.第二个数据是实体是一个类引用,指向常量池中另外一个实体,这个实体即名称以// Class java/lang/Object开头的类名称.这个符号链接被用于查找类java.lang.Object.new操作用于创建一个类实例并初始化它的变量.然后这个类新实例被加到操作数栈.dup操作复制一份操作数栈的顶部数据项并将其重新加到操作数栈的顶部.最后第2行的字节码使用invokespecial调用实例初始化函数,其操作数也包含一个指向常量池的引用,初始化方法使用(弹出,consumes)操作数栈顶部的引用作为参数.最后,就产生了一个新的引用,指向一个创建且初始化完成的对象.
从官网找到最新的release版本的下载地址,这里使用的版本是1.3.20(Released August 16, 2014)。
2.2 安装
下载到本机之后,依次解压,配置,make
123456789
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo tar -xvzf GraphicsMagick-1.3.20.tar.gz
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ cd GraphicsMagick-1.3.20/
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo ./configure
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo make
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo make install
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ gm version
GraphicsMagick 1.3.20 2014-08-16 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2014 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Feature Support:
Native Thread Safe yes
Large Files (> 32 bit) yes
Large Memory (> 32 bit) yes
BZIP no
DPS no
FlashPix no
FreeType yes
Ghostscript (Library) no
JBIG no
JPEG-2000 no
JPEG no
Little CMS no
Loadable Modules no
OpenMP yes (201107)
PNG yes
TIFF no
TRIO no
UMEM no
WebP no
WMF no
X11 yes
XML no
ZLIB yes
Host type: x86_64-unknown-linux-gnu
Configured using the command:
./configure
Final Build Parameters:
CC = gcc -std=gnu99
CFLAGS = -fopenmp -g -O2 -Wall -pthread
CPPFLAGS = -I/usr/include/freetype2
CXX = g++
CXXFLAGS = -pthread
LDFLAGS = -L/usr/lib
LIBS = -lfreetype -lpng12 -lXext -lSM -lICE -lX11 -lz -lm -lgomp -lpthread
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo wget ftp://ftp.graphicsmagick.org/pub/GraphicsMagick/delegates/jpegsrc.v9.tar.gz
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo tar xvfz jpegsrc.v9.tar.gz
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20/delegates/jpeg-9$ sudo ./configure --enable-shared
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20/delegates/jpeg-9$ sudo make
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20/delegates/jpeg-9$ sudo make install
再次重新安装GraphicsMagick,在configure的时候会发现支持jpeg:
12345678
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo ./configure
...
JPEG v1 --with-jpeg=yes yes
...
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo make
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ sudo make install
碰到的问题:
12
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ gm version
gm: error while loading shared libraries: libjpeg.so.9: cannot open shared object file: No such file or directory
xiaobaoqiu@xiaobaoqiu:/usr/local/GraphicsMagick/GraphicsMagick-1.3.20$ gm
GraphicsMagick 1.3.20 2014-08-16 Q8 http://www.GraphicsMagick.org/
Copyright (C) 2002-2014 GraphicsMagick Group.
Additional copyrights and licenses apply to this software.
See http://www.GraphicsMagick.org/www/Copyright.html for details.
Usage: gm command [options ...]
Where commands include:
animate - animate a sequence of images
batch - issue multiple commands in interactive or batch mode
benchmark - benchmark one of the other commands
compare - compare two images
composite - composite images together
conjure - execute a Magick Scripting Language (MSL) XML script
convert - convert an image or sequence of images
display - display an image on a workstation running X
help - obtain usage message for named command
identify - describe an image or image sequence
import - capture an application or X server screen
mogrify - transform an image or sequence of images
montage - create a composite image (in a grid) from separate images
time - time one of the other commands
version - obtain release version
Cached is the size of the page cache。
Buffers is the size of in-memory block I/O buffer。
6.4 vmstat
vmstat -s显示内存使用的统计信息
123456789101112131415161718192021222324252627
xiaobaoqiu@xiaobaoqiu:~$ vmstat -s
8047584 K total memory
7841504 K used memory
3624652 K active memory
1584740 K inactive memory
206080 K free memory
69252 K buffer memory
1890844 K swap cache
15879164 K total swap
39488 K used swap
15839676 K free swap
8744974 non-nice user cpu ticks
345 nice user cpu ticks
4309209 system cpu ticks
29496503 idle cpu ticks
240289 IO-wait cpu ticks
19 IRQ cpu ticks
14705 softirq cpu ticks
0 stolen cpu ticks
7878551 pages paged in
18640168 pages paged out
976 pages swapped in
9899 pages swapped out
664925325 interrupts
1290574510 CPU context switches
1409739162 boot time
36758 forks
if a request (typically POST) has Content-type header set to application/x-www-form-urlencoded the body is expected to be in the form of a standard querystring with url-encoded key=value pairs joined by &. Form data section then shows the key-value parameters (when viewed parsed). This way was much more common in past because it is a default for HTML forms.
other cases are shown in Request payload section (and nowadays parsed for readability as well for common formats like JSON).