linux 阿里技术协会

摘要: Linux服务器上经常遇到一些系统和应用上的问题,如何分析排查,需要利器,下面总结列表了一些常用工具、trace tool;最后也列举了最近hadoop社区在开发发展的分布式系统的trace tool。 概览: 引用linux-performance-analysis-and-tools中图片,

Linux服务器上经常遇到一些系统和应用上的问题,如何分析排查,需要利器,下面总结列表了一些常用工具、trace tool;最后也列举了最近hadoop社区在开发发展的分布式系统的trace tool。

概览:

引用linux-performance-analysis-and-tools中图片,说明这些tool试用层次位置

OS系统命令

系统信息(RHEL/Fedora)

  • uname -a 或 cat /proc/version #print system information

    • Linux hadoopst2.cm6 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
  • uptime
    • 15:42:46 up 674 days, 6 min, 35 users, load average: 1.30, 5.97, 11.53
  • cat /etc/redhat-release
    • Red Hat Enterprise Linux Server release 5.4 (Tikanga)
  • lsb_release
    • LSB Version:  :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
  • cat /proc/cpuinfo
  • cat /proc/meminfo
  • lspci - list all PCI devices
  • lsusb - list USB devices
  • last, lastb - show listing of last logged in users
  • lsmod — show the status of modules in the Linux Kernel
  • modprobe - add and remove modules from the Linux Kernel

常用命令/工具

  • ps

    • To print a process tree: ps -ejH / ps axjf
    • To get info about threads: ps -eLf / ps axms
  • ulimit -a
  • lsof - list open files, UNIX一切皆文件
    • lsof -p PID
  • rpm/yum
    • rpm -qf FILE #文件所属rpm包
    • rpm -ql RPM #rpm包含文件
    • /var/log/yum.log #yum 更新包日志
  • /etc/XXX #系统级程序配置目录, 如
    • /etc/yum.repos.d/ yum源配置
  • /var/log/XXX #日志目录, 如
    • /var/log/cron #crontab日志,可以查看调度执行情况
  • ntpd - Network Time Protocol (NTP) daemon,同步集群中机器时间
  • squid - proxy caching server,集群WebUI的代理

系统监控

  • mpstat - Report processors related statistics. 注意%sys %iowait值
  • vmstat - Report virtual memory statistics
  • iostat - Report Central Processing Unit (CPU) statistics and input/output statistics for devices and partitions.
  • netstat - Print network connections, routing tables, interface statistics, masquerade connections, and multicast memberships
    • netstat -atpn | grep PID
  • ganglia - a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.
  • sar/tsar - Collect, report, or save system activity information; tsar是淘宝自己改进的版本
    • 定时采样(每分钟),可查历史记录(默认5分钟),可弥补ganglia显示更详细信息
  • iftop - the "top" bandwidth consumers shown. iftop wiki
  • iotop
  • vmtouch, Portable file system cache diagnostics and control

网络相关

  • telnet/nc IP PORT - 确认目标端口是否可访问,只ping通不一定端口可访问,可能防火墙等禁止
  • ifconfig/ifup/ifdown - configure a network interface
  • traceroute - print the route packets trace to network host
  • nslookup - query Internet name servers interactively
  • tcpdump - dump traffic on a network, 类似开源工具 wiresharknetsniff-ng更多工具比较
  • lynx - a general purpose distributed information browser for the World Wide Web
  • tcpcp - allows cooperating applications to pass ownership of TCP connection endpoints from one Linux host to another one.

程序/进程相关

静态信息

  • ldconfig - configure dynamic linker run time bindings

    • ldconfig -p | grep SO 查看so是否在link cache中
  • ldd - print shared library dependencies, 查看exe或so依赖的so
  • nm - list symbols from object files,可grep查找是否存在相关的symbol,是否Undefined.
  • readelf - Displays information about ELF files. 可现实elf相关信息,如32/64位,适用的OS,处理器

动态信息

  • gdb
  • cat /proc/$PID/[cmdline|environ|limits|status|...] - 进程相关信息
  • pstack - print a stack trace of a running process
  • pmap - report memory map of a process

