我运行的是 CentOS 6.5 64 位操作系统,带有 Tomcat 和一个 Web 应用程序。我使用 Apache (httpd) 作为应用程序的反向代理 (ProxyPass)。直到最近,它 (Tomcat) 一直运行良好,没有崩溃。最近,我向 http 服务器添加了一个 Joomla 网站和 PHP (显然如此)。此后不久,我开始遇到 Tomcat 崩溃的情况。
当它崩溃时,Tomcat 不会在 中留下证据Catalina.out
。我终于在 中找到了输出/var/log/messages
。我希望有人可以粗略地看一眼并指出正确的方向:
============
Jul 23 01:19:31 myservername kernel: httpd invoked oom-killer: gfp_mask=0x201da, order=0, oom_adj=0, oom_score_adj=0
Jul 23 01:19:31 myservername kernel: httpd cpuset=/ mems_allowed=0
Jul 23 01:19:31 myservername kernel: Pid: 6104, comm: httpd Not tainted
2.6.32-431.1.2.0.1.el6.x86_64 #1
Jul 23 01:19:31 myservername kernel: Call Trace:
Jul 23 01:19:31 myservername kernel: [<ffffffff810d05c1>] ? cpuset_print_task_mems_allowed+0x91/0xb0
Jul 23 01:19:31 myservername kernel: [<ffffffff81122970>] ? dump_header+0x90/0x1b0
Jul 23 01:19:31 myservername kernel: [<ffffffff8122799c>] ? security_real_capable_noaudit+0x3c/0x70
Jul 23 01:19:31 myservername kernel: [<ffffffff81122df2>] ? oom_kill_process+0x82/0x2a0
Jul 23 01:19:31 myservername kernel: [<ffffffff81122d31>] ? select_bad_process+0xe1/0x120
Jul 23 01:19:31 myservername kernel: [<ffffffff81123230>] ? out_of_memory+0x220/0x3c0
Jul 23 01:19:31 myservername kernel: [<ffffffff8112fb4c>] ? __alloc_pages_nodemask+0x8ac/0x8d0
Jul 23 01:19:31 myservername kernel: [<ffffffff81167aaa>] ? alloc_pages_current+0xaa/0x110
Jul 23 01:19:31 myservername kernel: [<ffffffff8111fd67>] ? __page_cache_alloc+0x87/0x90
Jul 23 01:19:31 myservername kernel: [<ffffffff8111f74e>] ? find_get_page+0x1e/0xa0
Jul 23 01:19:31 myservername kernel: [<ffffffff81120d07>] ? filemap_fault+0x1a7/0x500
Jul 23 01:19:31 myservername kernel: [<ffffffff8114a094>] ? __do_fault+0x54/0x530
Jul 23 01:19:31 myservername kernel: [<ffffffff8114a667>] ? handle_pte_fault+0xf7/0xb00
Jul 23 01:19:31 myservername kernel: [<ffffffff811214a0>] ? generic_file_aio_read+0x380/0x700
Jul 23 01:19:31 myservername kernel: [<ffffffff8114b29a>] ? handle_mm_fault+0x22a/0x300
Jul 23 01:19:31 myservername kernel: [<ffffffff8104a8d8>] ? __do_page_fault+0x138/0x480
Jul 23 01:19:31 myservername kernel: [<ffffffff8100988e>] ? __switch_to+0x26e/0x320
Jul 23 01:19:31 myservername kernel: [<ffffffff81527920>] ? thread_return+0x4e/0x76e
Jul 23 01:19:31 myservername kernel: [<ffffffff8152d46e>] ? do_page_fault+0x3e/0xa0
Jul 23 01:19:31 myservername kernel: [<ffffffff8152a825>] ? page_fault+0x25/0x30
Jul 23 01:19:31 myservername kernel: Mem-Info:
Jul 23 01:19:31 myservername kernel: Node 0 DMA per-cpu:
Jul 23 01:19:31 myservername kernel: CPU 0: hi: 0, btch: 1 usd: 0
Jul 23 01:19:31 myservername kernel: Node 0 DMA32 per-cpu:
Jul 23 01:19:31 myservername kernel: CPU 0: hi: 186, btch: 31 usd: 30
Jul 23 01:19:31 myservername kernel: active_anon:112069 inactive_anon:56 isolated_anon:0
Jul 23 01:19:31 myservername kernel: active_file:17 inactive_file:465 isolated_file:0
Jul 23 01:19:31 myservername kernel: unevictable:0 dirty:1 writeback:0 unstable:0
Jul 23 01:19:31 myservername kernel: free:1181 slab_reclaimable:1556 slab_unreclaimable:5516
Jul 23 01:19:31 myservername kernel: mapped:78 shmem:58 pagetables:2575 bounce:0
Jul 23 01:19:31 myservername kernel: Node 0 DMA free:2040kB min:84kB low:104kB high:124kB active_anon:13500kB inactive_anon:0kB active_file:12kB inactive_file:12kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:15352kB mlocked:0kB dirty:0kB writeback:0kB mapped:24kB shmem:0kB slab_reclaimable:40kB slab_unreclaimable:76kB kernel_stack:16kB pagetables:48kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:6 all_unreclaimable? no
Jul 23 01:19:31 myservername kernel: lowmem_reserve[]: 0 489 489 489
Jul 23 01:19:31 myservername kernel: Node 0 DMA32 free:2684kB min:2784kB low:3480kB high:4176kB active_anon:434776kB inactive_anon:224kB active_file:56kB inactive_file:1848kB unevictable:0kB isolated(anon):0kB isolated(file):0kB present:500948kB mlocked:0kB dirty:4kB writeback:0kB mapped:288kB shmem:232kB slab_reclaimable:6184kB slab_unreclaimable:21988kB kernel_stack:944kB pagetables:10252kB unstable:0kB bounce:0kB writeback_tmp:0kB pages_scanned:130 all_unreclaimable? yes
Jul 23 01:19:31 myservername kernel: lowmem_reserve[]: 0 0 0 0
Jul 23 01:19:31 myservername kernel: Node 0 DMA: 0*4kB 1*8kB 1*16kB 1*32kB 1*64kB 1*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 2040kB
Jul 23 01:19:31 myservername kernel: Node 0 DMA32: 193*4kB 1*8kB 1*16kB 1*32kB 1*64kB 0*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 2684kB
Jul 23 01:19:31 myservername kernel: 547 total pagecache pages
Jul 23 01:19:31 myservername kernel: 0 pages in swap cache
Jul 23 01:19:31 myservername kernel: Swap cache stats: add 0, delete 0, find 0/0
Jul 23 01:19:31 myservername kernel: Free swap = 0kB
Jul 23 01:19:31 myservername kernel: Total swap = 0kB
Jul 23 01:19:31 myservername kernel: 131068 pages RAM
Jul 23 01:19:31 myservername kernel: 5503 pages reserved
Jul 23 01:19:31 myservername kernel: 13454 pages shared
Jul 23 01:19:31 myservername kernel: 119917 pages non-shared
Jul 23 01:19:31 myservername kernel: [ pid ] uid tgid total_vm rss cpu oom_adj oom_score_adj name
Jul 23 01:19:31 myservername kernel: [ 325] 0 325 2727 168 0 -17 -1000 udevd
Jul 23 01:19:31 myservername kernel: [ 602] 0 602 2726 167 0 -17 -1000 udevd
Jul 23 01:19:31 myservername kernel: [ 878] 0 878 23300 78 0 -17 -1000 auditd
Jul 23 01:19:31 myservername kernel: [ 894] 0 894 62368 729 0 0 0 rsyslogd
Jul 23 01:19:31 myservername kernel: [ 1027] 0 1027 29325 153 0 0 0 crond
Jul 23 01:19:31 myservername kernel: [ 1050] 0 1050 1016 21 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [ 1052] 0 1052 1016 22 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [ 1054] 0 1054 1016 22 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [ 1056] 0 1056 1016 22 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [ 1058] 0 1058 1016 21 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [ 1189] 38 1189 7679 158 0 0 0 ntpd
Jul 23 01:19:31 myservername kernel: [19331] 99 19331 11317 405 0 0 0 openvpn
Jul 23 01:19:31 myservername kernel: [19336] 0 19336 2726 167 0 -17 -1000 udevd
Jul 23 01:19:31 myservername kernel: [27296] 0 27296 16652 178 0 -17 -1000 sshd
Jul 23 01:19:31 myservername kernel: [29754] 0 29754 1016 22 0 0 0 mingetty
Jul 23 01:19:31 myservername kernel: [14500] 0 14500 20321 226 0 0 0 master
Jul 23 01:19:31 myservername kernel: [14503] 89 14503 20384 233 0 0 0 qmgr
Jul 23 01:19:31 myservername kernel: [ 3155] 0 3155 27042 66 0 0 0 mysqld_safe
Jul 23 01:19:31 myservername kernel: [ 3257] 27 3257 160134 4405 0 0 0 mysqld
Jul 23 01:19:31 myservername kernel: [ 6102] 0 6102 76169 1432 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6104] 48 6104 104399 5480 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6105] 48 6105 104565 5583 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6106] 48 6106 104301 5322 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6107] 48 6107 104630 5682 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6108] 48 6108 104491 5570 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6109] 48 6109 104563 5570 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6110] 48 6110 104546 5639 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6111] 48 6111 104362 5469 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6171] 48 6171 101911 3019 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6186] 48 6186 101530 2632 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6522] 48 6522 104451 5479 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 6835] 501 6835 317935 55623 0 0 0 java
Jul 23 01:19:31 myservername kernel: [ 7422] 48 7422 104365 5444 0 0 0 httpd
Jul 23 01:19:31 myservername kernel: [ 7656] 89 7656 20341 220 0 0 0 pickup
Jul 23 01:19:31 myservername kernel: Out of memory: Kill process 6835 (java) score 444 or sacrifice child
Jul 23 01:19:31 myservername kernel: Killed process 6835, UID 501, (java) total-vm:1271740kB, anon-rss:222432kB, file-rss:60kB
============
我已经将堆设置从默认值提高了,但这没有帮助:
-Xms256m -Xmx512m
我认为正确的做法是使用 JDK/JRE 附带的工具之一开始分析/监控 JVM,然后查看泄漏的位置。奇怪的是,在我摆弄新的 Joomla 网站之前,我从未遇到过这个问题。我对分析/监控不熟悉,因此,鉴于所包含的日志文件片段,我希望得到有关在我的特定情况下使用哪种工具的建议。
答案1
您的系统似乎没有更多可用内存。请使用以下命令检查您的系统上是否有交换内存
free -m
如果启用了交换,输出应该如下所示。
total used free shared buffers cached
Mem: 1876 1798 77 0 119 1440
-/+ buffers/cache: 237 1638
Swap: 4607 0 4607
如果您在文件中看不到交换,则必须创建交换文件。以下是创建和启用交换文件的指南。
http://www.cyberciti.biz/faq/linux-add-a-swap-file-howto/
您还可以配置java旋律使用 tomcat 应用程序来识别 tomcat 应用程序的问题
- - 更新
我写了一篇关于交换内存的文章,如果你有任何问题,请在下面发表评论
https://thinkersbase.blogspot.in/2018/03/create-linux-swap.html
答案2
原因如下:
Jul 23 01:19:31 myservername kernel: [<ffffffff81122df2>] ? oom_kill_process+0x82/0x2a0
内存不足。oom_kill_process
是内核函数,当内存不足时会终止某些进程。似乎有泄漏,或者内存太少。您的交换分区是否真的已启用并正常工作?(cat /proc/swaps
)。
扩大:有人说,启用交换会使你的系统变慢。这是错误的,不信,看我的评论。