微服务
一般是由于内存不错导致系统自动停掉该进程

1、先查看服务主机上的Java进程

  1. [root@iZuligp6e1dyzfZ pro]# ps -aux | grep 'java -jar'
  2. root 15833 0.4 11.3 2547696 213300 pts/0 Sl 10:52 0:39 java -jar business-ms-0.0.1-SNAPSHOT.jar
  3. root 21949 1.0 13.0 2565832 245592 pts/0 Sl 12:18 0:36 java -jar user-ms-0.0.1-SNAPSHOT.jar
  4. root 26191 0.0 0.0 112708 988 pts/0 R+ 13:17 0:00 grep --color=auto java -jar
  5. root 29451 0.0 11.3 2541072 213284 ? Sl Jan03 5:38 java -jar eureka-server-0.0.1-SNAPSHOT.jar
  6. root 31947 0.5 12.3 2611560 232880 ? Sl Jan05 21:09 java -jar gateway-0.0.1-SNAPSHOT.jar

image.png

2、在Java进程停掉后查看系统消息

系统消息一般在Linux的/var/log目录下以message关键字命名的文件中,其中message文件是当前写入的文件,其他带有日期别名的是分割后的以前的记录文件。

  1. [root@iZuligp6e1dyzfZ pro]# cat /var/log/messages | grep 'java'
  2. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: java invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
  3. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: java cpuset=/ mems_allowed=0
  4. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: CPU: 0 PID: 10071 Comm: java Tainted: G OE ------------ T 3.10.0-957.21.3.el7.x86_64 #1
  5. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567318 49655 184 0 0 java
  6. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [12798] 0 12798 575848 49573 199 0 0 java
  7. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [13006] 0 13006 556848 33402 141 0 0 java
  8. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [ 9687] 0 9687 634921 46675 148 0 0 java
  9. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [ 9893] 0 9893 651850 56802 185 0 0 java
  10. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [22905] 0 22905 639424 64983 186 0 0 java
  11. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: [14846] 0 14846 629056 43443 133 0 0 java
  12. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 22905 (java) score 134 or sacrifice child
  13. Jan 3 09:29:31 iZuligp6e1dyzfZ kernel: Killed process 22905 (java) total-vm:2557696kB, anon-rss:259932kB, file-rss:0kB, shmem-rss:0kB
  14. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: java invoked oom-killer: gfp_mask=0x201da, order=0, oom_score_adj=0
  15. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: java cpuset=/ mems_allowed=0
  16. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: CPU: 0 PID: 12808 Comm: java Tainted: G OE ------------ T 3.10.0-957.21.3.el7.x86_64 #1
  17. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567318 50090 184 0 0 java
  18. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [12798] 0 12798 575848 49813 199 0 0 java
  19. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [13006] 0 13006 556848 33677 141 0 0 java
  20. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [29451] 0 29451 634756 52411 158 0 0 java
  21. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [30713] 0 30713 646335 50897 173 0 0 java
  22. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [30777] 0 30777 636753 55604 166 0 0 java
  23. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [30819] 0 30819 641201 57071 181 0 0 java
  24. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: [30951] 0 30951 619289 15340 76 0 0 java
  25. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 30819 (java) score 118 or sacrifice child
  26. Jan 5 15:00:01 iZuligp6e1dyzfZ kernel: Killed process 30819 (java) total-vm:2564804kB, anon-rss:228284kB, file-rss:0kB, shmem-rss:0kB
  27. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567575 50121 184 0 0 java
  28. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [12798] 0 12798 575887 49866 199 0 0 java
  29. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [13006] 0 13006 556848 33743 141 0 0 java
  30. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [29451] 0 29451 635268 52542 159 0 0 java
  31. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [30777] 0 30777 638705 60316 175 0 0 java
  32. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [31125] 0 31125 649374 64148 192 0 0 java
  33. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: [31947] 0 31947 652890 56185 195 0 0 java
  34. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 31125 (java) score 132 or sacrifice child
  35. Jan 5 20:55:46 iZuligp6e1dyzfZ kernel: Killed process 31125 (java) total-vm:2597496kB, anon-rss:256592kB, file-rss:0kB, shmem-rss:0kB
  36. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567575 50141 184 0 0 java
  37. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [12798] 0 12798 575887 50090 199 0 0 java
  38. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [13006] 0 13006 557384 35132 144 0 0 java
  39. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [29451] 0 29451 635268 52996 166 0 0 java
  40. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [31947] 0 31947 652890 57859 197 0 0 java
  41. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [ 6267] 0 6267 638936 55610 169 0 0 java
  42. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: [ 6852] 0 6852 640175 62247 182 0 0 java
  43. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 6852 (java) score 128 or sacrifice child
  44. Jan 7 17:07:59 iZuligp6e1dyzfZ kernel: Killed process 6852 (java) total-vm:2560700kB, anon-rss:248988kB, file-rss:0kB, shmem-rss:0kB
  45. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567832 50490 185 0 0 java
  46. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [12798] 0 12798 576435 51241 203 0 0 java
  47. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [13006] 0 13006 557384 35268 144 0 0 java
  48. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [29451] 0 29451 635268 53310 167 0 0 java
  49. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [31947] 0 31947 652890 58126 197 0 0 java
  50. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [ 6267] 0 6267 639960 61383 176 0 0 java
  51. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: [12976] 0 12976 631872 48418 149 0 0 java
  52. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 6267 (java) score 126 or sacrifice child
  53. Jan 8 10:17:15 iZuligp6e1dyzfZ kernel: Killed process 6267 (java) total-vm:2559840kB, anon-rss:245532kB, file-rss:0kB, shmem-rss:0kB
  54. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567832 50490 185 0 0 java
  55. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [12798] 0 12798 576435 51242 203 0 0 java
  56. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [13006] 0 13006 557384 35268 144 0 0 java
  57. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [29451] 0 29451 635268 53311 167 0 0 java
  58. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [31947] 0 31947 652890 58137 197 0 0 java
  59. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [12976] 0 12976 650153 62518 196 0 0 java
  60. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: [15833] 0 15833 636753 52021 161 0 0 java
  61. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 12976 (java) score 129 or sacrifice child
  62. Jan 8 10:53:28 iZuligp6e1dyzfZ kernel: Killed process 12976 (java) total-vm:2600612kB, anon-rss:250072kB, file-rss:0kB, shmem-rss:0kB
  63. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [12664] 0 12664 567832 50490 185 0 0 java
  64. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [12798] 0 12798 576435 51269 203 0 0 java
  65. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [13006] 0 13006 557384 35345 144 0 0 java
  66. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [29451] 0 29451 635268 53321 167 0 0 java
  67. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [31947] 0 31947 652890 58244 197 0 0 java
  68. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [15833] 0 15833 636924 53237 164 0 0 java
  69. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: [21949] 0 21949 641458 60897 182 0 0 java
  70. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: Out of memory: Kill process 21949 (java) score 125 or sacrifice child
  71. Jan 8 13:44:36 iZuligp6e1dyzfZ kernel: Killed process 21949 (java) total-vm:2565832kB, anon-rss:243588kB, file-rss:0kB,

image.png
从信息里可以看到,被kill的进程id和启动时的一致,消息提示是Out of memory,即内存不足。