java相关

  • JDK Tools and Utilities
  • Java Troubleshooting Tools
  • jinfo - print java process information, 如classpath,java.libary.path(jni so目录)
  • jstack - print a stack trace of a running java process,可查看死锁情况
  • jmap - report memory map of a java process
    • jmap -histo:live 可触发full gc
    • jmap -dump:live,file=$FILE 可dump heap内存,用于jhat等工具debug分析object在heap的占用情况
  • jhat - Heap Dump Browser - Starts a web server on a heap dump file (eg, produced by jmap -dump), allowing the heap to be browsed.
    • 起http服务,浏览器访问查看
    • -J-mxXXXm ,分析大文件时需要加大heap大小
    • 若有对象数据超大或内存占用过多,极有可能memory leak
  • Memory Analyzer (MAT) - eclipse plugin,Java heap analyzer
    • 可视化工具,但受到机器内存的限制,无法分析太大的heap dump file
  • jdb - 可起服务做server,eclipse等工具远程连接调试
  • jstat - Java Virtual Machine Statistics Monitoring Tool
  • jstatd - Virtual Machine jstat Daemon,可配合jvisualvm
  • jvisualvm - Java Virtual Machine Monitoring, Troubleshooting, and Profiling Tool;可远程连接jstatd/jmx, 可视化展示工具:演示
  • jvmtop - In a top-like manner, displays JVM internal metrics (e.g. memory information) of running java processes.
  • JVM performance optimization JVM开发者写的优化文章
    1. Overview
    2. Compilers
    3. Garbage collection
    4. Concurrently compacting GC
    5. Scalability
  • HPROF - Heap Profiler: java -agentlib:hprof

Trace/Debug/Profiling工具

通用工具

  • 写log,但系统在线或无法源码时
  • strace - trace system calls and signals
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
67.90 3966.320849 496 7992161 3050250 futex
25.80 1507.326693 127093 11860 epoll_wait
....................
  • blktrace, generate traces of the i/o traffic on block devices
  • ltrace - A library call tracer
  • xtrace
  • gprof - a performance analysis tool, sampling and call-graph profiling
  • valgrind - an instrumentation framework for building dynamic analysis tools. automatically detect many memory management and threading bugs, and profile your programs in detail
  • systemtap - a simple command line interface and scripting language for writing instrumentation for a live running kernel plus user-space applications for complex tasks that may require live analysis, programmable on-line response, and whole-system symbolic access.
    • Linux版DTrace(SUN在Solaris上开发的)
    • 功能强大,kernel, user-space app,cross language(java perl python ruby),build-in markers(pg mysql)
    • can write and reuse simple scripts to deeply examine the activities of a live system
    • Data can be extracted, filtered, and summarized quickly and safely, to enable diagnoses of complex performance or functional problems
    • 丰富的 "tapset" script library

java trace工具

  • btrace - dynamic tracing tool for the Java platform. UserGuide

  • byteman - simplifies tracing and testing of Java programs. Can modify a running application without needing to stop and restart it.
    • define rules specifying the side effects you want to inject 而 BTrace类java语法

Distributed Tracing Tools

  • Dapper, a Large-Scale Distributed Systems Tracing Infrastructure
  • x-trace, a network diagnostic tool designed to provide users and network operators with better visibility into increasingly complex Internet applications.
  • HTrace, a tracing framework intended for use with distributed systems written in java

