??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲啪啪综合av一区二区三区,欧美一区二区少妇,一区久久精品http://www.aygfsteel.com/Todd/zh-cnTue, 17 Jun 2025 22:13:35 GMTTue, 17 Jun 2025 22:13:35 GMT60【unix】crontab 中用环境变?/title><link>http://www.aygfsteel.com/Todd/archive/2012/08/17/385698.html</link><dc:creator>Todd</dc:creator><author>Todd</author><pubDate>Fri, 17 Aug 2012 08:13:00 GMT</pubDate><guid>http://www.aygfsteel.com/Todd/archive/2012/08/17/385698.html</guid><wfw:comment>http://www.aygfsteel.com/Todd/comments/385698.html</wfw:comment><comments>http://www.aygfsteel.com/Todd/archive/2012/08/17/385698.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Todd/comments/commentRss/385698.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Todd/services/trackbacks/385698.html</trackback:ping><description><![CDATA[<p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">环境:(产品,q_,机型,软g版本,{?AIX5L</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">问题描述:crontab中启动的shell脚本不能正常q行Q但是用手动执行没有问题,?home/.profile中设定了脚本所需要的环境变量?/p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">解答:cron命o的默认shell?usr/bin/bshQ如果要在cron启动的脚本中使用kshQ就必须在脚本中的第一行添?#8220;#!/usr/bin/ksh”的声明?/p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">如果cronq程启动的shell脚本要用d时的环境变量Q就必须在cron启动的shell脚本中添加下面的内容Q才能够在启动的脚本中?br /> $home/.profile文g中的环境变量?/p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">. $home/.profile</p> <p style="color: #333333; font-family: Arial; line-height: 26px; text-align: left; ">q是因ؓcronq程执行的shell脚本是不会自动加载用L录下?profile文gQ所以需要脚本自己加载所需要的环境变量?br /> ================<br /> 环境变量文g加蝲序<br /> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; color: blue; ">/etc/profile:</span><span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; "> 此文件ؓpȝ的每个用戯|环境信?当用L一ơ登录时,该文件被执行.</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">q从/etc/profile.d目录的配|文件中搜集shell的设|?</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; color: blue; ">/etc/bashrc:</span><span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; "> 为每一个运行bash shell的用h行此文g.当bash shell被打开?该文件被d.</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; color: blue; ">~/.bash_profile:</span><span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; "> 每个用户都可使用该文件输入专用于自己使用的shell信息,当用L录时,?/span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">文g仅仅执行一?默认情况?他设|一些环境变?执行用户?bashrc文g.</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; color: blue; ">~/.bashrc:</span><span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; "> 该文件包含专用于你的bash shell的bash信息,当登录时以及每次打开新的shell??/span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">该文件被d.</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; color: blue; ">~/.bash_logout:</span><span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; "> 当每ơ退出系l?退出bash shell)?执行该文? </span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">另外,/etc/profile中设定的变量(全局)的可以作用于M用户,而~/.bashrc{中讑֮的变?局?只能l承/etc/profile中的变量,他们?父子"关系.</span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">~/.bash_profile 是交互式、login 方式q入 bash q行?/span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">~/.bashrc 是交互式 non-login 方式q入 bash q行?/span><br style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; " /> <span style="color: #000000; font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 13px; line-height: 19px; text-align: -webkit-auto; background-color: #28557e; ">通常二者设|大致相同,所以通常前者会调用后者?/span> <br /> </p> <img src ="http://www.aygfsteel.com/Todd/aggbug/385698.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Todd/" target="_blank">Todd</a> 2012-08-17 16:13 <a href="http://www.aygfsteel.com/Todd/archive/2012/08/17/385698.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>【oracle】高q发量表更新注意?/title><link>http://www.aygfsteel.com/Todd/archive/2012/07/25/383896.html</link><dc:creator>Todd</dc:creator><author>Todd</author><pubDate>Tue, 24 Jul 2012 18:29:00 GMT</pubDate><guid>http://www.aygfsteel.com/Todd/archive/2012/07/25/383896.html</guid><wfw:comment>http://www.aygfsteel.com/Todd/comments/383896.html</wfw:comment><comments>http://www.aygfsteel.com/Todd/archive/2012/07/25/383896.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Todd/comments/commentRss/383896.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Todd/services/trackbacks/383896.html</trackback:ping><description><![CDATA[Ud一个业务高q发Q接入一个客L话就发一个特D邀LQ码为字W加数字LQ无规律Q,码已存表Q业务上?码和用户手机L一一对应Q?br /> 所以,来个用户得Ҏ标记的码更新手机LQ高q发Ӟ行锁及等待比较耗时Q导致数据库性能下降严重Q?br /> 解决办法Q?br /> 码表增加seqid,字段Q导入数据时使用rownum,做该字段?建烦引;<br /> 更新Ӟ使用序列Q? <div></div> <div>CREATE SEQUENCE SQ_U_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 50000000 CYCLE CACHE 2000 NOORDER;<br /> 更新则:update ... where ... and t.seqid = SQ_U_SEQ.nextval ...;<br /> 以后有新的数据要导入Q则序列需重置Q则Q?/div> <div style="font-size: 13px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #cccccc; border-right-color: #cccccc; border-bottom-color: #cccccc; border-left-color: #cccccc; border-image: initial; padding-right: 5px; padding-bottom: 4px; padding-left: 4px; padding-top: 4px; width: 98%; word-break: break-all; background-color: #eeeeee; "><!--<br /> <br /> Code highlighting produced by Actipro CodeHighlighter (freeware)<br /> http://www.CodeHighlighter.com/<br /> <br /> --><span style="color: #0000FF; ">create</span> <span style="color: #808080; ">or</span> <span style="color: #FF00FF; ">replace</span> <span style="color: #0000FF; ">procedure</span> seq_reset(v_seqname <span style="font-weight: bold; ">varchar2</span>) <span style="color: #0000FF; ">as</span> n <span style="font-weight: bold; ">number</span>(<span style="color: #800000; font-weight: bold; ">10</span>);<br /> tsql <span style="font-weight: bold; ">varchar2</span>(<span style="color: #800000; font-weight: bold; ">100</span>);<br />  <span style="color: #0000FF; ">begin</span><br />  <span style="color: #0000FF; ">execute</span> immediate <span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">select </span><span style="color: #FF0000; ">'</span><span style="color: #808080; ">||</span>v_seqname<span style="color: #808080; ">||</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">.nextval from dual</span><span style="color: #FF0000; ">'</span> <span style="color: #0000FF; ">into</span> n;<br />   n:<span style="color: #808080; ">=-</span>(n<span style="color: #808080; ">-</span><span style="color: #800000; font-weight: bold; ">1</span>);<br />   tsql:<span style="color: #808080; ">=</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">alter sequence </span><span style="color: #FF0000; ">'</span><span style="color: #808080; ">||</span>v_seqname<span style="color: #808080; ">||</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; "> increment by </span><span style="color: #FF0000; ">'</span><span style="color: #808080; ">||</span> n;<br />   <span style="color: #0000FF; ">execute</span> immediate tsql;<br />  <span style="color: #0000FF; ">execute</span> immediate <span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">select </span><span style="color: #FF0000; ">'</span><span style="color: #808080; ">||</span>v_seqname<span style="color: #808080; ">||</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">.nextval from dual</span><span style="color: #FF0000; ">'</span> <span style="color: #0000FF; ">into</span> n;<br />   tsql:<span style="color: #808080; ">=</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; ">alter sequence </span><span style="color: #FF0000; ">'</span><span style="color: #808080; ">||</span>v_seqname<span style="color: #808080; ">||</span><span style="color: #FF0000; ">'</span><span style="color: #FF0000; "> increment by 1</span><span style="color: #FF0000; ">'</span>;<br />  <span style="color: #0000FF; ">execute</span> immediate tsql;<br />  <span style="color: #0000FF; ">end</span> seq_reset;</div> 另外Q高q发时序列的cache要设|大?一般业务设|?00以上Q但nocache的时候性能实很差Q最大相?0倍. 排序参数Qoracle默认是NOORDERQ如果设|ؓORDERQ在单实例环境没有媄响,在RAC环境此时Q多实例实际~存相同的序列,此时在多个实例ƈ发取该序列的时候,会有短暂的资源竞争来在多实例之间q行同步。因ơ性能相比noorder要差Q所以RAC环境非必ȝ情况下不要用ORDERQ尤其要避免NOCACHE ORDERl合Q? <img src ="http://www.aygfsteel.com/Todd/aggbug/383896.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Todd/" target="_blank">Todd</a> 2012-07-25 02:29 <a href="http://www.aygfsteel.com/Todd/archive/2012/07/25/383896.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VI常用命ohttp://www.aygfsteel.com/Todd/archive/2012/07/18/383419.htmlToddToddWed, 18 Jul 2012 09:32:00 GMThttp://www.aygfsteel.com/Todd/archive/2012/07/18/383419.htmlhttp://www.aygfsteel.com/Todd/comments/383419.htmlhttp://www.aygfsteel.com/Todd/archive/2012/07/18/383419.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/383419.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/383419.html阅读全文

