有时候关闭软件后,后台进程死掉,导致端口被占用。下面以TOMCAT端口8060被占用为例,列出详细解决过程。
解决方法:
1.查找被占用的端口
1、netstat -aptn
[root@localhost sysconfig]# netstat -aptn
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1391/sshd
tcp 0 0 192.168.1.105:22 192.168.1.103:62689 ESTABLISHED 2616/sshd: root@pts
tcp 0 0 192.168.1.105:22 192.168.1.103:62288 ESTABLISHED 2117/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 1931/mysqld
tcp6 0 0 192.168.1.105:9200 :::* LISTEN 2827/java
tcp6 0 0 192.168.1.105:9300 :::* LISTEN 2827/java
tcp6 0 0 :::22 :::* LISTEN 1391/sshd
- netstat -tln
- netstat -tln | grep 8060
netstat -tln查看端口使用情况,而netstat -tln | grep 8060则是只查看端口8060的使用情况
[root@localhost sysconfig]# netstat -tln
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 192.168.1.105:9200 :::* LISTEN
tcp6 0 0 192.168.1.105:9300 :::* LISTEN
tcp6 0 0 :::22 :::* LISTEN
[root@localhost sysconfig]#
2.查看端口属于哪个程序?端口被哪个进程占用
lsof -i:8060
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 20804 root 36u IPv6 35452317 0t0 TCP *:pcsync-https (LISTEN)
3.杀掉占用端口的进程 根据pid杀掉
kill -9 进程id
kill -9 20804
来自 <http://www.centoscn.com/CentosBug/osbug/2014/0617/3152.html>
CentOS系统端口占用解决
最新推荐文章于 2024-07-17 14:11:30 发布