Linux Port Information
What ports enabled in the Server.
root@kiloceilo:~# netstat -atun
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9696 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:6080 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:516 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8773 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8774 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8775 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9191 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:44040 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:8777 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
tcp 0 0 0.0.0.0:9292 0.0.0.0:* LISTEN
What services running in the port.
介紹lsof,這個指令對搞系統的來說應該要跟ls一樣熟。
為了強化大家的記憶,我就多說點lsof的背景,英文內涵為list open files。
為何用open file,對每個session來講都會產生一個port,在kernel中稱它為file。
這點我們可以透過ulimit -a查看,open file項,顯示1024表示最多1024個連線,這是可以被優化的。
現在我們可以將lsof指令記得更熟了吧。
root@kiloceilo:~# ulimit -a
.
.
max memory size (kbytes, -m) unlimited
open files (-n) 1024
我們來查查8773port是什麼,nova-api。
root@kiloceilo:~# lsof -n -i4TCP:8773 | grep LISTEN
nova-api 3911 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4271 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4274 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4294 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4295 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4300 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
nova-api 4303 root 6u IPv4 20035 0t0 TCP *:8773 (LISTEN)
Ignore protocol filter
lsof -n -i:80 | grep LISTEN
To check how many connection to mysql. Here we ignore some repeating. From localhost, by other hostname or ip address. 我們可以透過這個指令查到,服務與服務間,host與服務間的連線狀態,藉以了解整個系統的架構為何。
root@kiloceilo:~# lsof -i@127.0.0.1:mysql
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 2389 mysql 31u IPv4 20443 0t0 TCP localhost:mysql->localhost:36602 (ESTABLISHED)
mysqld 2389 mysql 32u IPv4 22561 0t0 TCP localhost:mysql->localhost:36607 (ESTABLISHED)
apache2 2931 stack 17u IPv4 20721 0t0 TCP localhost:36613->localhost:mysql (ESTABLISHED)
apache2 2941 stack 17u IPv4 20871 0t0 TCP localhost:36708->localhost:mysql (ESTABLISHED)
python 3832 root 3u IPv4 20442 0t0 TCP localhost:36602->localhost:mysql (ESTABLISHED)
python 3832 root 17u IPv4 66758 0t0 TCP localhost:36800->localhost:mysql (ESTABLISHED)
python 3832 root 18u IPv4 58123 0t0 TCP localhost:36792->localhost:mysql (ESTABLISHED)
nova-cert 3838 root 4u IPv4 20715 0t0 TCP localhost:36611->localhost:mysql (ESTABLISHED)
nova-sche 3844 root 4u IPv4 20718 0t0 TCP localhost:36612->localhost:mysql (ESTABLISHED)
nova-sche 3844 root 5u IPv4 22159 0t0 TCP localhost:36620->localhost:mysql (ESTABLISHED)
nova-cons 3853 root 4u IPv4 22113 0t0 TCP localhost:36610->localhost:mysql (ESTABLISHED)
ceilomete 3860 root 5u IPv4 28262 0t0 TCP localhost:36736->localhost:mysql (ESTABLISHED)
ceilomete 3870 root 8u IPv4 20834 0t0 TCP localhost:36695->localhost:mysql (ESTABLISHED)
glance-re 3935 root 8u IPv4 22471 0t0 TCP localhost:36709->localhost:mysql (ESTABLISHED)
glance-re 3942 root 8u IPv4 48805 0t0 TCP localhost:36775->localhost:mysql (ESTABLISHED)
glance-re 3948 root 8u IPv4 72908 0t0 TCP localhost:36818->localhost:mysql (ESTABLISHED)
nova-cond 4074 root 6u IPv4 22110 0t0 TCP localhost:36607->localhost:mysql (ESTABLISHED)
nova-cond 4076 root 6u IPv4 22564 0t0 TCP localhost:36608->localhost:mysql (ESTABLISHED)
nova-api 4261 root 11u IPv4 20842 0t0 TCP localhost:36700->localhost:mysql (ESTABLISHED)
nova-api 4262 root 11u IPv4 29859 0t0 TCP localhost:36734->localhost:mysql (ESTABLISHED)
You can replace 127.0.0.1 to any other host you are intrested or just ignore this parameter.
Obtaning what service connected to rabbitmq.
root@kiloceilo:~# lsof -i@172.16.235.128:amqp
.
.
nova-cert 3838 root 5u IPv4 22158 0t0 TCP 172.16.235.128:53157->172.16.235.128:amqp (ESTABLISHED)
python 3841 root 17u IPv4 20373 0t0 TCP 172.16.235.128:53139->172.16.235.128:amqp (ESTABLISHED)
python 3843 root 7u IPv4 19765 0t0 TCP 172.16.235.128:53121->172.16.235.128:amqp (ESTABLISHED)
python 3843 root 8u IPv4 19769 0t0 TCP 172.16.235.128:53123->172.16.235.128:amqp (ESTABLISHED)
nova-sche 3844 root 6u IPv4 22160 0t0 TCP 172.16.235.128:53159->172.16.235.128:amqp (ESTABLISHED)
python 3851 root 4u IPv4 20553 0t0 TCP 172.16.235.128:53124->172.16.235.128:amqp (ESTABLISHED)
python 3851 root 5u IPv4 20554 0t0 TCP 172.16.235.128:53125->172.16.235.128:amqp (ESTABLISHED)
python 3851 root 6u IPv4 20555 0t0 TCP 172.16.235.128:53126->172.16.235.128:amqp (ESTABLISHED)
python 3851 root 7u IPv4 21078 0t0 TCP 172.16.235.128:53266->172.16.235.128:amqp (ESTABLISHED)
nova-cons 3853 root 5u IPv4 22574 0t0 TCP 172.16.235.128:53153->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3859 root 4u IPv4 20496 0t0 TCP 172.16.235.128:53114->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3860 root 4u IPv4 22072 0t0 TCP 172.16.235.128:53141->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3860 root 7u IPv4 29971 0t0 TCP 172.16.235.128:53275->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3861 root 6u IPv4 23066 0t0 TCP 172.16.235.128:53248->172.16.235.128:amqp (ESTABLISHED)
neutron-v 3862 root 4u IPv4 18934 0t0 TCP 172.16.235.128:53127->172.16.235.128:amqp (ESTABLISHED)
neutron-v 3862 root 5u IPv4 18935 0t0 TCP 172.16.235.128:53128->172.16.235.128:amqp (ESTABLISHED)
neutron-v 3862 root 6u IPv4 27042 0t0 TCP 172.16.235.128:53267->172.16.235.128:amqp (ESTABLISHED)
neutron-v 3862 root 9u IPv4 21166 0t0 TCP 172.16.235.128:53268->172.16.235.128:amqp (ESTABLISHED)
nova-comp 3871 root 4u IPv4 22605 0t0 TCP 172.16.235.128:53163->172.16.235.128:amqp (ESTABLISHED)
nova-comp 3871 root 5u IPv4 22608 0t0 TCP 172.16.235.128:53164->172.16.235.128:amqp (ESTABLISHED)
nova-comp 3871 root 18u IPv4 22929 0t0 TCP 172.16.235.128:53208->172.16.235.128:amqp (ESTABLISHED)
nova-comp 3871 root 21u IPv4 58069 0t0 TCP 172.16.235.128:53329->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3872 root 11u IPv4 49675 0t0 TCP 172.16.235.128:53321->172.16.235.128:amqp (ESTABLISHED)
ceilomete 3917 root 5u IPv4 19754 0t0 TCP 172.16.235.128:53116->172.16.235.128:amqp (ESTABLISHED)
nova-cond 4074 root 7u IPv4 20722 0t0 TCP 172.16.235.128:53154->172.16.235.128:amqp (ESTABLISHED)
nova-cond 4074 root 9u IPv4 22609 0t0 TCP 172.16.235.128:53165->172.16.235.128:amqp (ESTABLISHED)
nova-cond 4075 root 7u IPv4 20723 0t0 TCP 172.16.235.128:53155->172.16.235.128:amqp (ESTABLISHED)
nova-api 4262 root 12u IPv4 29861 0t0 TCP 172.16.235.128:53273->172.16.235.128:amqp (ESTABLISHED)
172.16.235.128:53208->172.16.235.128:amqp表示,由nova-compute發起的連線(port number53208),連到amqp。
No comments:
Post a Comment