Äú¿ÉÒÔ¶ÔÓ¦ÓóÌÐò½øÐиú×Ù£¬ÒÔÕÒ³öËüÃÇÔÝÍ£»ò²»ÔËÐеÄÔÒò¡£²¢ÇÒ¿ÉÒÔʹÓÃͬÑùµÄ·½·¨£¬Á˽â¸ü¶à¹ØÓÚÓ¦ÓóÌÐòµÄÐÅÏ¢²¢Àí½âijЩÅäÖõÄÐÔÄܺ¬Òå¡£ÒòΪ Apache ·Ç³£Á÷Ðв¢ÇÒ´ó¶àÊý¶ÁÕ߶ÔËü¶¼±È½ÏÊìϤ£¬ËùÒÔ±¾ÎÄʹÓà Apache ×÷ΪʾÀý¡£Apache Ëù½øÐеÄÿ´Îϵͳµ÷Óö¼»á¶Ô Web Ò³ÃæµÄÌṩ´øÀ´ÑÓ³Ù£¬Í¨¹ý¸ú×Ù²»Í¬ÅäÖÃÏ嵀 Web ·þÎñÆ÷£¬Äú¿ÉÒÔÈ·¶¨¾ßÌåÅäÖõÄÓ°Ïì¡£
Ó¦ÓóÌÐò¸ú×Ù¸ÅÊö
ÔÚÓ¦ÓóÌÐòµÄÖ´Ðйý³ÌÖУ¬µ±ÐèÒª´ò¿ªÎļþ¡¢·¢ËÍÊý¾Ý°ü»òÕßʹÓÃϵͳ×ÊԴʱ£¬Ëü»á¶Ô»ù´¡²Ù×÷ϵͳ½øÐÐÏàÓ¦µÄϵͳµ÷Ó᣸ú×ÙÓ¦ÓóÌÐòÒâζ×Å¿ÉÒÔÔÚµ÷Ó÷¢Éúʱ¹Û²ìµ½ÕâЩϵͳµ÷Óã¬Õ⽫ʹµÃÄúÄܹ»ÉîÈëµØÁ˽â¸ÃÓ¦ÓóÌÐòµÄÐÐΪ¡£ÔÚ Solaris ºÍ IBM AIX® ²Ù×÷ϵͳ (AIX) ÖУ¬Ê¹Óà truss ÃüÁîÍê³ÉÕâÏîÈÎÎñ£¬¶øÔÚ Linux® ÖÐÔòʹÓà strace¡£Çåµ¥ 1 ÏÔʾÁË¶Ô pwd ÃüÁî½øÐиú×ÙµÄʾÀý¡£
Çåµ¥ 1. ¸ú×Ù pwd ÃüÁî
[code]-bash-3.00$ truss pwd
...
getcwd("/export/home/sean", 1025) = 0
/export/home/sean
write(1, " / e x p o r t / h o m e".., 18) = 18
_exit(0)[/code]
ÔÚɾ³ý¿ªÊ¼´¦Óë¼ÓÔظÃÓ¦ÓóÌÐòÏà¹ØµÄÊä³öÄÚÈݺó£¬Äú¿ÉÒÔ¿´µ½Ëù½øÐеÄÈý´Îϵͳµ÷Óãº
getcwd ·µ»Øµ±Ç°¹¤×÷Ŀ¼¡£Êä³öÄÚÈÝÖÐÏÔʾÁË×Ö·û´®¡°/export/home/sean¡±·µ»Øµ½»º³åÇø¡£
write ¿ÉÒÔÏÔʾ¸ø¶¨µÄ×Ö·û´®¡£ÒòΪÔÚÆäÖ´ÐÐÖ®ºó²ÅÏÔʾÕâ¸öϵͳµ÷Óã¬ËùÒÔÏÈÊä³öÁËËüµÄÖ´Ðнá¹û¡£»¹¿ÉÒÔ×¢Òâµ½£¬write ϵͳµ÷ÓõĽá¹ûÊÇдÈë×Ö·ûµÄ¸öÊýÊýÄ¿£¬ÔÚÕâ¸öʾÀýÖÐΪ 17 ¼ÓÉÏÒ»¸ö»Ø³µ¡£
_exit ʹÓôíÎó´úÂë 0 Í˳ö¸Ã³ÌÐò£¬Õâ¸ö´íÎó´úÂëͨ³£±íʾ³É¹¦½áÊø¡£
¾¡¹ÜÕâÊÇÒ»¸öºÜ¼òµ¥µÄʾÀý£¬µ«ËüÑÝʾÁËͨ¹ýÓ¦ÓóÌÐò¸ú×Ù¿ÉÒÔ¹Û²ì³ÌÐòÄÚ²¿»úÖƵij̶ȡ£Óйظú×Ù·½Ãæ¸üÉîÈëµÄÐÅÏ¢£¬Çë²Î¼û²Î¿¼×ÊÁϲ¿·Ö¡£
Apache ÅäÖõļòÒª½éÉÜ
¿ÉÒÔͨ¹ýÒ»¸öÃûΪ httpd.conf µÄÎļþ¶Ô Apache Web ·þÎñÆ÷½øÐÐÅäÖá£Çåµ¥ 2 ÏÔʾÁËÒ»¸ö¼òµ¥ÅäÖÃÖеIJ¿·ÖÄÚÈÝ¡£
Çåµ¥ 2. ʾÀý httpd.conf
[code]DocumentRoot "/var/apache/htdocs"
Options FollowSymLinks
AllowOverride None
Options Indexes FollowSymLinks MultiViews
µÚÒ»Ðж¨ÒåÁËÔںδ¦¿ÉÒÔÕÒµ½ HTML Îļþ¡£½«ËùÓеÄÇëÇó¶¼Ó³Éäµ½Õâ¸öĿ¼¡£Èç¹ûÇëÇó /project/charter.html£¬½«Ê¹Óà /var/apache/htdocs/project/charter.html Ìṩ¸ÃÒ³Ãæ¡£httpd.conf ÖÐÊ£ÓàµÄ²¿·ÖÓÉÁ½¸ö Directory ½Ú×é³É¡£
Èç¹û¶à¸ö½ÚÓ¦ÓÃÓÚµ¥¸öÇëÇó£¬ÄÇô½«»á¶ÔÕâЩÃüÁî½øÐÐ×éºÏ£¬²¢ÇÒ×îÊʺϵÄĿ¼¾ßÓиßÓÅÏȼ¶¡£ÀýÈ磬½«Ê¹Óà /var/apache/htdocs/project/charter.html Ìṩ /project/charter.html ÇëÇóµÄÒ³Ãæ¡£/var/apache/htdocs ÊÇ / µÄ×ÓĿ¼£¬ËùÒÔ Options Indexes FollowSymLinks MultiViews À´×ÔµÚ¶þ½Ú£¬AllowOverride None À´×ÔµÚÒ»½Ú¡£
¿ÉÒÔ¶ÔÐí¶àÄÚÈݽøÐÐÅäÖ㬲¢ÇÒÿÏîÄÚÈݶ¼¾ßÓÐÆäÐÔÄܺ¬Òå¡£±¾ÎÄÓàϵÄÄÚÈÝÖصã¹Ø×¢ÓÚÈçºÎ¶ÔÕâЩ¸Ä±äµÄÓ°Ïì½øÐÐÁ¿»¯·ÖÎö¡£
½¨Á¢»ù×¼
ÔÚÄú½øÐÐÈκε÷Õû֮ǰ£¬Îñ±ØÒªÁ˽âϵͳµ±Ç°µÄÔËÐз½Ê½¡£Ê¹Óà -X ²ÎÊýÆô¶¯ Apache£¬Õâ¸ö²ÎÊý½«Ç¿ÖÆ Apache ½øÈëµ¥½ø³Ìµ÷ÊÔģʽ¡£ÕâÑù×ö¿ÉÒÔÈ·±£½«ÇëÇó·¢Ë͵½ÕýÔÚ½øÐиú×ٵĽø³Ì£¬²¢ÇÒÏû³ý³£¹æ½ø³Ì¼äͨÐÅËù´øÀ´µÄ¿ªÏú¡£
ÔÚÊØ»¤½ø³ÌÆô¶¯Ö®ºó£¬Í¨¹ýÔËÐÐ ps -ef ÕÒµ½ÏàÓ¦µÄ½ø³Ì ID£¬²¢²éÕÒ httpd ÊØ»¤½ø³Ì¡£ÔÚÕÒµ½¸Ã½ø³ÌÖ®ºó£¬Ê¹Óà truss -c -p PID ¸½¼Óµ½¸Ã½ø³Ì¡£-c Ñ¡Ïî±íʾ¶Ôϵͳµ÷ÓýøÐмÆÊý£¬¶ø²»ÊÇÖð¸öÏÔʾËüÃÇ£¬¶ø -p Ôò±íʾ½«¸ú×ÙÆ÷¸½¼ÓÓÚÒ»¸öÕýÔÚÔËÐеĽø³Ì¡£
ʹÓà Web ä¯ÀÀÆ÷ÇëÇóÎĵµ¡£ÔÚÒ³Ãæ¼ÓÔØÖ®ºó£¬»Øµ½ truss Ó¦ÓóÌÐò£¬È»ºó°´ Ctrl-C ÒÔ½áÊø¼ÆÊý¡£¶ÔÓÚ¾²Ì¬ HTML Ò³Ã棬ÄúÓ¦¸Ã¿´µ½ÈçÇåµ¥ 3 ËùʾµÄÄÚÈÝ£¨ÎªÊ¹ÕâЩÊý×Ö±äµÃ¸üÓÐȤ£¬±¾Ê¾Àý½øÐÐÁË 100 ´ÎÏàͬµÄÇëÇ󣩡£
Çåµ¥ 3. ϵͳµ÷Óûù×¼
[code]sunbox# truss -c -p 15026
(make the Web request 100 times)
^C
syscall seconds calls errors
read .009 200
write .020 200
close .020 200
time .004 300
alarm .018 1100
fcntl .009 300
sigaction .007 400
munmap .007 100
llseek .001 100
pollsys .005 100
mmap64 .008 100
stat64 .007 100
open64 .006 100
accept .019 100
getsockname .002 100
setsockopt .002 100
-------- ------ ----
sys totals: .149 3600 0
usr time: .120
elapsed: 8.960[/code]
truss ·µ»Øϵͳµ÷ÓõÄÁÐ±í¡¢Ö´Ðе÷ÓúķѵÄ×Üʱ¼ä¡¢µ÷ÓõĴÎÊýºÍÈκη¢ÏÖµÄÎÊÌâ¡£ÔÚÕâ¸ö±¨±íµÄ½áβ´¦£¬·µ»ØÁËÕâЩϵͳµ÷ÓúķѵÄ×Üʱ¼ä£¬ÒÔ¼°Ö´ÐÐÓ¦ÓóÌÐòËùºÄ·ÑµÄʱ¼ä¡£¶ÔÓÚÕâЩĿµÄÀ´Ëµ£¬ËùºÄʱ¼äÊÇûÓÐÒâÒåµÄ£¬ÒòΪËüÖ¸µÄÊÇ´ÓÆô¶¯ truss ¿ªÊ¼µ½Æä½áÊøµÄʱ¼ä£¬¶øÓë Web ÇëÇóûÓÐÈκιØϵ¡£
Çåµ¥ 3 ÏÔʾÁË×î¼òµ¥µÄÇé¿ö¡£ÔÚÀ´×Ô Web ä¯ÀÀÆ÷µÄÁ¬½ÓÇëÇóµ½´ïºó£¬accept ϵͳµ÷ÓÃÍê³É¸ÃÁ¬½Ó¡£Web ·þÎñÆ÷ʹÓà read µ÷ÓûñµÃÇëÇóµÄÄÚÈÝ£¬½«ÇëÇóµÄÄÚÈÝÓ³Éäµ½´ÅÅÌÉϵÄÎļþ¡£Web ·þÎñÆ÷Ê×ÏÈʹÓà stat64 ÑéÖ¤¸ÃÎļþÊÇ·ñ´æÔÚ£¬Ê¹Óà open64 ´ò¿ª¸ÃÎļþÒÔ±ã½øÐжÁÈ¡£¬È»ºóʹÓà mmap64 ½«¸ÃÎļþµÄÄÚÈÝÓ³Éäµ½ÄÚ´æÖС£È»ºóʹÓà write ½«Õâ¸öÎļþ·¢Ëͻؿͻ§¶Ë£¬Ê¹ÓÃÁíÒ»¸ö write Éú³ÉÈÕÖ¾Îļþ£¬²¢ÇÒ·þÎñÆ÷Ö´ÐÐÀ´×Ôä¯ÀÀÆ÷µÄ×îºóÒ»¸ö read¡£¸ÃÁбíÖÐÆäÓàµÄµ÷Óö¼ÊÇϵͳ¿ªÏú£¬²¢ÇÒµ±ÅäÖ÷¢Éú¸Ä±äʱ£¬²»»áÓÐÏÔÖøµÄ±ä»¯¡£
½âÊÍÕâЩÊýÖµ
100 ´ÎÇëÇó×ܹ²ºÄ·Ñ 0.269 Ãë (0.149 + 0.120)£¬ÕâÑùµÄÐÔÄÜÏ൱²»´í£¬²¢ÇҸ÷þÎñÆ÷ÿÃëÖÓÓ¦¸Ã¿ÉÒÔÌṩ´óÔ¼ 370 ¸öÒ³Ãæ (100/0.269)¡£µ«ÊDz»ÄÜÍêÈ«ÏàÐÅÕâЩÊýÖµ£¬ÒòΪËüÃǽö±íʾ½ø³ÌºÄ·ÑÔÚ CPU ÉϵÄʱ¼ä£¬¶ø²»ÊÇÆäÕæÕýµÄÖ´ÐÐʱ¼ä£¨Ò²³ÆΪʱÖÓʱ¼ä£©¡£»¹Óиü¶àµÄÒòËØÐèÒª¿¼ÂÇ£¬Èç´ÅÅ̺ÍÍøÂçµÄËٶȡ¢¼ÆËã»úÉÏÕýÔËÐеÄÆäËûÄÚÈÝ¡¢¸ÃÊØ»¤½ø³ÌÔËÐÐÓÚµ÷ÊÔģʽµÄÊÂʵ¡£Äú»¹ÐèÒª¿¼ÂÇϵͳµ÷Óøú×Ù±¾ÉíµÄ¿ªÏú¡£
±¾ÎÄÖÐʹÓõķ½·¨Öصã¹Ø×¢ÕâЩ²Ù×÷µÄÏà¶Ô¼ÆʱºÍʹÓÃÓ¦ÓóÌÐò¸ú×ÙÏû³ýÀ˷ѵôµÄ²Ù×÷¡£Èç¹ûÄúÐèÒªÁ˽â Web ·þÎñÆ÷ÿÃë¿ÉÒÔÌṩµÄÒ³ÃæÊýÄ¿£¬²Î¿¼×ÊÁϲ¿·ÖÖÐÓÐÏàÓ¦µÄÈí¼þÁ´½Ó£¬Ëü¿ÉÒÔ°ïÖúÄúÈ·¶¨¸ÃÊýÖµ¡£
¸ú×Ù AllowOverride ·¶Î§
Apache ÔÊÐí¹ÜÀíԱͨ¹ý .htaccess »úÖƽ«ÅäÖÃȨίÍиø¸ö±ðµÄÓû§¡£.htaccess ÊÇÒ»¸ö°üº¬¸½¼ÓÅäÖÃÖ¸ÁîµÄÎļþ£¬Èç¹ûÔÚ httpd.conf ÖÐͨ¹ý AllowOverride ÅäÖÃÁËÇëÇóµÄĿ¼£¬ÄÇô Web ·þÎñÆ÷½«ËÑË÷Õâ¸öÎļþ¡£Çåµ¥ 4 ÏÔʾÁËÇ°ÃæµÄÅäÖÃÁË AllowOverride Limit µÄÅäÖÃÐÅÏ¢£¬ËüÔÊÐíÓû§»ñÈ¡·ÃÎÊ Web Ò³ÃæµÄÓû§ÃûºÍÃÜÂë¡£
Çåµ¥ 4. ÅäÖÃÁË AllowOverride µÄʾÀý httpd.conf
[code]DocumentRoot "/var/apache/htdocs"
Options FollowSymLinks
AllowOverride Limit
Options Indexes FollowSymLinks MultiViews
ÖØÐÂÆô¶¯ httpd ÊØ»¤½ø³Ì²¢ÔÙ´ÎÔËÐÐÕâЩ²âÊÔ£¬Æä½á¹ûÈçÇåµ¥ 5 Ëùʾ¡£
Çåµ¥ 5. ¿ªÆôÁË AllowOverride Limit µÄ 100 ´ÎÇëÇóµÄ½á¹û
[code]sunbox# truss -c -t write,read,open64,stat64,mmap64 -p 21136
^C
syscall seconds calls errors
read .012 200
write .021 200
mmap64 .007 100
stat64 .007 100
open64 .022 500 400
-------- ------ ----
sys totals: .072 1100 400
usr time: .141
elapsed: 16.660[/code]
³õ¿´ÆðÀ´£¬ÏµÍ³µ÷ÓúķѵÄʱ¼äϽµÁË£¬µ«ÕâÊÇÒòΪʹÓÃÁË -t Ñ¡Ï¸ú×ÙÈÎÎñÏÞÖÆÓÚһЩÓÐÒâÒåµÄϵͳµ÷Óᣴó¶àÊýϵͳµ÷Óò¢Ã»Óз¢Éú±ä»¯£¬µ«ÏÖÔÚÓÐ 500 ´Î open64 µ÷Óã¬ÆäÖÐÓÐ 400 ´Î·µ»ØÁË´íÎó¡£Ö´ÐÐ open64 µÄʱ¼äÔö¼ÓÁË£¨´Ó 0.006 ÃëÔö¼Óµ½ 0.22 Ã룩£¬Í¬Ê±Óû§¿Õ¼ä²¿·ÖµÄʱ¼äÒ²Ôö¼ÓÁË£¨´Ó 0.12 ÃëÔö¼Óµ½ 0.141 Ã룩¡£
ʱ¼äÔö¼ÓÊÇÒòΪ Apache ÏÖÔÚ±ØÐëÍê³É¸½¼ÓµÄ¹¤×÷ÒÔ´¦Àí¸ÃÇëÇ󣬼´Ê¹Ã»ÓÐÅäÖÃÖØд¡£µ¥¶ÀµÄ AllowOverride Limit ÅäÖÃÃ÷ÏÔµØÔö¼ÓÁË¿ªÏú¡£ÎÊÌâÒÀÈ»´æÔÚ£¬¼´Ê²Ã´µ¼ÖÂÁËÕâЩ´íÎó£¿ Òª»Ø´ðÕâ¸öÎÊÌ⣬¿ÉÒÔ¸ú×Ùµ¥¸ö Web ÇëÇó£¬ÈçÇåµ¥ 6 Ëùʾ¡£
Çåµ¥ 6. È·¶¨ open64 µ÷ÓÃʧ°ÜµÄÔÒò
[code]sunbox# truss -t open64 -p 21136
open64("/.htaccess", O_RDONLY) Err#2 ENOENT
open64("/var/.htaccess", O_RDONLY) Err#2 ENOENT
open64("/var/apache/.htaccess", O_RDONLY) Err#2 ENOENT
open64("/var/apache/htdocs/.htaccess", O_RDONLY) Err#2 ENOENT
open64("/var/apache/htdocs/test.html", O_RDONLY) = 5[/code]
Çåµ¥ 6 ÏÔʾÁ˵±ÇëÇó½øÈëʱ£¬Apache ¶Ôÿ¸öÖ¸Ïò /var/apache/htdocs µÄĿ¼½øÐмì²é²¢³¢ÊÔ´ò¿ª .htaccess Îļþ£¬µ«ÊÇÒòΪ AllowOverride ÅäÖÃΪ¸ùĿ¼£¬ËùÒÔÕâ¸öÎļþ²¢²»´æÔÚ¡£Apache ±ØÐëÔÚÿ¸ö×ÓĿ¼ÖвéÕÒ .htaccess ÎļþµÄÖØдÐÅÏ¢£¬²¢¶ÔËüÃǽøÐд¦Àí¡£ÕâÑùÒ»À´£¬ÓÉÓÚ¶îÍâµÄϵͳµ÷Óᢸü¶àµÄÓû§¿Õ¼ä¿ªÏúºÍ¶îÍâµÄ´ÅÅ̻£¬´Ó¶ø½øÒ»²½Ôö¼ÓÁËÑÓ³Ù¡£¶ÔÓÚ 100 ´ÎÇëÇóÀ´Ëµ£¬Ôö¼ÓÁãµã¼¸ÃëµÄʱ¼ä¿´ÆðÀ´²¢²»ÊǺÜÃ÷ÏÔ£¬µ«ÊǶÔÓÚһ̨·±Ã¦µÄ·þÎñÆ÷£¬¾Í»áÔö¼Ó¸ü³¤µÄÑÓ³Ù¡£
¼ÈÈ»ÄúÁ˽âÁËÖØдµÄ·¶Î§£¬ÄÇôÀíÏëµÄ½â¾ö·½°¸ÊDz»ÔÊÐíÖØд£¬²¢ÇÒÇ¿ÖÆÔÚ httpd.conf ÖжÔËùÓеÄÄÚÈݽøÐÐÅäÖá£Èç¹ûʧ°Ü£¬¿ÉÒÔ½«ÅäÖõķ¶Î§ÏÞÖÆÓÚÐèÒªËüµÄĿ¼¡£ÔÚÕâ¸öÑо¿Ê¾ÀýÖУ¬°Ñ AllowOverride Limit ·Åµ½µÚ¶þ¸ö Directory ½ÚÖУ¬Õ⽫½öÌí¼ÓÒ»¸ö¶îÍâµÄ open64 µ÷Óã¬ÒÔ±ãÔÚ /var/apache/htdocs ÖвéÕÒ .htaccess¡£¶ÔËùÓеĸ¸Ä¿Â¼½øÐÐËÑË÷ÊÇÀË·Ñʱ¼ä£¬ÒòΪÔÚÕâ¸öÅäÖÃÖУ¬²»»áʹÓÃÆäÖеÄÈκÎÎļþÀ´ÌṩҳÃæ¡£
Ñо¿Ö÷»úÃû²éÕÒ
µ± Web ·þÎñÆ÷½ÓÊÕµ½Ò»¸öÇëÇóʱ£¬ËüËùÖªµÀµÄ¹ØÓÚ¿Í»§¶ËµÄÐÅÏ¢Ö»ÓÐÆä IP µØÖ·£¬Èç 129.42.42.212 ¶ÔÓ¦ÓÚ IBM.com¡£È»¶ø£¬Web ·þÎñÆ÷²¢²»ÖªµÀÕâ¸öµØÖ·À´×ÔÓÚ IBM.com£¬Òò´Ë£¬Ëü±ØÐë½øÐз´Ïò DNS ²éÕÒ¡£ÕâÑù×öÐèÒªºÄ·ÑÒ»¶¨µÄʱ¼ä£¬Èç¹ûÔÚ·¢ËÍÇëÇó֮ǰÐèÒªÕâ¸öÃû³Æ£¬ÄÇô½«»áÑÓ³Ù¶Ô¿Í»§¶ËµÄÏìÓ¦¡£¹ýÈ¥£¬Apache ÔÚȱʡÇé¿öÏ»áÖ´ÐÐÕâЩ·´Ïò²éÕÒ£¬µ«ÏÖÔÚÕâÖÖÐÐΪÒѾÓÐÁ˸ı䡣
»¹ÓÐÁíÒ»ÖÖÇé¿ö£¬ÆäÖбØÐë½øÐз´Ïò DNS ËÑË÷¡£µ±»ùÓÚÖ÷»úÃû£¨¶ø²»ÊÇ IP µØÖ·£©ÅäÖ÷ÃÎÊÏÞÖÆʱ£¬Apache ±ØÐëÊ×ÏȽ« IP µØÖ··´Ïò½âÎöΪÏàÓ¦µÄÖ÷»úÃû£¬È»ºóÔٴν«Ö÷»úÃû½âÎöΪ IP µØÖ·£¬ÒÔÈ·±£ËüÃÇÕýÈ·Æ¥Åä¡£ÒòΪ·´ÏòÓòÃûËÑË÷¿ÉÒÔÓɵØÖ·¿éËùÓÐÕßÈ·¶¨£¬ËùÒÔÒª·ÀÖ¹ IP ÆÛƵķ¢Éú£¬±ØÐë½øÐеڶþ´Î²éÕÒ¡£¿ÉÒÔͨ¹ýÓ¦ÓóÌÐò¸ú×ÙÀ´È·¶¨ DNS ½âÎöµÄÓ°ÏìÂð£¿
Òª¶ÔÆä½øÐвâÊÔ£¬¿ÉÒÔ´ÓÇ°ÃæµÄʾÀýÖÐɾ³ý AllowOverride Limit£¬È»ºóÌí¼Ó Allow from ibm.com ´úÌæȱʡµÄ Allow from all¡£È»ºó£¬¶Ô DNS ·þÎñÆ÷½øÐиü¸ÄÒÔ±ãÏòÄúµÄ¹¤×÷Õ¾·µ»Ø something.ibm.com£¬È·±£³õʼ·´Ïò¼ì²éÄܹ»³É¹¦²¢ÇÒËæºóµÄÕýÏò²éÕÒ±ØÐëͨ¹ý Internet Íê³É¡£ÔÚʾÀýÔËÐйý³ÌÖУ¬¶Ô±£»¤µÄ Web ·þÎñÆ÷µÄÇëÇóºÄ·ÑÁË 15 ÃëµÄʱ¼ä¡£Ïà·´£¬Ê¹Óà IP µØÖ·´úÌæ ibm.com ËùºÄ·ÑµÄʱ¼äСÓÚ°ëÃëÖÓ¡£Çåµ¥ 7 ÏÔʾÁËÔÚʹÓà DNS È·±£°²È«Ê±£¬¶ÔһЩϵͳµ÷ÓýøÐÐͳ¼Æ¡£
Çåµ¥ 7. ͨ¹ýÖ÷»úÃû½øÐÐÏÞÖÆµÄ Web ÇëÇóµÄ truss Êä³ö
[code]bash-3.00# truss -c -p 26089
^C
syscall seconds calls errors
read .000 5
write .000 3
open .000 2
close .001 10
time .000 3
stat .000 5
alarm .000 8
fcntl .000 7 2
sigaction .000 3
sysconfig .000 5
pollsys .001 5
door_info .000 2
stat64 .000 1
open64 .000 2
so_socket .001 5
accept .000 1
connect .002 5
recvfrom .000 2
send .001 5
getsockname .000 1
setsockopt .000 1
-------- ------ ----
sys totals: .011 81 2
usr time: .004[/code]
truss ±¨¸æÁ˸ýø³ÌËùºÄ·ÑµÄʱ¼äԶԶСÓÚ¿Í»§¶Ë¸Ð¾õµ½µÄʱ¼ä£¨0.015 ÃëÓë 15 Ã룩¡£ÕâÊÇÒòΪ´ó¶àÊýÌ×½Ó×Ö²Ù×÷¶¼ÊÇÒì²½µØ ½øÐеģ¬ÆäÖÐÌ×½Ó×Ö½øÐÐÂÖѯÒÔ¼ì²éÊý¾ÝÊÇ·ñ³öÏÖ£¬¶ø²»ÊÇʹµÃÓ¦ÓóÌÐò´¦ÓÚ×èÈû£¨µÈ´ý£©×´Ì¬ÒԵȴýÏìÓ¦¡£Èç´ËÒ»À´£¬Ó¦ÓóÌÐòÔڵȴý½á¹ûµÄʱºò²»»áÏûºÄ CPU ʱ¼ä¡£Õâ¾Í½âÊÍÁË truss ±¨¸æµÄʱ¼äºÍ¿Í»§¶Ë¸Ð¾õµ½µÄʱ¼äÖ®¼ä³öÏÖ²îÒìµÄÔÒò¡£
truss ²¢Ã»ÓÐÍü¼ÇËù×öµÄ¸ü¸Ä£¬0.015 Ãë±È±¾ÎÄÖÐÑо¿µÄµÚÒ»¸ö¼òµ¥Ê¾ÀýÒª¸ßÒ»¸öÊýÁ¿¼¶¡£´Óϵͳµ÷ÓüÆÊýÖпÉÒÔ¿´³ö£¬ÓÐһЩÒÔǰûÓгöÏÖ¹ýµÄµ÷Ó㬰üÀ¨ read¡¢write¡¢close ºÍ stat¡£ÒÔ¼°»¹ÓÐ send¡¢connect¡¢so_socket ºÍ pollsys£¬ÕâЩϵͳµ÷ÓÃÓÃÓÚ½øÐÐÃû³ÆÇëÇó¡£ÒòΪÃû³Æ½âÎö¿ÉÒÔÀ´×ÔÓÚ²»Í¬µÄÀ´Ô´£¬°üÀ¨±¾µØÎļþϵͳºÍÃû³Æ»º´æÊØ»¤½ø³Ì£¬ËùÒÔ±ØÐë¶ÔÕ⼸¸öλÖýøÐмì²é¡£ÔÚËæºóµÄµ÷ÓÃÖУ¬ÇëÇóʱ¼äСÓÚ 1 Ã룬ÕâÊÇÒòΪ¶Ô DNS ÐÅÏ¢½øÐÐÁË»º´æ¡£
×îºó£¬´ó²¿·ÖµÄÑÓ³ÙÀ´×ÔÓÚÔ¶³ÌÃû³Æ·þÎñÆ÷ºÍÕýÏò½âÎö¡£Õâ¸öÊÂʵ½øÒ»²½Ç¿µ÷ÁË£¬Èç¹ûÄúÏ£ÍûÒÀÀµÓÚÃû³Æ²éÕÒ£¬ÄÇô¾ÍÐèҪʹÓà DNS »º´æºÍ¿ìËÙ DNS ·þÎñÆ÷¡£È»¶ø£¬×î¼ÑµÄ½â¾ö·½°¸ÊÇʹÓÃÒ»ÖÖ¿ÉÑ¡µÄ·½·¨À´´¦ÀíÕâ¸öÎÊÌâ¡£Ò»ÖֱȽϼòµ¥µÄ½â¾ö·½°¸ÊÇÖ¸¶¨ IP µØÖ·¿é£¨Èç Allow from 10.0.0.0/8£©£¬ÕâÖÖ·½·¨±È DNS ²éÕÒÒª¿ìµÃ¶à¡£ÒòΪ·´ÏòºÍÕýÏò²éÕÒ±ØÐëÆ¥Å䣬ËùÒÔ¶ÔÃû³Æ½øÐеIJÙ×÷£¬ºÜ¿ÉÄÜ¿ÉÒÔÓÃÓÚÍø¶Î¡£ÁíÍ⣬Apache ¿ÉÒÔ¼¯³É¸÷ÖÖÉí·ÝÑé֤ϵͳ£¬ËùÒÔ»ùÓÚÓû§µÄÉí·ÝÑéÖ¤ÊÇÁíÒ»ÖÖ¿ÉÑ¡·½·¨¡£
ϵͳµ÷ÓÃÓë¿âµ÷ÓÃ
Èç¹ûÊìϤÌ×½Ó×Ö±à³Ì£¬ÄÇôÄú¿ÉÄÜ»áÑ°ÕÒ gethostbyname ºÍÆäËûÀàËƵĵ÷Óã¬ÕâЩµ÷Óö¼¿ÉÒÔÓÃÀ´Ö´ÐÐÖ÷»ú²éÕÒ¹¦ÄÜ¡£ÓÐһЩ¿âµ÷Óã¬ÓÉ /usr/lib ÖеÄϵͳ¿â libc ºÍ libsocket Ìṩ¡£¿âµ÷Ó÷â×°ÁËÒ»¸ö»ò¶à¸öϵͳµ÷Óã¬ÒÔ¼°¶îÍâµÄÂß¼¡£Äú¿ÉÒÔ½«ËüÃÇ×÷Ϊ³ÌÐòÔ±ÓѺõĽӿÚÀ´½øÐÐϵͳµ÷Óá£ÀýÈ磬gethostbyname ¿âµ÷Óý«Ö´ÐÐÐí¶à²½Ö裬ÒÔ±ã¸ù¾Ý·þÎñÆ÷µÄÅäÖòéÕÒÏàÓ¦µÄÃû³Æ£¬Èç¼ì²é /etc/hosts »òËÑË÷ÍøÂçÐÅϢϵͳ (NIS) »ò DNS¡£ÕâЩ²½Öè°üº¬ÁËÄÚºËËùÌṩµÄ¸üСµÄ¹¹¼þ£¬¼´ÏµÍ³µ÷Óá£ÔÚ´ó¶àÊýÕâÑùµÄÕâÖÖÇé¿öÏ£¬Á½ÕßÖ®¼äµÄ²î±ðͨ³£ºÜС¡£truss »¹¿ÉÒÔ¸ú×Ù¿âµ÷Ó㬵«ÊÇÎÞ·¨ÌṩÏñϵͳµ÷ÓÃÄÇÑùÏêϸµÄÐÅÏ¢¡£
½áÊøÓï
¼àÊÓºÍͳ¼Æϵͳµ÷ÓõŦÄܲ»½öÓÐÖúÓÚ½øÐйÊÕÏÅųý£¬»¹ÓÐÖúÓÚÀí½âÓ¦ÓóÌÐòÅäÖÃÈçºÎ¶ÔÐÔÄܲúÉúÓ°Ïì¡£ÓëϵͳµÄÆäËû²¿·ÖÖ®¼äµÄÿ¸ö½»»¥²Ù×÷¶¼»áµ÷ÓÃÒ»¸ö»ò¶à¸öϵͳµ÷Ó㬲¢ÇÒÿ´Îµ÷Óö¼»áÔö¼Óϵͳ¿ªÏú¡£Õâ²¢²»ÊÇ˵ϵͳµ÷Ó÷dz£Ôã¸â£¬Èç¹û³ÌÐòÔ±²»ÓëÆäËûµÄ²¿·Ö½øÐн»»¥£¬Äǽ«ÊǺܷ¦Î¶µÄ¡£Ïà·´£¬ÔڸıäÓ¦ÓóÌÐòʱ£¬Äú¿ÉÒÔ¼àÊÓϵͳµ÷ÓõÄʹÓã¬ÒÔ±ã¸üºÃµØÁ˽âÕâЩ¸Ä±ä¶Ô×ÜÌåÐÔÄܵÄÓ°Ïì¡£