Linux系统及应用问题分析排查工具的更多相关文章

  1. 在Linux系统下运行微信Web开发者工具

    微信Web开发者工具只有window版本和mac版本,如果想要在Linux系统下运行微信Web开发者工具,需要花费很大周折. 注:带 * 的步骤或文件为不确定是否管用的步骤或文件.本人系统为Linux ...

  2. 监控 Linux 系统的 7 个命令行工具

    监控 Linux 系统的 7 个命令行工具: " 深入 关于Linux最棒的一件事之一是你能深入操作系统,来探索它是如何工作的,并寻找机会来微调性能或诊断问题.这里有一些基本的命令行工具,让 ...

  3. linux系统挂掉问题的分析

    玩linux系统,经常遇到的一件事就是做了某个操作之后系统会突然挂掉,这要怎么办? 1. 首先我们要看log,看看是否会留下一些蛛丝马迹,比如PC/LR是否有留下来. PC是ARM的一个寄存器,即程序 ...

  4. Linux 系统负载查询及分析说明

    Linux 系统出现死机或卡顿时,可以参阅如下步骤进行整体排查: 检查服务器进程与服务否占用了过多内存,或者内存没有正常释放,导致出现内存溢出,系统宕机. 检查 /var/spool/cron 等系统 ...

  5. linux系统下使用流行的版本管理工具 Git

    前几天被版本管理困扰了好久,主要是因为 没法回到之前的版本,新版本又出了问题真的很尴尬. 终于决定使用目前网上很火的版本管理工具-------Git 历史啥的就不说了,说些有用的. 我用的是oschi ...

  6. Lynis 2.2.0 :面向Linux系统的安全审查和扫描工具

    Lynis是一款功能非常强大的开源审查工具,面向类似Unix/Linux的操作系统.它可以扫描系统,查找安全信息.一般的系统信息.已安装软件及可用软件信息.配置错误.安全问题.没有设密码的用户帐户.错 ...

  7. Linux系统 磁盘IO过高排查总结

    最近做的一个电商网站因为磁盘 I/O 过高导致访问速度奇慢,问题存在两个月有余未得到解决办法.此次排查原因的经验可以作下次问题的参考. 1.会看懂 top 系统命令出来的各项参数.此次是无意中发现 u ...

  8. Linux系统网络性能实例分析

    由于TCP/IP是使用最普遍的Internet协议,下面只集中讨论TCP/IP 栈和以太网(Ethernet).术语 LinuxTCP/IP栈和 Linux网络栈可互换使用,因为 TCP/IP栈是 L ...

  9. linux系统卡顿 性能分析

    systemtrap 是一个内核开发者要掌握的工具. linux performance analysis 系统瓶颈性能分析软件

随机推荐

  1. 目录重定向的源代码工程( linux平台利用VFS实现目录重定向驱动)虚拟磁盘MINIPORT驱动代码(雨中风华)

    http://download.csdn.net/user/fanxiushu/uploads/2 http://download.csdn.net/user/fanxiushu/uploads/1

  2. 在redhat6.4下安装 Oracle® Database 11g Release 2

    OS版本: 安装过程的相关信息: pdksh 安装好后根据需要设置oracle开机自启动http://www.cnblogs.com/softidea/p/3761671.html 设置环境变量NLS ...

  3. WCF - Versus Web Service

    There are some major differences that exist between WCF and a Web service which are listed below. 这里 ...

  4. 关于数组和List之间相互转换的方法

    1.List转换成为数组:返回数组的运行时类型.如果列表能放入指定的数组.否则,将根据指定数组.如果指定的数组的元素比列表的多),那么会将存储列表元素的数组. 返回:包含列表元素的list.add(& ...

  5. poj2723

    把每对钥匙看做一个变量,那两个钥匙看做他的两个状态 每一个开门的要求就是一个条件(xi or xj) 很显然有了2sat的基本要素 2sat是一个判定性问题,而这题求最多能过几个门: 不难想到二分答案 ...

  6. Android获取IMSI和IMEI

    IMSI是一个 唯一的数字, 标识了GSM和UMTS 网络里的唯一一个用户. 它 存储 在手机的SIM卡里,它会通过手机发送到网络上. IMEI也是一串唯一的数字, 标识了 GSM 和 UMTS网络里 ...

  7. Java开发心得

    1. Spring概述 Spring 是一个开源框架,是为了解决企业应用程序开发复杂性由Rod Johnson创建的.框架的主要优势之一就是其分层架构,分层架构允许使用者选择使用哪一个组件,同时为 J ...

  8. 不要浪费人生的每一天 ——Dropbox创始人在麻省理工的演讲 z

    Dropbox 创始人,CEO 德鲁·休斯顿(Drew Houston)近期在美国麻省理工学院的毕业典礼上发表演讲.他向大学生提出了 3 点人生建议:追逐自己感兴趣的事,找到最合适的圈子,以及不要浪费 ...

  9. javascript 关于cookie的操作

    <script language=javascript> //获得coolie 的值 function cookie(name){ var cookieArray=document.coo ...

  10. 【转】Getting xrdp to work on CentOS 6.4

    vi /etc/selinux/config SELINUX=disabled reboot Step 1: #rpm -Uvh http://pkgs.repoforge.org/rpmforge- ...