linux 環境下查看tomcat端口是否被佔用及解決方法

在停tomcat後,重新啓動tomcat 報以下錯誤:

tomcat 文件下bin目錄裏的hs_err_pid14967.log 報錯內容

#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 134217728 bytes for committing reserved memory.
# Possible reasons:
#   The system is out of physical RAM or swap space
#   In 32 bit mode, the process size limit was hit
# Possible solutions:
#   Reduce memory load on the system
#   Increase physical memory or swap space
#   Check if swap backing store is full
#   Use 64 bit Java on a 64 bit OS
#   Decrease Java heap size (-Xmx/-Xms)
#   Decrease number of Java threads
#   Decrease Java thread stack sizes (-Xss)
#   Set larger code cache with -XX:ReservedCodeCacheSize=
# This output file may be truncated or incomplete.
#
#  Out of Memory Error (os_linux.cpp:2627), pid=14967, tid=0x00007f7f44bdd700
#
# JRE version: Java(TM) SE Runtime Environment (8.0_111-b14) (build 1.8.0_111-b14)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.111-b14 mixed mode linux-amd64 compressed oops)
# Failed to write core dump. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again

#

在控制檯中報錯中顯示內存溢出

一開始以爲是分配內存不足,經過網上查找,最後發現是因爲tomcat的端口被佔用,在停tomcat時,進程沒有 被殺死導致的

這是就需要去殺死進程才能啓動tomcat

1、先查看端口被佔用情況:

netstat -apn|grep 80

 

確實是被佔用了

2、 確定進程號

通過命令:ps -ef | grep tomcat  如下圖

 root 後面的就是進程號

使用以下命令查看詳細信息:

ps -aux|grep <進程號>

 eg: ps -aux | grep 1091

3. 殺掉該進程

kill -9 進程號

殺掉所有的進程後,就可以啓動tomcat了

注:所有的命令在tomcat的bin路徑下執行

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章