Todd 2012-07-18 17:32 发表评论
]]>
?】freebsd netperf |络性能试工具 http://www.aygfsteel.com/Todd/archive/2012/03/29/373010.htmlToddToddThu, 29 Mar 2012 14:45:00 GMThttp://www.aygfsteel.com/Todd/archive/2012/03/29/373010.htmlhttp://www.aygfsteel.com/Todd/comments/373010.htmlhttp://www.aygfsteel.com/Todd/archive/2012/03/29/373010.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/373010.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/373010.htmlhttp://www.netperf.org/netperf/DownloadNetperf.html
2.安装Qnetperf-2.5.0.tar.gzQ解压后执行一下命令:
cd netperf-2.5.0
./configure
make && make install
默认安装目录Q?usr/local/bin
有两个文?netperf netserver
后者服务端Q在要测试的机器上也要安装,q执行netserver启动之,否则客户端报错)  前者客L
3.试--直接转别人的

TCP|络性能

׃TCP协议能够提供端到端的可靠传输Q因此被大量的网l应用程序用。但是,可靠性的建立是要付出代h的。TCP协议保证可靠性的措施Q如建立q维护连接、控制数据有序的传递等都会消耗一定的|络带宽?/p>

Netperf可以模拟三种不同的TCP量模式Q?/p>

