确定使用了哪个套接字要分两步 。这部分完全看不懂,先记录下,
第一步,用strace -e trace=file跟踪应用程序所有的I/0系统调用 。这能显示进程是从哪些文件描述符进行读写的 。┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$yum -y install strace
跟踪执行kubectl get nodes涉及到的文件读写
┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$kubectl get nodes
NAMESTATUSROLESAGEVERSION
vms81.liruilongs.github.ioReadycontrol-plane,master153dv1.22.2
vms82.liruilongs.github.ioReady<none>153dv1.22.2
vms83.liruilongs.github.ioNotReady<none>153dv1.22.2
┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$strace -e trace=filekubectl get nodes
execve("/usr/bin/kubectl", ["kubectl", "get", "nodes"], 0x7ffc888b4e40 /* 22 vars */) = 0
openat(AT_FDCWD, "/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", O_RDONLY) = -1 ENOENT (没有那个文件或目 录)
readlinkat(AT_FDCWD, "/proc/self/exe", "/usr/bin/kubectl", 128) = 16
openat(AT_FDCWD, "/usr/bin/kubectl", O_RDONLY|O_CLOEXEC) = 6
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
— SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=22013, si_uid=0} —
openat(AT_FDCWD, "/root/.kube/cache/discovery/192.168.26.81_6443/policy/v1beta1/serverresources.json", O_RDONLY|O_CLOEXEC) = 6
……….
第二步,通过查看proc文件系统,将这些文件描述符映射回套接字 。/proc/<pid>/fd/中的文件是从文件描述符到实际文件或套接字的符号链接 。该目录下的1s-1a会显示特定进程全部的文件描述符 。名字中带有socket的是网络套接字 。之后就可以利用这些信息来确定程序中的哪个套接字产生了这些通信 。┌──[root@vms81.liruilongs.github.io]-[~/ansible]
└─$ps -elF | grep etcd
4 S root202520042800 – 2803899 futex_ 96656 1 5月14 ?00:33:14 etcd –advertise-client-urls=https://192.168.26.81:2379 –cert-file=/etc/kubernetes/pki/etcd/server.crt –client-cert-auth=true –data-dir=/var/lib/etcd –initial-advertise-peer-urls=https://192.168.26.81:2380 –initial-cluster=vms81.liruilongs.github.io=https://192.168.26.81:2380 –key-file=/etc/kubernetes/pki/etcd/server.key –listen-client-urls=https://127.0.0.1:2379,https://192.168.26.81:2379 –listen-metrics-urls=http://127.0.0.1:2381 –listen-peer-urls=https://192.168.26.81:2380 –name=vms81.liruilongs.github.io –peer-cert-file=/etc/kubernetes/pki/etcd/peer.crt –peer-client-cert-auth=true –peer-key-file=/etc/kubernetes/pki/etcd/peer.key –peer-trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt –snapshot-count=10000 –trusted-ca-file=/etc/kubernetes/pki/etcd/ca.crt
4 S root1419614020 10800 – 311578 futex_ 445044 0 5月14 ?01:54:30 kube-apiserver –advertise-address=192.168.26.81 –allow-privileged=true –token-auth-file=/etc/kubernetes/pki/liruilong.csv –authorization-mode=Node,RBAC –client-ca-file=/etc/kubernetes/pki/ca.crt –enable-admission-plugins=NodeRestriction –enable-bootstrap-token-auth=true –etcd-cafile=/etc/kubernetes/pki/etcd/ca.crt –etcd-certfile=/etc/kubernetes/pki/apiserver-etcd-client.crt –etcd-keyfile=/etc/kubernetes/pki/apiserver-etcd-client.key –etcd-servers=https://127.0.0.1:2379 –kubelet-client-certificate=/etc/kubernetes/pki/apiserver-kubelet-client.crt –kubelet-client-key=/etc/kubernetes/pki/apiserver-kubelet-client.key –kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname –proxy-client-cert-file=/etc/kubernetes/pki/front-proxy-client.crt –proxy-client-key-file=/etc/kubernetes/pki/front-proxy-client.key –requestheader-allowed-names=front-proxy-client –requestheader-client-ca-file=/etc/kubernetes/pki/front-proxy-ca.crt –requestheader-extra-headers-prefix=X-Remote-Extra- –requestheader-group-headers=X-Remote-Group –requestheader-username-headers=X-Remote-User –secure-port=6443 –service-account-issuer=https://kubernetes.default.svc.cluster.local –service-account-key-file=/etc/kubernetes/pki/sa.pub –service-account-signing-key-file=/etc/kubernetes/pki/sa.key –service-cluster-ip-range=10.96.0.0/12 –tls-cert-file=/etc/kubernetes/pki/apiserver.crt –tls-private-key-file=/etc/kubernetes/pki/apiserver.key
推荐阅读
- 万里长城是怎么建成的
- 小鸡怎么叫的
- 手表平时怎么保养 手表平时怎么保养发亮
- 文言文是什么意思怎么讲 文言文是什么意思
- 古代女子的守宫砂是真的吗?,古代女子的守宫砂是怎么回事
- 信息安全专业是个坑吗 发展前景怎么样
- 现在学计算机好找工作吗 前景怎么样
- 植物新叶子发黑怎么办 室内植物叶子发黑是什么原因
- 财务管理工资一般多少 待遇怎么样
- 工程管理出来工资高吗 发展前景及方向怎么样