Good programmers cloud computing learning process process route Share View

Good programmers cloud computing learning process process route Share View

Understand such processes:
• PID, PPID
• The current process status
• Memory allocation
• CPU and the actual time is spent
• User UID, he decided to privileged processes
netstat -anptu view port 

[root @ tianyun ~] # yum clean all // Clear the original old yUM database information
[root @ tianyun ~] # yum makecache

static check process PS
[root @ Tianyun ~] # PS the AUX | less
the USER PID% the CPU% MEM TTY STAT RSS VSZ the START the TIME the COMMAND
root 1 0.0 2164 648 Ss 08:47 0:00 0.0 the init [5]? 

the uSER: user run process
PID: process ID
% the CPU: the CPU occupancy rate
% MEM: memory usage
VSZ: the virtual memory
RSS: the actual memory resident memory footprint
TTY: terminal processes running
STAT: PS process state man (/ the sTATE) 
R & lt running
S interruptible sleep sleep
D uninterruptible sleep (usually the IO)
T stopped process 
Z zombie
X die process

sTART: start time course
TIME: total CPU time the process takes
COMMAND: process file, process name

[root @ Tianyun ~] # PS the AUX --sort the CPU% | less
[root @ Tianyun ~] # --sort the AUX PS - the CPU% | less
[root ~ @tianyun] # PS the AUX --sort rss | less
[root @ Tianyun ~] # PS the AUX --sort -rss | less

[root @ Tianyun ~] # yum -y install httpd
[root @ Tianyun ~] # systemctl Start httpd
[root @ Tianyun ~] # PS auxf | grep [H] ttpd
root 8310 0.0 0.1 2912 10092 Ss 14:19 0:00 / usr / sbin / httpd?
the Apache 0.0 8311 0.0 10092 S 2060 14:19 0:00? \ _ / usr / sbin / httpd
the Apache 0.0 8312 0.0 10092 2060? S 14:19 0:00 \ _ / usr / sbin / httpd
the Apache 0.0 8313 0.0 10092 2060? S 14:19 0:00 \ _ / usr / sbin / httpd
the Apache 0.0 8314 0.0 10092 2060? S 14:19 0:00 \ _ / usr / sbin / httpd
apache 8315 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd
apache 8316 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd
apache 8318 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd
apache 8319 0.0 0.0 10092 2060 ? S 14:19 0:00 \_ /usr/sbin/httpd

[root@tianyun ~]# ps -ef
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 08:47 ? 00:00:00 init [5] 

//自定义显示字段
[root@tianyun ~]# ps axo user,pid,ppid,%mem,command
[root@tianyun ~]# ps axo user,pid,ppid,%mem,command |grep httpd 
root 8310 1 0.1 /usr/sbin/httpd
apache 8311 8310 0.0 /usr/sbin/httpd
apache 8312 8310 0.0 /usr/sbin/httpd
apache 8313 8310 0.0 /usr/sbin/httpd
apache 8314 8310 0.0 /usr/sbin/httpd
apache 8315 8310 0.0 /usr/sbin/httpd
apache 8316 8310 0.0 /usr/sbin/httpd
apache 8318 8310 0.0 /usr/sbin/httpd
apache 8319 8310 0.0 /usr/sbin/httpd
root 9236 6798 0.0 grep httpd
[root@tianyun ~]# ps axo user,pid,ppid,%mem,%cpu,command --sort -%cpu |less

//查看指定进程的PID
[yang@iZm5eiwihahzq6ds23gbf6Z ~]$ cat /run/sshd.pid 
830

[root@tianyun ~]# ps aux |grep sshd
root 10180 0.0 0.0 7224 1024 ? Ss 16:00 0:00 /usr/sbin/sshd

[root@tianyun ~]# pgrep -l sshd
10180 sshd
[root@tianyun ~]# pgrep sshd
10180
[root@tianyun ~]# pidof sshd
10180

//查看进程树
[root@tianyun ~]# pstree


动态查看进程 top
[root@tianyun ~]# top
[root@tianyun ~]# top -d 1
[root@tianyun ~]# top -d 1 -p 10126 查看指定进程的动态信息
[root@tianyun ~]# top -d 1 -p 10126,1
[root@tianyun ~]# top -d 1 -u apache 查看指定用户的进程

top -d 1 -u sshd
[root@tianyun ~]# top -d 1 -b -n 2 > top.txt 将2次top信息写入到文件

第一部分:系统整体统计信息
top - 14:15:04 up 47 min, 2 users, load average: 0.25, 0.18, 0.12
Tasks: 235 total, 1 running, 234 sleeping, 0 stopped, 0 zombie
Cpu(s): 8.9%us, 1.0%sy, 0.0%ni, 90.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 7944064k total, 746164k used, 7197900k free, 35724k buffers
Swap: 1048568k total, 0k used, 1048568k free, 261492k cached

load average: 0.86, 0.56, 0.78 CPU最近 1分钟,5分钟,15分钟平均负载



第二部分:进程信息
命令
h|?帮助
M 按内存的使用排序
P 按CPU使用排序
N 以PID的大小排序
R 对排序进行反转
f 自定义显示字段
1 显示所有CPU的负载

< 向前
> 向后
z 彩色
W 保存top环境设置 ~/.toprc

netstat


netstat用来查看系统当前系统网络状态信息,包括端口,连接情况等,常用方式如下:
netstat -atunlp,各参数含义如下:
-t : 指明显示TCP端口
-u : 指明显示UDP端口
-l : 仅显示监听套接字(LISTEN状态的套接字)
-p : 显示进程标识符和程序名称,每一个套接字/端口都属于一个程序
-n : 不进行DNS解析
-a 显示所有连接的端口• 1

一般该指令会与grep配合使用,比如查找端口22,就用netstat -tunlp | grep 22 或者干脆netstat -an | grep 22就可以了,查看其它端口类似,当然也可以通过端口状态查找即netstat -anp | grep TIME_WAIT,即只会显示含有TIME_WAIT字符串的条目

lsof


lsof的作用是列出当前系统打开文件(list open files),不过通过-i参数也能查看端口的连接情况,-i后跟冒号端口可以查看指定端口信息,直接-i是系统当前所有打开的端口
lsof -i:22 #查看22端口连接情况,默认为sshd端口


北京 ------------------------------------------------->> 广州
server1 192.168.1.2 10.10.10.2
server2 192.168.1.3 10.10.10.3


1 切服务
2系统级: 修改DNS 网卡配置文件 路由 

root
cisco -switch-01口
cisco -switch-02口


变更
IP地址

10.10.10.2 --------------------------→ 192.168.2.3


ping 192.168.2.3 -->不通才可继续操作
ssh 10.10.10.2

修改网卡配置文件/ip地址 /-----192.168.2.3/----->路由---关
systemctl restart network--->xshell XXX掉线----→ 交换机端口的vlan id--->


Guess you like

Origin blog.51cto.com/14479068/2427755