1Q?单个TCPq接Q批量(bulkQ传输大量数?/p>

2Q?单个TCPq接Qclienth/server应答的交易(transactionQ方?/p>

3Q?多个TCPq接Q每个连接中一对请?应答的交易方?/p>

UDP|络性能

UDP没有建立q接的负担,但是UDP不能保证传输的可靠性,所以用UDP的应用程序需要自行跟t每个发出的分组Qƈ重发丢失的分l?/p>

Netperf可以模拟两种UDP的流量模式:

1Q?从client到server的单向批量传?/p>

2Q?h/应答的交易方?/p>

׃UDP传输的不可靠性,在用netperf时要保发送的~冲区大不大于接收~冲区大,否则数据会丢失,netperf给出错误的l果。因此,对于接收到分l的l计不一定准,需要结合发送分l的l计l合得出l论?/p>

Netperf的命令行参数

在unixpȝ中,可以直接q行可执行程序来启动netserverQ也可以让inetd或xinetd来自动启动netserver?/p>

当netserver在server端启动以后,可以在client端运行netperf来测试网l的性能。netperf通过命o行参数来控制试的类型和具体的测试选项。根据作用范围的不同Qnetperf的命令行参数可以分ؓ两大c:全局命o行参数、测试相关的局部参敎ͼ两者之间?-分隔Q?/p>
netperf [global options]-- [test-specific options] 

q里我们只解释那些常用的命o行参敎ͼ其它的参数读者可以查询netperf的man手册?/p>

-H host Q指定远端运行netserver的server IP地址?/p>

-l testlenQ指定测试的旉长度Q秒Q?/p>

-t testnameQ指定进行的试cdQ包括TCP_STREAMQUDP_STREAMQTCP_RRQTCP_CRRQUDP_RRQ在下文中分别对它们说明?/p>

在后面的试中,netserverq行?92.168.0.28Qserver与client通过局域网q接Q?00M HubQ?/p>

Netperf试|络性能

试扚wQbulkQ网l流量的性能

扚w数据传输典型的例子有ftp和其它类似的|络应用Q即一ơ传输整个文Ӟ。根据用传输协议的不同Q批量数据传输又分ؓTCP扚w传输和UDP扚w传输?/p>

1Q?TCP_STREAM

Netperf~省情况下进行TCP扚w传输Q即-t TCP_STREAM。测试过E中Qnetperf向netserver发送批量的TCP数据分组Q以定数据传输q程中的吞吐量:

 ./netperf -H 192.168.0.28 -l 60 TCP STREAM TEST to 192.168.0.28 Recv   Send    Send Socket Socket  Message  Elapsed Size   Size    Size     Time     Throughput bytes  bytes   bytes    secs.    10^6bits/sec    87380  16384  16384    60.00      88.00  

从netperf的结果输ZQ我们可以知道以下的一些信息:

1Q?q端pȝQ即serverQ用大ؓ87380字节的socket接收~冲

2Q?本地pȝQ即clientQ用大ؓ16384字节的socket发送缓?/p>

3Q?向远端系l发送的试分组大小?6384字节

4Q?试l历的时间ؓ60U?/p>

5Q?吞吐量的试l果?8Mbits/U?/p>

在缺省情况下Qnetperf向发送的试分组大小讄为本地系l所使用的socket发送缓冲大?/p>

TCP_STREAM方式下与试相关的局部参数如下表所C:

参数说明
-s size讄本地pȝ的socket发送与接收~冲大小
-S size讄q端pȝ的socket发送与接收~冲大小
-m size讄本地pȝ发送测试分l的大小
-M size讄q端pȝ接收试分组的大?/td>
-DҎCq端pȝ的socket讄TCP_NODELAY选项

通过修改以上的参敎ͼq观察结果的变化Q我们可以确定是什么因素媄响了q接的吞吐量。例如,如果怀疑\由器׃~Z_的缓冲区I间Q得{发大的分l时存在问题Q就可以增加试分组Q?mQ的大小Q以观察吞吐量的变化Q?/p>
 ./netperf -H 192.168.0.28 -l 60 -- -m 2048 TCP STREAM TEST to 192.168.0.28 Recv   Send    Send Socket Socket  Message  Elapsed Size   Size    Size     Time     Throughput bytes  bytes   bytes    secs.    10^6bits/sec    87380  16384   2048    60.00      87.62  

在这里,试分组的大减到2048字节Q而吞吐量却没有很大的变化Q与前面例子中测试分l大ؓ16K字节相比Q。相反,如果吞吐量有了较大的提升Q则说明在网l中间的路由器确实存在缓冲区的问题?/p>

2Q?UDP_STREAM

UDP_STREAM用来试q行UDP扚w传输时的|络性能。需要特别注意的是,此时试分组的大不得大于socket的发送与接收~冲大小Q否则netperf会报出错提示Q?/p>
./netperf -t UDP_STREAM -H 192.168.0.28 -l 60 UDP UNIDIRECTIONAL SEND TEST to 192.168.0.28 udp_send: data send error: Message too long 

Z避免q样的情况,可以通过命o行参数限定测试分l的大小Q或者增加socket的发?接收~冲大小。UDP_STREAM方式使用与TCP_STREAM方式相同的局部命令行参数Q因此,q里可以使用-m来修Ҏ试中使用分组的大:

 ./netperf -t UDP_STREAM -H 192.168.0.28 -- -m 1024 UDP UNIDIRECTIONAL SEND TEST to 192.168.0.28 Socket  Message  Elapsed      Messages Size    Size     Time         Okay Errors   Throughput bytes   bytes    secs            #      #   10^6bits/sec    65535    1024   9.99       114127      0      93.55  65535           9.99       114122             93.54  

UDP_STREAM方式的结果中有两行测试数据,W一行显C的是本地系l的发送统计,q里的吞吐量表示netperf向本地socket发送分l的能力。但是,我们知道QUDP是不可靠的传输协议,发送出ȝ分组数量不一定等于接收到的分l数量?/p>

W二行显C的是q端pȝ接收的情况,׃client与server直接q接在一P而且|络中没有其它的量Q所以本地系l发送过ȝ分组几乎都被q端pȝ正确的接收了Q远端系l的吞吐量也几乎{于本地pȝ的发送吞吐量。但是,在实际环境中Q一般远端系l的socket~冲大小不同于本地系l的socket~冲区大,而且׃UDP协议的不可靠性,q端pȝ的接收吞吐量要远q小于发送出ȝ吞吐量?/p>

试h/应答Qrequest/responseQ网l流量的性能

另一cd见的|络量cd是应用在client/serverl构中的request/response模式。在每次交易QtransactionQ中Qclient向server发出的查询分组Qserver接收到请求,l处理后q回大的l果数据。如下图所C:


 

1Q?TCP_RR

TCP_RR方式的测试对象是多次TCP request和response的交易过E,但是它们发生在同一个TCPq接中,q种模式常常出现在数据库应用中。数据库的clientE序与serverE序建立一个TCPq接以后Q就在这个连接中传送数据库的多ơ交易过E?/p>
./netperf -t TCP_RR -H 192.168.0.28 TCP REQUEST/RESPONSE TEST to 192.168.0.28 Local /Remote Socket Size   Request  Resp.   Elapsed  Trans. Send   Recv   Size     Size    Time     Rate bytes  Bytes  bytes    bytes   secs.    per sec   16384  87380  1        1       10.00    9502.73 16384  87380 

Netperf输出的结果也是由两行l成。第一行显C本地系l的情况Q第二行昄的是q端pȝ的信息。^均的交易率(transaction rateQؓ9502.73?U。注意到q里每次交易中的request和response分组的大都?个字节,不具有很大的实际意义。用户可以通过试相关的参数来改变request和response分组的大,TCP_RR方式下的参数如下表所C:

参数说明
-r req,resp讄request和reponse分组的大?/td>
-s size讄本地pȝ的socket发送与接收~冲大小
-S size讄q端pȝ的socket发送与接收~冲大小
-DҎCq端pȝ的socket讄TCP_NODELAY选项

通过使用-r参数Q我们可以进行更有实际意义的试Q?/p>
./netperf -t TCP_RR -H 192.168.0.28 -- -r 32,1024 TCP REQUEST/RESPONSE TEST to 192.168.0.28 Local /Remote Socket Size   Request  Resp.   Elapsed  Trans. Send   Recv   Size     Size    Time     Rate bytes  Bytes  bytes    bytes   secs.    per sec   16384  87380  32       1024    10.00    4945.97 16384  87380 

从结果中可以看出Q由于request/reponse分组的大增加了Q导致了交易率明昄下降?注:相对于实际的pȝQ这里交易率的计没有充分考虑C易过E中的应用程序处理时Ӟ因此l果往往会高于实际情c?/p>

2Q?TCP_CRR

与TCP_RR不同QTCP_CRR为每ơ交易徏立一个新的TCPq接。最典型的应用就是HTTPQ每ơHTTP交易是在一条单独的TCPq接中进行的。因此,׃需要不停地建立新的TCPq接Qƈ且在交易l束后拆除TCPq接Q交易率一定会受到很大的媄响?/p>
./netperf -t TCP_CRR -H 192.168.0.28  TCP Connect/Request/Response TEST to 192.168.0.28 Local /Remote Socket Size   Request  Resp.   Elapsed  Trans. Send   Recv   Size     Size    Time     Rate bytes  Bytes  bytes    bytes   secs.    per sec   131070 131070 1        1       9.99     2662.20 16384  87380 

即是用一个字节的request/response分组Q交易率也明昄降低了,只有2662.20?U。TCP_CRR使用与TCP_RR相同的局部参数?/p>

3Q?UDP_RR

UDP_RR方式使用UDP分组q行request/response的交易过E。由于没有TCPq接所带来的负担,所以我们推交易率一定会有相应的提升?/p>
./netperf -t UDP_RR -H 192.168.0.28  UDP REQUEST/RESPONSE TEST to 192.168.0.28 Local /Remote Socket Size   Request  Resp.   Elapsed  Trans. Send   Recv   Size     Size    Time     Rate bytes  Bytes  bytes    bytes   secs.    per sec   65535  65535  1        1       9.99     10141.16 65535  65535 

l果证实了我们的推测Q交易率?0141.16?U,高过TCP_RR的数倹{不q,如果出现了相反的l果Q即交易率反而降低了Q也不需要担心,因ؓq说明了在网l中Q\由器或其它的|络讑֤对UDP采用了与TCP不同的缓冲区I间和处理技术?/p>

http://www.ibm.com/developerworks/cn/linux/l-netperf/


Todd 2012-03-29 22:45 发表评论
]]>
[转]暴雪总裁ȝ游戏十条l验 http://www.aygfsteel.com/Todd/archive/2012/03/19/372197.htmlToddToddMon, 19 Mar 2012 07:33:00 GMThttp://www.aygfsteel.com/Todd/archive/2012/03/19/372197.htmlhttp://www.aygfsteel.com/Todd/comments/372197.htmlhttp://www.aygfsteel.com/Todd/archive/2012/03/19/372197.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/372197.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/372197.html暴雪创办人兼总裁Michael Morhaime在GDC Austin上发表了演讲Q谈Z从《魔兽世界》和其他暴雪游戏中ȝ出来的十条经验?br style="word-wrap: break-word; " />
1·游戏性第一?br style="word-wrap: break-word; " />
    如果你了解暴雪,那你知道他们在游戏^衡性上力尽完美Q或者说比Q何h做的都好。暴雪哲学好懂但难掌握。他们希望你入门Ҏ而维持长旉的兴,用同一ƾ品同时吸引休闲和核心玩家?br style="word-wrap: break-word; " />
2·打造ƈ保护品牌?br style="word-wrap: break-word; " />
    暴雪的目标是要消费者进入商店,看到暴雪的商标就知道那是好东ѝ但个h认ؓ暴雪q方面做的不好,ZQ他们欺负了可怜的BNetDQ战|私服)人员Q控告一没有反抗能力的开发者。暴雪真坏?br style="word-wrap: break-word; " />
3·抗拒提早上市的诱惑?br style="word-wrap: break-word; " />
    q一点很多h都做不到。游戏是要在完成之后再推出,而不是当日历上某个时候到来。如果照着日历办事Q那你的l果是创世U?Q更p糕的,是多bug的微软恶梦般的操作系l?br style="word-wrap: break-word; " />
    Michael指出Q公司应该用长远的目光去看,而不是考虑短期。短期考虑通常不会有好l果。《暗黑破坏神》错q了圣诞假期Q在12?1日推出。你会觉得暗黑是个错q了圣诞的游戏,q是个卖了几百万的游戏?《燃烧远征》也错过了圣诞假期,但在W一天就卖出?40万䆾?br style="word-wrap: break-word; " />
4·不要所有东襉K同时做?br style="word-wrap: break-word; " />
    知道自己能做什么,然后把它做好。《魔兽世界》ƈ不是他们W一Ƒ֜U游戏,《魔?》就有大量在U内容,《暗?》也是。从它们之中吸取l验QWOWp生了?br style="word-wrap: break-word; " />
5·暴雪是一个全球性的企业?br style="word-wrap: break-word; " />
    它曾l只是美国的公司。东西先做好英文的再d其它地区的。游戏先在北发售,然后到欧zԌ然后到其它地斏V这U做法有好些弊端?br style="word-wrap: break-word; " />
    星际争霸Q韩国的国家U游戏,昄的却不是本地语言。唯一有本地语a的是日本版,但这个版本又与其它的冲突Q韩国h玩的是英文版。而北和Ƨ洲的灰色市场意味着当游戏在国发售Q那在欧z发售日期之前h们就能拿到它Q而当游戏正式在欧z发售的时候,Z已经买到了,销售自然不好,零售商也不高兴?br style="word-wrap: break-word; " />
    解决Ҏ是q等的对待所有玩家。进行全球范围的同步发售。这需要更多时_但绝对值得。《暗?》便是全球同时发售,而结果也相当好?br style="word-wrap: break-word; " />
6·地区性口味的话?br style="word-wrap: break-word; " />
    暴雪不相信有地区性口呌玩意儿,全球兴趣都是一LQ只是hC同。如果你制作一N合所有h口味得游戏,那你׃用针Ҏ个市场各做一个版本了?br style="word-wrap: break-word; " />
    有一件事q是得注意,是文化问题Q比如魔?里的熊猫。游戏里的熊猫穿着日本服装拿着日本武器。中国玩家对此颇有怨言。因此它后来改I了中式服装和中式武器,问题p决了?br style="word-wrap: break-word; " />
7·q营|络游戏不属于游戏开发?br style="word-wrap: break-word; " />
    你在三个大陆?4时不停得运行着数千台服务器。你q需要管理一活跃但虚拟的社区?br style="word-wrap: break-word; " />
    举个例子Q你的开发小l在为游戏增加内容,但如果小l需要修正服务器的问题,他们׃能l开发那些内容,哪个更重要?暴雪特别成立了一个小l专门应付游戏里的问题,q样开发小l就可以专注于他们的工作了?br style="word-wrap: break-word; " />
8·交流。内部交、外部交?br style="word-wrap: break-word; " />
    如果你有C֌Q跟他们交谈Q经常的Q清楚的。如果有个大bugQ或者服务器挂了Q工作h员马上就开始工作,他们不会到论坛里解释问题Q时间就q样费了?br style="word-wrap: break-word; " />
    因ؓq样Q内部无关h员不知道发生了什么事Q外面的Z不知道发生了什么事Q然后h们开始抓狂,在论坛上疯狂发脓然后论坛挂了?br style="word-wrap: break-word; " />
    Z解决q个问题Q暴雪徏立了一个正式的邮gpȝ。开发小l可以与内部人员交流Q消息可以有U序的传播开厅R?br style="word-wrap: break-word; " />
9·避免涉及金钱?br style="word-wrap: break-word; " />
    只要你在WOW里显露出一点商机,Z׃滥用它。如果你把它隐藏Q问题就变小了。如果坏Z能赚钱,淘金、窃取帐受伪造信用卡{等q些问题׃再存在了?br style="word-wrap: break-word; " />
10·持箋试游戏?br style="word-wrap: break-word; " />
    不要怿Ver.1.0。你试的越多就好Q但很少做到。在暴雪Q每时每L人都在测试。先有封,然后公测Q然后发售,希望游戏C发售日的时候能有^衡性、流畅、无bug?br style="word-wrap: break-word; " />
    暴雪在燃烧远征的发售上相当接q这个目标。服务器的结构升U以减少|络延迟Qƈ提升了容量。他们补充了很多的内容,最后把发售日期推迟到完成的那一天?br style="word-wrap: break-word; " />
    最后,他们在当地时间凌晨发售了。一天卖掉了240万䆾Q这是很好的成W。有理员表C当他看着服务器的灯一个接一个亮h的时候他感到非常ƣ慰?br style="word-wrap: break-word; " />
    暴雪奋斗?6q_现在有数百万玩家在线游戏Q他们做Z不错的成l。Q何技术都会出现问题,但暴雪总能把它们减轅R希望日后的|络游戏可以从他们的错误和成功中学到一些经?/td>

Todd 2012-03-19 15:33 发表评论
]]>
?】freebsd 安装Q环境,资料http://www.aygfsteel.com/Todd/archive/2012/02/09/369634.htmlToddToddWed, 08 Feb 2012 17:26:00 GMThttp://www.aygfsteel.com/Todd/archive/2012/02/09/369634.htmlhttp://www.aygfsteel.com/Todd/comments/369634.htmlhttp://www.aygfsteel.com/Todd/archive/2012/02/09/369634.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/369634.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/369634.html1.中文使用手册 必备
http://www.freebsd.org/doc/zh_CN/books/handbook/index.html
开发手?br />http://www.freebsd.org/doc/en/books/developers-handbook/index.html
2.pȝ安装
pȝ安装包FreeBSD-8.2-RELEASE-i386-disc1.iso 地址Q?br />ftp://ftp.freebsd.org/pub/FreeBSD/releases/i386/ISO-IMAGES/8.2/
或者用网易的镜像地址下蝲Q?br />http://mirrors.163.com/FreeBSD/ISO-IMAGES-i386/8.2/
使用虚拟光驱加蝲iso文gQ在vm中加载安?br />安装步骤参见《手册》地址Q?br />http://www.freebsd.org/doc/zh_CN/books/handbook/using-sysinstall.html
我用标准安装,安装步骤很详l,若要ssh,标准安装中带ssh,查下rc.conf?pre class="SCREEN">sshd_enable="YES"
gcc也是自带装好的,可以hello验证?br />#include <stdio.h>
int main()
{
        printf("hello,todd^^\n");
        return 0;
}
>gcc hello.c -o hello
>./hello
>hello,todd^^
Ƨ了






Todd 2012-02-09 01:26 发表评论
]]>
[转]linux下抓包命?-tcpdump的?/title><link>http://www.aygfsteel.com/Todd/archive/2012/02/06/369460.html</link><dc:creator>Todd</dc:creator><author>Todd</author><pubDate>Mon, 06 Feb 2012 02:38:00 GMT</pubDate><guid>http://www.aygfsteel.com/Todd/archive/2012/02/06/369460.html</guid><wfw:comment>http://www.aygfsteel.com/Todd/comments/369460.html</wfw:comment><comments>http://www.aygfsteel.com/Todd/archive/2012/02/06/369460.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Todd/comments/commentRss/369460.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Todd/services/trackbacks/369460.html</trackback:ping><description><![CDATA[<div><div>?tcpdump host 172.16.29.40 and port 4600 -X -s 500 </div><div></div><div>tcpdump采用命o行方式,它的命o格式为:</div><div>  tcpdump [ -adeflnNOpqStvx ] [ -c 数量 ] [ -F 文g?]</div><div>          [ -i |络接口 ] [ -r 文g名] [ -s snaplen ]</div><div>          [ -T cd ] [ -w 文g?] [表达?]</div><div></div><div>  1. tcpdump的选项介绍</div><div>   -a    网l地址和广播地址转变成名字;</div><div>   -d    匹配信息包的代码以Z能够理解的汇~格式给出;</div><div>   -dd    匹配信息包的代码以c语言E序D늚格式l出Q?/div><div>   -ddd    匹配信息包的代码以十进制的形式l出Q?/div><div>   -e    在输打印出数据链路层的头部信息;</div><div>   -f    外部的Internet地址以数字的形式打印出来Q?/div><div>   -l    使标准输出变为缓冲行形式Q?/div><div>   -n    不把|络地址转换成名字;</div><div>   -t    在输出的每一行不打印旉戻I</div><div>   -v    输出一个稍微详l的信息Q例如在ip包中可以包括ttl和服务类型的信息Q?/div><div>   -vv    输出详细的报文信息;</div><div>   -c    在收到指定的包的数目后,tcpdump׃停止Q?/div><div>   -F    从指定的文g中读取表辑ּ,忽略其它的表辑ּQ?/div><div>   -i    指定监听的网l接口;</div><div>   -r    从指定的文g中读取包(q些包一般通过-w选项产生)Q?/div><div>   -w    直接包写入文g中,q不分析和打印出来;</div><div>   -T    监听到的包直接解释为指定的cd的报文,常见的类型有rpc Q远E过E?/div><div>调用Q和snmpQ简单       |络理协议Q)</div><div></div><div>  2. tcpdump的表辑ּ介绍</div><div>   表达式是一个正则表辑ּQtcpdump利用它作滤报文的条gQ如果一个报文满</div><div>辑ּ的条Ӟ则这个报文将会被捕获。如果没有给ZQ何条Ӟ则网l上所有的信息包将?/div><div>被截莗?/div><div>   在表辑ּ中一般如下几U类型的关键字,一U是关于cd的关键字Q主要包括hostQ?/div><div>netQport, 例如 host 210.27.48.2Q指?210.27.48.2是一C机,net 202.0.0.0 指明</div><div>202.0.0.0是一个网l地址Qport 23 指明端口h23。如果没有指定类型,~省的类型是</div><div>host.</div><div>   W二U是定传输方向的关键字Q主要包括src , dst ,dst or src, dst and src ,</div><div>q些关键字指明了传输的方向。D例说明,src 210.27.48.2 ,指明ip包中源地址?10.27.</div><div>48.2 , dst net 202.0.0.0 指明目的|络地址?02.0.0.0 。如果没有指明方向关键字Q则</div><div>~省是src or dst关键字?/div><div>   W三U是协议的关键字Q主要包括fddi,ip ,arp,rarp,tcp,udp{类型。Fddi指明是在</div><div>FDDI(分布式光U数据接口网l?上的特定的网l协议,实际上它?ether"的别名,fddi和e</div><div>therhcM的源地址和目的地址Q所以可以将fddi协议包当作ether的包q行处理和分析?/div><div>其他的几个关键字是指明了监听的包的协议内容。如果没有指定Q何协议,则tcpdump会</div><div>监听所有协议的信息包?/div><div>   除了q三U类型的关键字之外,其他重要的关键字如下Qgateway, broadcast,less,</div><div>greater,q有三种逻辑q算Q取非运是 'not ' '! ', 与运是'and','&&';或运??o</div><div>r' ,'||'Q?/div><div>   q些关键字可以组合v来构成强大的l合条g来满h们的需要,下面丑և个例子来</div><div>说明?/div><div>   (1)惌截获所?10.27.48.1 的主机收到的和发出的所有的数据包:</div><div>    #tcpdump host 210.27.48.1 </div><div>   (2) 惌截获L210.27.48.1 和主?10.27.48.2 ?10.27.48.3的通信Q用命?/div><div>Q(在命令行中适用   括号Ӟ一定要</div><div>    #tcpdump host 210.27.48.1 and \ (210.27.48.2 or 210.27.48.3 \) </div><div>   (3) 如果惌获取L210.27.48.1除了和主?10.27.48.2之外所有主机通信的ip?/div><div>Q用命令:</div><div>    #tcpdump ip host 210.27.48.1 and ! 210.27.48.2</div><div>   (4)如果惌获取L210.27.48.1接收或发出的telnet包,使用如下命oQ?/div><div>    #tcpdump tcp port 23 host 210.27.48.1 </div><div></div><div>  3. tcpdump 的输出结果介l?/div><div>   下面我们介绍几种典型的tcpdump命o的输Z?/div><div>   (1) 数据链\层头信息</div><div>   使用命o#tcpdump --e host ice</div><div>   ice 是一台装有linux的主机,她的MAC地址?Q?0Q?7Q?8QAFQ?A</div><div>   H219是一台装有SOLARIC的SUN工作站,它的MAC地址?Q?Q?0Q?9Q?BQ?6Q上一?/div><div>命o的输出结果如下所C:</div><div>21:50:12.847509 eth0 < 8:0:20:79:5b:46 0:90:27:58:af:1a ip 60: h219.33357 > ice.</div><div>telne</div><div>t 0:0(0) ack 22535 win 8760 (DF)</div><div>  分析Q?1Q?0Q?2是显C的旉Q?847509是IDPeth0 <表示从网l接口eth0 接受?/div><div>数据包,eth0 >表示从网l接口设备发送数据包, 8:0:20:79:5b:46是主机H219的MAC地址,?/div><div>表明是从源地址H219发来的数据包. 0:90:27:58:af:1a是主机ICE的MAC地址,表示该数据包?/div><div>目的地址是ICE . ip 是表明该数据包是IP数据?60 是数据包的长? h219.33357 > ice.</div><div>telnet 表明该数据包是从LH219?3357端口发往LICE的TELNET(23)端口. ack 22535</div><div>表明对序列号?22535的包q行响应. win 8760表明发送窗口的大小?760.</div><div></div><div>  (2) ARP包的TCPDUMP输出信息</div><div>   使用命o#tcpdump arp </div><div>   得到的输出结果是Q?/div><div>  22:32:42.802509 eth0 > arp who-has route tell ice (0:90:27:58:af:1a)</div><div>  22:32:42.802902 eth0 < arp reply route is-at 0:90:27:12:10:66 (0:90:27:58:af</div><div>:1a)</div><div>  分析: 22:32:42是时间戳, 802509是ID? eth0 >表明从主机发数据? arp表明?/div><div>ARPh? who-has route tell ice表明是主机ICEhLROUTE的MAC地址?0:90:27:5</div><div>8:af:1a是主机ICE的MAC地址?/div><div></div><div>  (3) TCP包的输出信息</div><div>   用TCPDUMP捕获的TCP包的一般输Z息是Q?/div><div>  src > dst: flags data-seqno ack window urgent options</div><div>  src > dst:表明从源地址到目的地址, flags是TCP包中的标志信?S 是SYN标志, F (F</div><div>IN), P (PUSH) , R (RST) "." (没有标记); data-seqno是数据包中的数据的顺序号, ack?/div><div>下次期望的顺序号, window是接收缓存的H口大小, urgent表明数据包中是否有紧急指? </div><div>Options是选项.</div><div></div><div>  (4) UDP包的输出信息</div><div>   用TCPDUMP捕获的UDP包的一般输Z息是Q?/div><div>  route.port1 > ice.port2: udp lenth</div><div>  UDP十分单,上面的输表明从主机ROUTE的port1端口发出的一个UDP数据包到L</div><div>ICE的port2端口Q类型是UDPQ?包的长度是lenth <br />=====================================================<br /><div><div class="wmqeeuq" id="appShareTitle" style="word-wrap: break-word; height: 24px; line-height: 24px; font-weight: bold; color: #333333; font-family: arial; background-color: #f4f8fb; ">tcpdump抓包分析详解</div><div class="wmqeeuq" id="appShareOpt" style="word-wrap: break-word; text-align: right; margin-bottom: 10px; margin-right: 5px; line-height: 24px; font-family: arial; background-color: #f4f8fb; "></div><div class="wmqeeuq" id="app-share-content" style="word-wrap: break-word; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #edf1f4; border-right-color: #edf1f4; border-bottom-color: #edf1f4; border-left-color: #edf1f4; border-image: initial; background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; background-color: #f4f8fb; padding-top: 20px; padding-right: 20px; padding-bottom: 20px; padding-left: 20px; color: #9a9a9a; font-size: 12px; font-family: arial; "><div style="word-wrap: break-word; ">說實在的Q對?tcpdump 這個軟體來說,你甚臛_以說這個軟體其實就是個駭客軟體, 因為他不但可以分析封包的向Q連封包的內容也可以進行『監聽』, 如果你用的傌資料是明的話,不得了,?router 上面可能被人家監聽CQ?很可怕吶Q所以,我們也要來瞭解一下這個軟體啊Q?a:這?tcpdump 必須使用 root 的n份執?<br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>tcpdump [-nn] [-i 介面] [-w 儲存檔名] [-c ơ數] [-Ae]</strong> <strong> [-qX] [-r 檔案] [所Ʋ擷取的資料內容]</strong> 參數Q?-nnQ直接以 IP ?port number 示Q而非L名與服務名稱 -i Q後面接要『監聽』的E\介面Q例?eth0, lo, ppp0 {等的介面; -w Q如果你要將監聽所得的包資料儲存下來Q用這個參數就了Q後面接檔名 -c Q監聽的包數,如果沒有這個參數, tcpdump 會持U不L監聽Q? 直到使用者?[ctrl]-c 為止?-A Q封包的內容?ASCII 示Q通常用來捉取 WWW 的網頁封包資料?-e Q用資料連接?(OSI W二? ?MAC 包資料來顯C; -q Q僅列出較為短的封包資a,每一行的內容比較_ -X Q可以列出十六進位 (hex) 以及 ASCII 的封包內容,於監聽包內容很有?-r Q從後面接的檔案封包資料讀Z。那個『檔案』是已經存在的檔案, 並且這個『檔案』是?-w 所製作Z的?所Ʋ擷取的資料內容Q我們可以專門針對某些通訊協定或者是 IP 來源進行包擷取Q? 那就可以化輸出的結果,並取得最有用的資a。常見的表示Ҏ有: 'host foo', 'host 127.0.0.1' Q針單部主來進行包擷取 'net 192.168' Q針某個網域來進行包的擷取; 'src host 127.0.0.1' 'dst net 192.168'Q同時加上來?src)或目?dst)限制 'tcp port 21'Q還可以針對通訊協定偉|Q如 tcp, udp, arp, ether {? 還可以利?and ?or 來進行包資料的整合顯C呢Q? 例一Q以 IP ?port number 捉下 eth0 這個網路卡上的包Q持U?3 U?[root@linux ~]# <strong>tcpdump -i eth0 -nn</strong> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 01:33:40.41 IP 192.168.1.100.22 > 192.168.1.11.1190: P 116:232(116) ack 1 win 9648 01:33:40.41 IP 192.168.1.100.22 > 192.168.1.11.1190: P 232:364(132) ack 1 win 9648 <==按下 [ctrl]-c 之後i束 6680 packets captured <==捉下來的包敔R 14250 packets received by filter <==由過Ⱦ所得的^封包數?7512 packets dropped by kernel <==被核心所丟棄的封?/pre></td></tr></tbody></table>如果你是W一ơ看 tcpdump ?man page 時,肯定一個頭兩個大Q因?tcpdump q乎都是分析包的表頭資料,使用者如果沒有簡易的E\包基礎Q要看懂_難Ӟ 所以,臛_您得要回?a style="color: #1463c4; text-decoration: none; ">E\基礎</a>裡面d TCP 包的表頭資料理解理解才好啊Q?^_^Q至於那個範例一所產生的出範例中Q我們可以約略區分為數個欄位, 我們以例一當中那個特D字體行來說明一下:<br /><ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">01:33:40.41Q這個是此封包被擷取的時間,『時:?U』的單位Q?/li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">IPQ透過的通訊協定?IP Q?/li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">192.168.1.100.22 > Q傳送端?192.168.1.100 這?IPQ而傳送的 port number ?22Q您必須要瞭解的是,那個大?(>) 的符號指的是包的傳輸方向喔Q?/li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">192.168.1.11.1190Q接收端?IP ?192.168.1.11Q?且該L開啟 port 1190 來接Ӟ</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">P 116:232(116)Q這個封包帶?PUSH 的資料傳輸標誌, 且傳輸的資料為整體資料的 116~232 byteQ所以這個封包帶?116 bytes 的資料量Q?/li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">ack 1 win 9648QACK?Window size 的相關資料?/li></ul>最單的說法,是該封包是?192.168.1.100 傛_ 192.168.1.11Q透過?port 是由 22 ?1190 Q?且帶?116 bytes 的資料量Q用的?PUSH 的旗標,而不?SYN 之類的主動連線標誌?呵呵Q不Ҏ看的懂吧Q所以說Q上頭才請務必?nbsp;<a style="color: #1463c4; text-decoration: none; ">TCP 表頭資料</a>的部分去瞧一瞧的啊!<br /><br />再來Q一個網路狀態很忙的L上面Q你惌取得某部L你連線的封包資料而已時, 使用 tcpdump 配合線命o與正規表C法也可以,不過Q畢竟不好捉取! 我們可以透過 tcpdump 的表C法功能Q就能夠輕易的將所需要的資料獨立的取Z?在上面的例一當中Q我們僅針對 eth0 做監聽,所以整?eth0 介面上面的資料都會被示到螢q上Q?不好分析啊!那麼我們可以簡化嗎Q例如只取出 port 21 的連線包Q可以這樣做:<br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>tcpdump -i eth0 -nn port 21</strong> tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on eth0, link-type EN10MB (Ethernet), capture size 96 bytes 01:54:37.96 IP 192.168.1.11.1240 > 192.168.1.100.21: . ack 1 win 65535 01:54:37.96 IP 192.168.1.100.21 > 192.168.1.11.1240: P 1:21(20) ack 1 win 5840 01:54:38.12 IP 192.168.1.11.1240 > 192.168.1.100.21: . ack 21 win 65515 01:54:42.79 IP 192.168.1.11.1240 > 192.168.1.100.21: P 1:17(16) ack 21 win 65515 01:54:42.79 IP 192.168.1.100.21 > 192.168.1.11.1240: . ack 17 win 5840 01:54:42.79 IP 192.168.1.100.21 > 192.168.1.11.1240: P 21:55(34) ack 17 win 5840</pre></td></tr></tbody></table>瞧!這樣僅提出 port 21 的資a而已Q且仔細看的話,你會發現包的傳遞都是雙向的Q?client 端發出『要求』?server 端則予以『回應』,所以,當然是有L回啊Q?而我們也可以經過這個封包的向來瞭解到包運作的過E?舉例來說Q?ol style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: none; list-style-position: outside; list-style-type: none; ">我們先在一個終端機視窗輸入?tcpdump -i lo -nn ?的監聽,</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: none; list-style-position: outside; list-style-type: none; ">再另開一個終端機視窗來對本機 (127.0.0.1) d『ssh localhost?/li></ol>那麼輸出的結果會是如何?<br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>tcpdump -i lo -nn</strong> 1 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode 2 listening on lo, link-type EN10MB (Ethernet), capture size 96 bytes 3 11:02:54.253777 IP 127.0.0.1.32936 > 127.0.0.1.22: S 933696132:933696132(0) win 32767 <mss 16396,sackOK,timestamp 236681316 0,nop,wscale 2> 4 11:02:54.253831 IP 127.0.0.1.22 > 127.0.0.1.32936: S 920046702:920046702(0) ack 933696133 win 32767 <mss 16396,sackOK,timestamp 236681316 236681316,nop, wscale 2> 5 11:02:54.253871 IP 127.0.0.1.32936 > 127.0.0.1.22: . ack 1 win 8192 <nop, nop,timestamp 236681316 236681316> 6 11:02:54.272124 IP 127.0.0.1.22 > 127.0.0.1.32936: P 1:23(22) ack 1 win 8192 <nop,nop,timestamp 236681334 236681316> 7 11:02:54.272375 IP 127.0.0.1.32936 > 127.0.0.1.22: . ack 23 win 8192 <nop, nop,timestamp 236681334 236681334></pre></td></tr></tbody></table>上表示的頭兩行?tcpdump 的基本說明,然後Q?ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; "><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">W?3 行顯C的是『來?client 端,帶有 SYN d連線的封包』,</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">W?4 行顯C的是『來?server 端,除了回應 client 端之?ACK)Q還帶有 SYN d連線的標誌;</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">W?5 行則示 client 端回?server 定連線建立 (ACK)</li><li style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-image: initial; list-style-position: initial; list-style-type: none; ">W?6 行以後則開始進入資料傌的步驟?/li></ul>從第 3-5 行的程來看Q熟不熟悉啊Q沒錯!那就?nbsp;<a style="color: #1463c4; text-decoration: none; ">三向交握</a> 的基C流E啦Q夠有趣吧! 不過 tcpdump 之所以被Eq駭客軟體之一可不止上頭介紹的功能Ӟ 上面介紹的功能可以用來作為我們主的包連線與傳輸的程分析Q?這將有助於我們瞭解到包的運作,同時瞭解C的防火牆設定規則是否有需要修a的地方?br /><br />更神奇的使用要來啦!如果我們?tcpdump ?router 上面監聽『明{的傌資料時, 例如 FTP 傌協定Q你覺得會發生什麼問呢Q?我們先在主端下達?tcpdump -i lo port 21 -nn -X 』然後再?ftp d本機Q並輸入希與密| i果你就可以發現如下的狀況:<br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>tcpdump -i lo -nn -X 'port 21'</strong> 0x0000: 4500 0048 2a28 4000 4006 1286 7f00 0001 E..H*(@.@....... 0x0010: 7f00 0001 0015 80ab 8355 2149 835c d825 .........U!I.\.% 0x0020: 8018 2000 fe3c 0000 0101 080a 0e2e 0b67 .....<.........g 0x0030: 0e2e 0b61 3232 3020 2876 7346 5450 6420 ...a220.(vsFTPd. 0x0040: 322e 302e 3129 0d0a 2.0.1).. 0x0000: 4510 0041 d34b 4000 4006 6959 7f00 0001 E..A.K@.@.iY.... 0x0010: 7f00 0001 80ab 0015 835c d825 8355 215d .........\.%.U!] 0x0020: 8018 2000 fe35 0000 0101 080a 0e2e 1b37 .....5.........7 0x0030: 0e2e 0b67 5553 4552 2064 6d74 7361 690d ...gUSER.dmtsai. 0x0040: 0a . 0x0000: 4510 004a d34f 4000 4006 694c 7f00 0001 E..J.O@.@.iL.... 0x0010: 7f00 0001 80ab 0015 835c d832 8355 217f .........\.2.U!. 0x0020: 8018 2000 fe3e 0000 0101 080a 0e2e 3227 .....>........2' 0x0030: 0e2e 1b38 5041 5353 206d 7970 6173 7377 ...8PASS.mypassw 0x0040: 6f72 6469 7379 6f75 0d0a ordisyou..</pre></td></tr></tbody></table>上面的出結果已E被化過了Q你必須要自行在你的輸出i果當中搜尋盔R的字串才行?從上面出結果的Ҏ字體中,我們可以發現『該 FTP 軟體使用的是 vsftpd Q並且用者?dmtsai 這個x號名E,且密是 mypasswordisyou?嘿嘿Q你說可不可怕啊Q如果用的是明的方式來傳怽的網路資料? 所以我們才常常在講啊,E\是很不安全低Q?br /><br />另外你得瞭解Q為了讓E\介面可以?tcpdump 監聽Q所以執?tcpdump 時網路介面會啟動?『錯亂模?(promiscuous)』,所以你會在 /var/log/messages 裡面看到很多的警告訊息, 通知你說你的E\卡被a定成為錯亂模式Q別擔心Q那是正常的?x更多的應用,請參?man tcpdump 囉!<br /><br /><table cellspacing="0" cellpadding="5" width="90%" border="1" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; ">例題Q如何?tcpdump 監聽 (1)來自 eth0 介面卡且 (2)通訊協定?port 22 Q?3)目標來源?192.168.1.100 的封包資料?<br /><br />{:<ul style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; list-style-type: none; list-style-position: initial; list-style-image: initial; ">tcpdump -i eth0 -nn 'port 22 and src host 192.168.1.100'</ul></td></tr></tbody></table></div><hr /><a name="ethereal" style="color: rgb(20, 99, 196); text-decoration: none; "></a><img height="23" alt="標的圖示" width="16" align="middle" src="http://linux.vbird.org/images/penguin-s.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><strong>ethereal<br /></strong><div style="word-wrap: break-word; ">除了 tcpdump 這個軟體之外,其實你還可以使用 ethereal 這個好用的E\量分析軟體Ӟ ethereal 分為文字介面與圖形介面,文字介面的用法與 tcpdump 相當的類|不過他的指o名稱?tethereal 是了。因為用法差不多Q所以徏議您直接使用 man tethereal 查閱吧! ?CentOS 上原本就?ethereal 了,所以請拿出光碟來安裝即可喔Q?需要安?ethereal ?ethereal-gnome 才行Ӟ<br /><br />啟動的方法很單Q你必須要在 X Window 底下Q先開啟一個終端機Q然後直接?ethereal 後, 會出現如下的畫面了Q?br /><br /><center><img title="ethereal 使用例? alt="ethereal 使用例? src="http://linux.vbird.org/linux_server/0140networkcommand/ethereal_1.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br />圖五、ethereal 使用例?/center><br />單的作法,你可以點選如上圖示的那個按鈕,會出現挑選監聽的介面視窗Q如下所C:<br /><br /><center><img title="ethereal 使用例? alt="ethereal 使用例? src="http://linux.vbird.org/linux_server/0140networkcommand/ethereal_2.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br />圖六、ethereal 使用例?/center><br />你應該選擇要監聽的介面,在這裡因為是測試用的,所以郔哥用的?lo 這個內部介面, 你當然應該要選擇你自qE\介面才是。然後按?start 後,會出現開始偉|的畫面了Q?br /><br /><center><img title="ethereal 使用例? alt="ethereal 使用例? src="http://linux.vbird.org/linux_server/0140networkcommand/ethereal_3.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br />圖七、ethereal 使用例?/center><br />在這個畫面當中你可以看到很多型的封包協定,在等你處理完畢後Q就可以按下『stop』結束監聽, 而開始進入如下的封包分析畫面?br /><br /><center><img title="ethereal 使用例? alt="ethereal 使用例? src="http://linux.vbird.org/linux_server/0140networkcommand/ethereal_4.jpg" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><br />圖八、ethereal 使用例?/center><br />包分析畫面共分Z大區塊,如上圖所C,W一區塊主要顯C的是封包的標頭資料Q?內容有點類?tcpdump 的顯C結果,W二區塊則是詳細的表頭資料Q?包括a框的內宏V通訊協定的內容以?socket pair {等資訊?W三區塊則?16 進位?ASCII 的示i果。透過這?ethereal 您就可以一口氣得到所需要的所有封包內容啦Q?而且還是圖Ş介面的,很方便吧Q透過在第一區塊選擇不同的包Q就能夠查閱每個封包的資料內容囉!</div><hr /><a name="nc" style="color: rgb(20, 99, 196); text-decoration: none; "></a><img height="23" alt="標的圖示" width="16" align="middle" src="http://linux.vbird.org/images/penguin-s.gif" style="border-top-width: 0px; border-right-width: 0px; border-bottom-width: 0px; border-left-width: 0px; border-style: initial; border-color: initial; border-image: initial; border-top-style: none; border-right-style: none; border-bottom-style: none; border-left-style: none; border-width: initial; border-color: initial; " /><strong>nc, netcat<br /></strong><div style="word-wrap: break-word; ">這?nc 可以用來作為某些服務的檢測,因為他可以連接到某?port 來進行溝通, 此外Q還可以自行啟動一?port 來傾聽其他用戶的連線Ӟ非常的不錯用Q?如果在編譯的時候予『GAPING_SECURITY_HOLE』參數的話,嘿嘿Q?這個軟體還可以用來取得用戶端的 bash 哩!可怕吧Q我們的 CentOS 比較人性化Q並沒有i予上面的參數,所以我們不能夠用來作為駭客軟體?但是用來取代 telnet 也是個很的功能了!(有的pȝ執行檔改名?netcat 啦!)<br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>nc [IP|host] [port]</strong> [root@linux ~]# <strong>nc -l -p [port]</strong> 參數Q?-l Q作為監聽之用,亦即開啟一?port 來監聽用戶的連線Q?-p Q開啟的這?port number 例一Q連接本地端的 port 25 查閱盔Ra息 [root@linux ~]# <strong>nc localhost 25</strong> localhost.localdomain [127.0.0.1] 25 (smtp) open 220 pc.dm.tsai ESMTP Postfix <strong>ehlo localhost</strong> 250-pc.dm.tsai 250-PIPELINING 250-SIZE 40000000 250-ETRN <strong>quit</strong> 221 Bye</pre></td></tr></tbody></table>這個最單的功能與 telnet q乎一樣吧Q可以去檢查某個服務啦Q不過,更神奇的在後面, 我們可以徏立兩個連線來傳a喔Q舉個例子來說,我們先?client 端的地方啟動一?port 來進行傾聽Q?br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>例二:啟動一?port 來監聽用者的連線要求 [root@linux ~]# <strong>nc -l -p 20000</strong> # 啟動一?port 20000 在主上Q如果此時?netstat -tlnp # 可以看到系i׃多出來一?port 20000 在傾聽用者的連線喔!</pre></td></tr></tbody></table>然後在主端的地方,也利?nc 來連線到用戶端Q並且入一些指令看看喔Q?br /><table fck__showtableborders"="" style="border-collapse: collapse; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; "><tbody><tr><td style="word-wrap: break-word; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 0px; "><pre>[root@linux ~]# <strong>nc localhost 20000</strong> <==這裡可以開始輸入字串了!</pre></td></tr></tbody></table>此時Q在L端我們可以打入一些字Q你會發珑֜ client 端會同時出現你入的字眼Ӟ 如果你同時予一些額外的參數Q例如利用標準入與輸出 (stdout, stdin) 的話Q?那麼可以透過這個連線來作很多事情了! 當然 nc 的功能不只如此,你還可以發現很多的用途喔Q?請自行到您主內?/usr/share/doc/nc-1.10/scripts 目錄下看看這些 script Q有q助的吶Q?不過Q如果你需要額外的R譯出含?GAPING_SECURITY_HOLE 功能Q?以兩端</div></div><div class="wmqeeuq" id="appShareUrl" style="word-wrap: break-word; font-size: 12px; color: #999999; margin-top: 10px; border-top-width: 1px; border-top-style: solid; border-top-color: #f4f4f4; font-family: arial; background-color: #f4f8fb; clear: both; ">来自: <a target="_blank" style="color: #9a9a9a; text-decoration: none; ">http://hi.baidu.com/june2june/blog/item/84a66865ea77acf8f73654ea.html</a></div></div></div></div><img src ="http://www.aygfsteel.com/Todd/aggbug/369460.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Todd/" target="_blank">Todd</a> 2012-02-06 10:38 <a href="http://www.aygfsteel.com/Todd/archive/2012/02/06/369460.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>mysql root 密码http://www.aygfsteel.com/Todd/archive/2011/12/13/366196.htmlToddToddMon, 12 Dec 2011 19:18:00 GMThttp://www.aygfsteel.com/Todd/archive/2011/12/13/366196.htmlhttp://www.aygfsteel.com/Todd/comments/366196.htmlhttp://www.aygfsteel.com/Todd/archive/2011/12/13/366196.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/366196.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/366196.html

