我试图通过此命令显示打开了多少文件:
lsof | awk'{print $ 1“”$ 2}'| uniq -c | sort -n -r
,结果如下:
717 mysqld 1762
188 httpd 5171
185 httpd 5145
184 httpd 5631
184 httpd 5488
184 httpd 5150
184 httpd 3824
184 httpd 3819
184 httpd 3811
184 httpd 3483
184 httpd 3255
184 httpd 3249
184 httpd 3236
184 httpd 3230
183 httpd 5655
183 httpd 5490
183 httpd 5489
183 httpd 5487
183 httpd 5465
183 httpd 5464
183 httpd 5149
183 httpd 4480
183 httpd 4479
183 httpd 4478
183 httpd 4477
183 httpd 4474
183 httpd 4473
183 httpd 4459
183 httpd 3490
183 httpd 3489
183 httpd 3488
183 httpd 3487
183 httpd 3484
183 httpd 3478
183 httpd 3326
183 httpd 3235
183 httpd 3234
183 httpd 3233
183 httpd 3231
183 httpd 3229
183 httpd 10551
183 httpd 10317
183 httpd 10316
183 httpd 10291
182 httpd 10602
182 httpd 10601
182 httpd 10281
174 httpd 5443
174 httpd 3319
174 httpd 10603
174 httpd 10596
174 httpd 10578
174 httpd 10577
174 httpd 10552
174 httpd 10531
173 httpd 10576
173 httpd 10378
173 httpd 10319
173 httpd 10318
171 httpd 3226
137 master 1985
118 dovecot 1854
74 newrelic- 1880
63 sshd 8631
62 auth 11282
57 fail2ban- 2107
56 auth 11283
49 qmgr 2007
49 pickup 31235
44 squid 2061
44 memcached 1002
41 sshd 1183
37 squid 2059
34 log 1857
27 vsftpd 1206
27 imap 7971
24 anvil 1855
22 config 11280
20 rsyslogd 869
20 init 1
19 udevd 363
19 crond 2042
15 unlinkd 2063
15 udevd 911
15 udevd 910
15 mysqld_sa 1246
15 lsof 11502
15 bash 8687
13 acpid 895
12 sort 11505
12 awk 11503
10 newrelic- 1879
10 lsof 11506
10 irqbalanc 884
9 uniq 11504
8 mingetty 2155
3 xenwatch 23
3 xenbus 24
3 sync_supe 56
3 netns 19
3 migration 9
3 migration 7
3 migration 5
3 migration 4
3 kthreadd 2
3 kswapd0 117
3 kstriped 292
3 ksoftirqd 8
3 ksoftirqd 6
3 ksoftirqd 3
3 ksoftirqd 10
3 ksnapd 296
3 kseriod 68
3 kjournald 318
3 khvcd 136
3 khelper 16
3 kblockd/3 63
3 kblockd/2 62
3 kblockd/1 61
3 kblockd/0 60
3 kauditd 570
3 flush-202 725
3 events/3 14
3 events/2 13
3 events/1 12
3 events/0 11
3 crypto/3 125
3 crypto/2 124
3 crypto/1 123
3 crypto/0 122
3 cpuset 15
3 bdi-defau 58
3 async/mgr 20
3 aio/3 121
3 aio/2 120
3 aio/1 119
3 aio/0 118
1 COMMAND PID
伙计们,你能告诉我为什么Apache打开这么多文件吗?我在httpd.conf中禁用了access_log指令,但它没有帮助我。
THX
答案 0 :(得分:2)
如果查看实际结果(lsof|grep httpd
),您将看到每个父进程都有对每个加载模块的打开句柄,因此您的模块(例如mod_rewrite)将位于打开文件列表中。
每个进程还将具有error_log
文件的句柄,运行httpd或任何模块所需的lib文件,以及IPC的每个进程至少一个管道。
如果您正在提供大量静态文件并且您有一个繁忙的网站,那么您很可能会看到其中一些文件也被打开。
这一点都不是问题。请记住,运行的服务器进程越多,打开的文件就越多,因为每个父进程都会打开许多相同的文件(特别是模块和日志文件)。