lsof installation command
[sarah@hadoop102 bin]$ sudo yum install -y lsof
How to view
For example, check who is occupying port 8080
[sarah@hadoop102 bin]$ lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
java 8769 sarah 53u IPv6 7950020 0t0 TCP *:webcache (LISTEN)
You can see that port 8080 is occupied by process 8769. Use jps to see which process 8769 belongs to.
[sarah@hadoop102 bin]$ jps
8769 QuorumPeerMain
11842 JournalNode
16898 HRegionServer
29706 ConsoleProducer
30094 ConsoleProducer
13329 JobHistoryServer
26068 RunJar
16596 HMaster
23510 NodeManager
23319 ResourceManager
28572 ConsoleConsumer
12062 DFSZKFailoverController
4963 HistoryServer
31075 YarnTaskExecutorRunner
13862 DataNode
15655 MasterServer
13799 NameNode
15912 LoggerServer
27944 Kafka
You can see that the process is zk