Todd 2011-12-13 03:18 发表评论
]]>
java heap spaceQ?PermGen space 错误 使用jvisualvm监测讄合理?/title><link>http://www.aygfsteel.com/Todd/archive/2011/10/18/361543.html</link><dc:creator>Todd</dc:creator><author>Todd</author><pubDate>Tue, 18 Oct 2011 14:16:00 GMT</pubDate><guid>http://www.aygfsteel.com/Todd/archive/2011/10/18/361543.html</guid><wfw:comment>http://www.aygfsteel.com/Todd/comments/361543.html</wfw:comment><comments>http://www.aygfsteel.com/Todd/archive/2011/10/18/361543.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.aygfsteel.com/Todd/comments/commentRss/361543.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/Todd/services/trackbacks/361543.html</trackback:ping><description><![CDATA[使用myeclipse启动tomcat 报java heap space QPermGen space 错误Q分别ؓ heap内存不QPermGen内存不<br />需加大 tomcat启动参?Xmx ?nbsp;XX:MaxPermSize<br />PermGen是指内存的永久保存区域,它用于存放class?method 对象Q以及String 对象<br />Qsun原文Qpermanent generation is the area of the heap where class and method objects are stored. If an application loads a very large number of classes, then the size of the permanent generation might need to be increased using the -XX:MaxPermSize option. <div>Interned java.lang.String objects are also stored in the permanent generation. The java.lang.String class maintains a pool of strings. When the intern method is invoked, the method checks the pool to see if an equal string is already in the pool. If there is, then the intern method returns it; otherwise it adds the string to the pool. In more precise terms, the java.lang.String.intern method is used to obtain the canonical representation of the string; the result is a reference to the same class instance that would be returned if that string appeared as a literal. If an application interns a huge number of strings, the permanent generation might need to be increased from its default setting. </div> <div>When this kind of error occurs, the text String.intern or ClassLoader.defineClass might appear near the top of the stack trace that is printed. </div> <div>The jmap -permgen command prints statistics for the objects in the permanent generation, including information about internalized String instances. See 2.6.4 Getting Information on the Permanent Generation.</div>Q?br />PermGen又是一个特D内存区域:Classloader 加蝲的东东是不能回收的,它们攑֜PermGen?br />Qtomcat原文QWhy does the memory usage increase when I redeploy a web application? Because the Classloader (and the Class objects it loaded) cannot be recycled. They are stored in the permanent heap generation by the JVM, and when you redepoy a new class loader is created, which loads another copy of all these classes. This can cause OufOfMemoryErrors eventually.Q?br /><br />回到我的问题来,打开%java_home%bin\jvisualvm.exe  (jdk6以上?<br />查看tomcat的内存情况,点击tomcat标签下monitor , 当used heap = max heap      used PermGen = max PermGen 时tomcatq在启动中,一会就报错Q?br />׃此前已经myeclipse中server->tomcat->tomcatx.x->jdk的参数设|成-Xms64m -Xmx512m -XX:MaxPermSize=80m<br />但是monitor 画面中max heap?256M<br />点击overview标签,发现jvm参数如下Q?br />-Xms64m<br />-Xmx512m<br />-XX:MaxPermSize=80m<br />-Xms64m<br />-Xmx256m<br /><br />昄tomcat使用了最后的讄-Xms64m -Xmx256mQ这个是在myeclipse的属?》java->installed jres 中的vm启动参数里,双击默认启用的jreQ把参数L或者设|成-Xms64m -Xmx512m<br />再回到server->tomcat->tomcatx.x->jdk中把-XX:MaxPermSize=80m修改?XX:MaxPermSize=128m<br />保存后再启动tomcatQok<br /><br />另外Q用jvisualvm持箋监测tomcat内存情况发现heap区域的内存用会在一个高峰后E_降低Q内存被回收了;<br />而PermGen区域的内存则是不断增加到达一个峰值后׃再增加,但之后此区的内存没有被回Ӟ验证了上面的说法Q?br /><br />多说两句Qjava的动态加载衍生出诸多框架Q在I间上也暴露出问题,反射在时间上也存在效率问题:下面是组试数据Q?br /> <p>Java version 1.6.0_13<br />Java HotSpot(TM) Client VM<br />11.3-b02<br />Sun Microsystems Inc.</p> <p>Direct access using member field:<br /> 47 125 47 46 46<br /> average time = 66 ms.<br />Reference access to member field:<br /> 109 109 110 94 109<br /> average time = 106 ms.<br />Reflection access to member field:<br /> 13094 12984 13063 13062 13094<br /> average time = 13051 ms.</p> <p>Java version 1.6.0_13<br />Java HotSpot(TM) Client VM<br />11.3-b02<br />Sun Microsystems Inc.</p> <p>Direct call using member field:<br /> 47 31 109 109 31<br /> average time = 70 ms.<br />Direct call using passed value:<br /> 16 16 16 31 15<br /> average time = 20 ms.<br />Call to object using member field:<br /> 46 47 47 47 32<br /> average time = 43 ms.<br />Call to object using passed value:<br /> 15 16 31 16 16<br /> average time = 20 ms.<br />Reflection call using member field:<br /> 812 782 844 844 844<br /> average time = 829 ms.<br />Reflection call using passed value:<br /> 938 953 954 1031 953<br /> average time = 973 ms.</p> <p>Java version 1.6.0_13<br />Java HotSpot(TM) Client VM<br />11.3-b02<br />Sun Microsystems Inc.</p> <p>Direct Object creation:<br /> 62 47 78 32 93<br /> average time = 63 ms.<br />Reflection Object creation:<br /> 125 94 94 109 187<br /> average time = 121 ms.<br />Direct byte[8] creation:<br /> 125 187 94 172 94<br /> average time = 137 ms.<br />Reflection byte[8] creation:<br /> 266 171 187 188 219<br /> average time = 191 ms.<br />Direct byte[64] creation:<br /> 250 172 156 125 203<br /> average time = 164 ms.<br />Reflection byte[64] creation:<br /> 281 219 203 203 219<br /> average time = 211 ms.</p>华丽的上层需要坚实的底层基础<br /><br /><a >http://wiki.apache.org/tomcat/FAQ/Deployment</a><br /><a >http://download.oracle.com/javase/7/docs/webnotes/tsg/TSG-VM/html/memleaks.html#gbyuu</a><br /><br /><img src ="http://www.aygfsteel.com/Todd/aggbug/361543.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/Todd/" target="_blank">Todd</a> 2011-10-18 22:16 <a href="http://www.aygfsteel.com/Todd/archive/2011/10/18/361543.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>java反射效率试 jdk6http://www.aygfsteel.com/Todd/archive/2011/09/22/359221.htmlToddToddWed, 21 Sep 2011 23:18:00 GMThttp://www.aygfsteel.com/Todd/archive/2011/09/22/359221.htmlhttp://www.aygfsteel.com/Todd/comments/359221.htmlhttp://www.aygfsteel.com/Todd/archive/2011/09/22/359221.html#Feedback0http://www.aygfsteel.com/Todd/comments/commentRss/359221.htmlhttp://www.aygfsteel.com/Todd/services/trackbacks/359221.html

