linuxÏÂfile descriptoerÏÞÖÆ
linuxÏÂfile descriptoerÏÞÖÆ
ĬÈÏ·ÖÀà 2009-11-21 14:47 ÔĶÁ0 ÆÀÂÛ0
×ֺţº ´ó´ó ÖÐÖРСС
Tuning file descriptor limits on Linux
Linux limits the number of file descriptors that any one process may open; the default limits are 1024 per process. These limits can prevent optimum performance of both benchmarking clients (such as httperf and apachebench) and of the web servers themselves (Apache is not affected, since it uses a process per connection, but single process web servers such as Zeus use a file descriptor per connection, and so can easily fall foul of the default limit).
The open file limit is one of the limits that can be tuned with the ulimit command. The command
ulimit -aS
displays the current limit, and
ulimit -aH
displays the hard limit (above which the limit cannot be increased without tuning kernel parameters in /proc).
The following is an example of the output of
ulimit -aH
. You can see that the current shell (and its children) is restricted to 1024 open file descriptors.
core file size (blocks) unlimiteddata seg size (kbytes) unlimitedfile size (blocks) unlimitedmax locked memory (kbytes) unlimitedmax memory size (kbytes) unlimitedopen files 1024pipe size (512 bytes) 8stack size (kbytes) unlimitedcpu time (seconds) unlimitedmax user processes 4094virtual memory (kbytes) unlimited
Increasing the file descriptor limit
The file descriptor limit can be increased using the following procedure:
Edit
/etc/security/limits.conf
and add the lines:
* soft nofile 1024
* hard nofile 65535
Edit
/etc/pam.d/login
, adding the line:
session required /lib/security/pam_limits.so
The system file descriptor limit is set in
/proc/sys/fs/file-max
. The following command will increase the limit to 65535:
echo 65535 > /proc/sys/fs/file-max
You should then be able to increase the file descriptor limits using:
ulimit -n unlimitedThe above
Ïà¹ØÎĵµ£º
Service Discovery Protocol(SDP)ÌṩһÖÖÄÜÁ¦£¬ÈÃÓ¦ÓóÌÐòÓз½·¨·¢ÏÖÄÄÖÖ·þÎñ¿ÉÓÃÒÔ¼°ÕâÖÖ·þÎñµÄÌØÐÔ¡£
·þÎñ·¢ÏÖÐÒé(SDP»òBluetooth SDP)ÔÚÀ¶ÑÀÐÒéÕ»ÖжÔÀ¶ÑÀ»·¾³ÖеÄÓ¦ÓóÌÐòÓÐÌØÊâµÄº¬Ò⣬·¢ÏÖÄĸö·þÎñÊÇ¿ÉÓõĺÍÈ·¶¨ÕâЩ¿ÉÓ÷þÎñµÄÌØÕ÷¡£SDP¶¨ÒåÁËbluetooth client·¢ÏÖ¿ÉÓÃbluetooth server·þÎñºÍËüÃǵÄÌØÕ÷µÄ·½·¨¡£ ......
/ :¸ùĿ¼£¬ÊÇFHS½á¹¹ÖеÄ×î¶¥²ãĿ¼¡£ÆäËüËùÓÐĿ¼¶¼ÊÇËüµÄ×ÓĿ¼£¬Ëü×ÜÊÇÒÔ¶ÀÁ¢µÄ·ÖÇø¹ÒÔØ¡£ÆäËüËùÓв»ÊÇÒÔ¶ÀÁ¢·ÖÇø¹ÒÔØµÄĿ¼¶¼°üº¬Ôڴ˸ùĿ¼·ÖÇø¡£
/bin:°üº¬Ò»Ð©ÓÐÓõÄÃüÁîÐй¤¾ß¡£²»Äܱ»µ¥¶À¹ÒÔØÎªÒ»¸ö·ÖÇø£¬·ñÔòÓûָ´ÅÌÐÞ¸´ÏµÍ³Ê±½«²»ÄÜ·ÃÎÊÕâЩÃüÁî¡£
/boot:°üº¬LinuxÆô¶¯Îļþ£¬°üº¬LinuxϵͳµÄÄÚº ......
½«php·þÎñÆ÷¼Üµ½linuxÏÂʱûÓÐ×¢Òâ¸ÃÎÊÌ⣬
ǰ¼¸Ììµ¹ÊÇÅöµ½ÁËÔÚlinuxÏÂÑéÖ¤ÂëµÄͼƬÎÞ·¨ÏÔʾµÄÇé¿ö£¬·¢ÏÖlinuxÏÂÒ²ÒªÓÐgd¿âµÄÖ§³Ö£¬ÓÚÊǰ²×°ÁËphp5-gd£¨±¾ÈËʹÓõÄÊÇphp5£©
£¬Õâ¸öÎÊÌâ½â¾öÁË
½ñÌìͻȻ·¢ÏÖimgͼƬÎÞ·¨ÏÔʾ£¬ÉÏÍøËÑÁËÒ»°Ñ£¬ÓÖ¾¹ý²âÊԵóöÈçϽáÂÛ
<img src="pc.jpg"......>
Ëû»áÒÔµ±Ç°Â·¾¶ ......
Linux Ê×ÏÈ´´½¨ramfsÎļþϵͳ(/)
È»ºó°Ñinitrd.imgÎļþ¼ÓÔØµ½ / Ŀ¼Ï¡£
ÆäËüÎļþϵͳÊÇ×öΪramfsµÄÒ»¸öĿ¼½áµã¹ÒÔØÉÏÈ¥µÄ¡£
initrd.imgÊÇÒ»¸öÓÃzipѹËõµÄcpio¸ñʽµÄѹËõÎļþ¡£°´ÏÂÃæ²½ÖèʵÏÖ½âѹ
µÚÒ»²½£º½«initrd.img¸ÄÃûΪinitrd.img.gz
mv initrd.img initrd.img.gz
µÚ¶þ²½£ºÓÃgunzip½âѹÉú³Éinitrd.img
gunzi ......
Linux 2.6ÄÚºËÁ´±íÊý¾Ý½á¹¹µÄʵÏÖ
ÔÚ¼ÆËã»ú¿ÆÑ§ÖУ¬Á´±íÊǷdz£Í¨ÓõÄÊý¾Ý½á¹¹£¬¹á´©ÓÚÕû¸ölinuxµÄÄںˡ£ÔÚlinuxÄÚºËÖУ¬Á´±íͨ³£ÒÔ
˫ѻ·Á´±íµÄ·½Ê½³öÏÖ¡£ËùÓÐÁ´±íµÄ´úÂëÔÚinclude/linux/list.hÎļþÖС£
¶¨ÒåÈçÏ£º
struct list_head {
struct list_head *next, *prev;
}; ......