java应用问题排查要点之linux

一般java应用程序都跑在linux环境中,如果linux系统有问题,那么必须有可能导致java应用程序也会出问题

针对该情况就说两种排查方式

1. linux系统性能

2. JVM问题

 

linux中基本都是命令,首先在学会使用这些命令,最好的办法就是通过man命令来学习

man 你想知道的命令

 

接下来最重要的几个点为: CPU,Memory,IO,Network

 

了解几个基本概念:

上下文切换(Context Switches):如果可运行的线程数大于CPU的数量,那么OS最终会强行换出正在执行的线程,从而使其他线程能够使用CPU,它会保存当前运行线程的执行上下文,并重建新调入线程的执行上下文。

 

运行队列(Run Queue ):每个CPU 都维护一个线程的运行队列。如果CPU 子系统处于高负荷下,那就意味着内核调度将无法及时响应系统请求.导致结果,可运行状态进程拥塞在运行队列里.当运行队列越来越巨大,进程线程将花费更多的时间获取被执行., 每个运行队列不超过1-3个线程

 

Load:

CPU队列中有多少数目的线程,以及其中当前有多少进程线程数目被执行的组合, 安全load,一般就是cpu的个数

 

CPU 利用率: CPu使用的百分比  有User Time, System Time, Wait IO,,Idle

比较平衡的cpu利用率:

65% -70% User Time

30% -35% System Time

0% -5% Idle Time

 

中断:Devices tell the kernel that they are done processing

 

 

查看cpu的信息  cat /pro/cpuinfo

查看cpu的个数: grep 'processor' /pro/cpuinfo | wc -l

查看系统运行多少时间:  uptime, 同时该命令显示当前系统在1min,5min,15min系统平均load

 

实时性能监测命令: vmstat

       后面可以跟数字,多少时间刷新一次  如: vmstat 1

       procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------

       r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st

       0  0   1588  77684 292764 910576    0    0     0    14    3    0  0  0 100  0  0

       2  0   1588  77684 292764 910576    0    0     0    56  202  436  0  0 100  0  0

       0  0   1588  77660 292764 910576    0    0     0     0  209  460  0  0 100  0  0

 

FIELD DESCRIPTION FOR VM MODE

   Procs

       r: The number of processes waiting for run time.

       b: The number of processes in uninterruptible sleep.

 

   Memory

       swpd: the amount of virtual memory used.

       free: the amount of idle memory.

       buff: the amount of memory used as buffers.

       cache: the amount of memory used as cache.

       inact: the amount of inactive memory. (-a option)

       active: the amount of active memory. (-a option)

 

   Swap

       si: Amount of memory swapped in from disk (/s).

       so: Amount of memory swapped to disk (/s).

 

   IO

       bi: Blocks received from a block device (blocks/s).

       bo: Blocks sent to a block device (blocks/s).

 

   System

       in: The number of interrupts per second, including the clock.

       cs: The number of context switches per second.

 

   CPU

       These are percentages of total CPU time.

       us: Time spent running non-kernel code. (user time, including nice time)

       sy: Time spent running kernel code. (system time)

       id: Time spent idle. Prior to Linux 2.5.41, this includes IO-wait time.

       wa: Time spent waiting for IO. Prior to Linux 2.5.41, included in idle.

       st: Time stolen from a virtual machine. Prior to Linux 2.6.11, unknown

 

top命令: 直接输入top回车

       按1可以显示各个cpu的运行情况

mpstat : 不但能查看所有cpu的平均状况信息,还可以查看特定cpu的运行信息

       


memory


查看内存信息: cat /pro/meminfo

同样可以根据vmstat来查看memory的信息


IO

通过df命令可以查看磁盘空间的使用情况  df -ha

通过iostat可以来查看 io写入情况

Device:         rrqm/s   wrqm/s   r/s   w/s   rsec/s   wsec/s avgrq-sz avgqu-sz   await  svctm  %util
xvda              0.02     3.27  0.05  3.87     1.29    57.14    14.92     0.01    2.23   0.41   0.16
xvda1             0.00     0.00  0.00  0.00     0.00     0.00     5.37     0.00    5.58   2.41   0.00
xvda2             0.00     1.74  0.03  1.36     0.83    24.74    18.43     0.00    2.38   0.60   0.08
xvda3             0.00     0.00  0.00  0.00     0.00     0.00    29.39     0.00   20.93   1.24   0.00
xvda4             0.00     0.00  0.00  0.00     0.00     0.00     2.00     0.00    2.67   2.67   0.00
xvda5             0.02     1.54  0.02  2.51     0.46    32.40    12.99     0.01    2.15   0.36   0.09


网络相关

netstat, ifconfig, ping 等命令来查看网络状况

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值