Java version 1.6.0_13
Java HotSpot(TM) Client VM
11.3-b02
Sun Microsystems Inc.

Direct access using member field:
 47 125 47 46 46
 average time = 66 ms.
Reference access to member field:
 109 109 110 94 109
 average time = 106 ms.
Reflection access to member field:
 13094 12984 13063 13062 13094
 average time = 13051 ms.

Java version 1.6.0_13
Java HotSpot(TM) Client VM
11.3-b02
Sun Microsystems Inc.

Direct call using member field:
 47 31 109 109 31
 average time = 70 ms.
Direct call using passed value:
 16 16 16 31 15
 average time = 20 ms.
Call to object using member field:
 46 47 47 47 32
 average time = 43 ms.
Call to object using passed value:
 15 16 31 16 16
 average time = 20 ms.
Reflection call using member field:
 812 782 844 844 844
 average time = 829 ms.
Reflection call using passed value:
 938 953 954 1031 953
 average time = 973 ms.

Java version 1.6.0_13
Java HotSpot(TM) Client VM
11.3-b02
Sun Microsystems Inc.

Direct Object creation:
 62 47 78 32 93
 average time = 63 ms.
Reflection Object creation:
 125 94 94 109 187
 average time = 121 ms.
Direct byte[8] creation:
 125 187 94 172 94
 average time = 137 ms.
Reflection byte[8] creation:
 266 171 187 188 219
 average time = 191 ms.
Direct byte[64] creation:
 250 172 156 125 203
 average time = 164 ms.
Reflection byte[64] creation:
 281 219 203 203 219
 average time = 211 ms.

 



Todd 2011-09-22 07:18 发表评论
]]>
վ֩ģ壺 | ɽ| | | ˮ| | | ˮ| | ˳| | | | | Դ| ػ| | Ȫ| | ɣ| | | | | ³| | | ˮ| | ̩| ¡| ¡| | ߱| | | ̩| | Դ| | ³|