10 用awk分析文件

  • 查看nginx访问每秒并发统计top20,awk '{print $4}' access.log |cut -c 14-21|sort|uniq -c|sort -nr|head -n 20

  • 查看请求的url次数top20统计,awk '{print $7}' access.log |sort | uniq -c |sort -n -k 1 -r|head -n 20,把head -n 20more替换才能回车看到全部的url

9 mac下查看进程

lsof -i tcp:1088

8 网络不通,如何诊断

缘由:

不通

您iptables -L 查看一下您服务器出方向是否对端口有禁行呢?

查看防火墙

防火墙没有限制规则的,麻烦您找个时间登录服务器做下端口探测,我们看下,谢谢, 方法参考这里

网络路由

查看具体端口不通的路由节点是在IP 122.189.40.42查询为湖北咸宁联通运营商,已经出了阿里云机房网络,应该是在对应本地运营商骨干网络吧, 建议您可以尝试根据此路由测试结果进行运营商报障,或者是尝试更换下服务器公网IP,换成EIP绑定ECS使用,这样就可以随时进行换IP了,您可以参考一下。

7 查看外部连接

netstat -tonp

居然这效果:

Active Internet connections (w/o servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name     Timer
tcp        0      0 172.26.71.242:60612     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.70/0/0)
tcp        0      0 172.26.71.242:60626     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.72/0/0)
tcp        0      0 172.26.71.242:60618     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.71/0/0)
tcp        0      0 172.26.71.242:36056     100.100.30.25:80        ESTABLISHED 1917/AliYunDun       off (0.00/0/0)
tcp        0      0 172.26.71.242:60616     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.71/0/0)
tcp        0    212 172.26.71.242:22        172.26.71.240:42928     ESTABLISHED 13663/sshd: root@pt  on (0.20/0/0)
tcp        0      0 172.26.71.242:49022     172.26.71.241:9600      ESTABLISHED 13488/java           off (0.00/0/0)
tcp        0      0 172.26.71.242:60614     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.70/0/0)
tcp        0      0 172.26.71.242:60624     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.72/0/0)
tcp        0      0 172.26.71.242:60608     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.70/0/0)
tcp        0      0 172.26.71.242:60610     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.70/0/0)
tcp        0      0 172.26.71.242:60622     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.72/0/0)
tcp        0      0 172.26.71.242:60620     172.26.71.241:3306      ESTABLISHED 13488/java           keepalive (6434.71/0/0)
tcp        0      0 172.26.71.242:22        172.26.71.240:41632     ESTABLISHED 13023/sshd: root@no  keepalive (6594.66/0/0)
tcp        0      0 172.26.71.242:43396     172.26.71.241:6379      ESTABLISHED 13488/java           keepalive (6375.32/0/0)

统计外部连接的量,比如netstat -an | grep 6379 | grep EST | wc -l能统计出连接到这个端口的连接数量

6 tar的用法

  • 打包并排除子目录: tar --exclude toc/log -cvzf app2.tar toc/ ,更多可以参考这里

5 centos卸载自带的jdk

rpm -qa|grep jdk查看版本,显示:jdk-1.7.0_71-fcs.x86_64

rpm -e --nodeps jdk-1.7.0_71-fcs.x86_64卸载

4 查看系统版本

centos:

  • cat /etc/redhat-release查看版本 ,比如结果:
CentOS Linux release 7.3.1611 (Core) 
  • rpm -q kernel查看内核,结果:
kernel-3.10.0-514.el7.x86_64

3 make时/bin/sh: cc: command not found

sudo yum -y install gcc gcc-c++ libstdc++-devel # 安装类库
make MALLOC=libc
rpm -qa|grep cc # 检查一下程序是否安装

2 搜索大文件

find / -xdev -size +100M -exec ls -l {} \; # 大于100M的文件全给我出来

1 改变目录所有者

chgrp GROUPNAME DIR -r # 所属用户组 chown USERNAME DIR -r # 所属用户