update doc

This commit is contained in:
hengyunabc committed 2018-09-13 01:43:46 +08:00
1 parent 54ca57afa1
commit b651be8826
13 files changed
+30 -546

No files matched your search

-135
View File
@@ -1,135 +0,0 @@
Arthas 用户文档
===
## Arthas(阿尔萨斯) 能为你做什么?
当你遇到以下类似问题而束手无策时,你看到了这篇文档,看到了 `Arthas`,那么恭喜你,你朝正确的方向又迈了一大步。
0. 这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
0. 我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
0. 遇到问题无法在预发 debug 一下,难道只能通过加日志再重新预发布吗?
0. 线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
0. 是否有一个全局视角来查看系统的运行状况?
0. 有什么办法可以监控到容器和中间件(AliTomcat、HSF、Notify 等)的实时运行状态?
`Arthas` 是全新的在线诊断工具,采用命令行交互模式,支持web端在线诊断,同时提供丰富的 `Tab` 自动补全功能,进一步方便进行问题的定位和诊断。
## [Release Notes](release-notes)
## Arthas 安装及使用
### 1. 在线诊断
TODO
### 2. 通过脚本使用Arthas
* 下载脚本
#### MAC/Linux
```sh
curl -L TODO /install.sh | sh
```
#### Windows
点击 [下载](TODO) 最新zip包
> 如遇无法下载,请参考[这里](install-detail)
* 启动 Arthas
`./as.sh`
执行该脚本的用户需要和目标进程具有相同的权限。比如以`admin`用户来执行:
`sudo su admin && ./as.sh` 或 `sudo -u admin -EH ./as.sh`
详细的启动脚本说明,请参考[这里](start-arthas)
如果attatch不上目标进程,可以查看`~/logs/arthas/` 目录下的日志。
### 3. 开启诊断之旅
为了使你快速找到适合你分析、诊断问题的命令,我们将 Arthas 的命令按问题的类型做了一个大的分类,如下:
#### 想快速了解系统、应用运行状况
---
* [dashboard](dashboard)——当前系统的实时数据面板
* [thread](thread)——查看当前 JVM 的线程堆栈信息
* [jvm](jvm)——查看当前 JVM 的信息
* [sysprop](sysprop)——查看和修改JVM的系统属性
* **New!** [getstatic](getstatic)——查看类的静态属性
#### 类、方法冲突、class文件、classloader继承问题等
---
* [sc](sc)——查看JVM已加载的类信息
* [sm](sm)——查看已加载类的方法信息
* [dump](dump)——dump 已加载类的 byte code 到特定目录
* [redefine](redefine)——加载外部的`.class`文件,redefine到JVM里
* [jad](jad)——反编译指定已加载类的源码
* [classloader](classloader)——查看classloader的继承树,urls,类加载信息,使用classloader去getResource
#### 查看方法执行参数、异常、返回值、调用路径等
> 非常重要,请注意,这些命令,都通过字节码增强技术来实现的,会在指定类的方法中插入一些切面来实现数据统计和观测,因此在线上、预发使用时,请尽量明确需要观测的类、方法以及条件,诊断结束要执行 `shutdown` 或将增强过的类执行 `reset` 命令。
* [monitor](monitor)——方法执行监控
* [watch](watch)——方法执行数据观测
* [trace](trace)——方法内部调用路径,并输出方法路径上的每个节点上耗时
* [stack](stack)——输出当前方法被调用的调用路径
* [tt](tt)——方法执行数据的时空隧道,记录下指定方法每次调用的入参和返回信息,并能对这些不同的时间下调用进行观测
#### options
* [options](options)——查看或设置Arthas全局开关
#### Arthas 基础命令
* help——查看命令帮助信息
* cls——清空当前屏幕区域
* session——查看当前会话的信息
* [reset](reset)——重置增强类,将被 Arthas 增强过的类全部还原,Arthas 服务端关闭时会重置所有增强过的类
* version——输出当前目标 Java 进程所加载的 Arthas 版本号
* quit——退出当前 Arthas 客户端,其他 Arthas 客户端不受影响
* shutdown——关闭 Arthas 服务端,所有 Arthas 客户端全部退出
* [keymap](keymap)——Arthas快捷键列表及自定义快捷键
#### 管道
Arthas支持使用管道对上述命令的结果进行进一步的处理,如`sm org.apache.log4j.Logger | grep <init>`
* grep——搜索满足条件的结果
* plaintext——将命令的结果去除颜色
* wc——按行统计输出结果
#### 后台异步任务
当线上出现偶发的问题,比如需要watch某个条件,而这个条件一天可能才会出现一次时,异步后台任务就派上用场了,详情请参考[这里](async.md)
* 使用 > 将结果重写向到日志文件,使用 & 指定命令是后台运行,session断开不影响任务执行(生命周期默认为1天)
* jobs——列出所有job
* kill——强制终止任务
* fg——将暂停的任务拉到前台执行
* bg——将暂停的任务放到后台执行
### 4. 常见问题及FAQ
TODO
### 5. 其他特性说明
* [异步命令支持](async.md)
* [执行结果存日志](options.md)
* [批处理的支持](batch-support.md)
* [ognl表达式的用法说明](TODO/articles/92448)
### 6. 用户使用案例
* [用户使用案例](usercase)
* [Arthas——码农的才思与浪漫] TODO
钉钉交流群号: TODO
-1
View File
@@ -1 +0,0 @@
This is home.
-18
View File
@@ -1,18 +0,0 @@
* 命令使用
* [系统指标](dashboard)
* [线程堆栈](thread)
* [JVM信息](jvm)
* [查看类信息](sc)
* [查看方法信息](sm)
* [dump字节码](dump)
* [反编译类](jad)
* [查看类加载信息](classloader)
* [方法执行监控](monitor)
* [方法AOP观测](watch)
* [方法内部路径耗时](trace)
* [查看方法调用栈](stack)
* [方法执行记录与回放](tt)
* [启动脚本说明](start-arthas)
* [Release Notes](release-notes)
* 常见问题
* [FAQ](TODO)
+1 -1
View File
@@ -72,4 +72,4 @@ Arthas支持使用管道对上述命令的结果进行进一步的处理,如`s
* [异步命令支持](async.md)
* [执行结果存日志](save-log.md)
* [批处理的支持](batch-support.md)
* [ognl表达式的用法说明](TODO/articles/92448)
* [ognl表达式的用法说明](https://github.com/alibaba/arthas/issues/11)
+2 -2
View File
@@ -27,7 +27,7 @@ watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params +
为了避免这个问题,Arthas 3.0中使用了ognl这个更加轻量的表达式求值库来代替groovy,彻底解决了groovy引起的FGC风险。但由于这个替换,导致原来使用groovy脚本编写的自定义脚本失效。这个问题留待后续解决。
在3.0中,watch命令的表达式部分的书写有了一些改变,详见[这里](https://github.com/alibaba/arthas/wiki/watch)
在3.0中,watch命令的表达式部分的书写有了一些改变,详见[这里](https://alibaba.github.io/arthas/watch)
#### 提升rt统计精度
@@ -47,7 +47,7 @@ $ tt -l
#### watch/stack/trace命令支持按耗时过滤
我们在trace的时候,经常会出现某个方法间隙性的rt飙高,但是我们只想知道rt高的时候,是哪里慢了,对于正常rt的方法我们并不关心,Arthas 3.0支持了按`#cost`(方法执行耗时,单位为`ms`)进行过滤,只输出符合条件的trace路径,目前,这三个命令的相关文档已经做了更新,增加了该用法的示例,请在[这里](https://github.com/alibaba/arthas/wiki/home#%E6%9F%A5%E7%9C%8B%E6%96%B9%E6%B3%95%E6%89%A7%E8%A1%8C%E5%8F%82%E6%95%B0%E5%BC%82%E5%B8%B8%E8%BF%94%E5%9B%9E%E5%80%BC%E8%B0%83%E7%94%A8%E8%B7%AF%E5%BE%84%E7%AD%89)查看。
我们在trace的时候,经常会出现某个方法间隙性的rt飙高,但是我们只想知道rt高的时候,是哪里慢了,对于正常rt的方法我们并不关心,Arthas 3.0支持了按`#cost`(方法执行耗时,单位为`ms`)进行过滤,只输出符合条件的trace路径,目前,这三个命令的相关文档已经做了更新,增加了该用法的示例。
#### sysprop命令操作SystemProperty
-109
View File
@@ -1,109 +0,0 @@
Arthas 3.0使用说明
===
## 命令行诊断
1. 安装Arthas 3.0启动脚本
```
curl -sLk http://TODO/arthas/install.sh | sh
```
2. 可以直接运行`./as.sh`,启动脚本会自动更新到最新版本
```
➜ tmp ./as.sh
Found existing java process, please choose one and hit RETURN.
* [1]: 53090 org.apache.catalina.startup.Bootstrap
[2]: 50020
[3]: 69893 org.jetbrains.idea.maven.server.RemoteMavenServer
[4]: 93320 org.jetbrains.jps.cmdline.Launcher
updating version 3.0.20170224142641 ...
######################################################################## 100.0%
Archive: /var/tmp/temp_3.0.20170224142641_35932/arthas-3.0.20170224142641-bin.zip
creating: /var/tmp/temp_3.0.20170224142641_35932/arthas/
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/arthas-agent.jar
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/arthas-client.jar
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/arthas-core.jar
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/arthas-spy.jar
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/as.bat
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/as.sh
inflating: /var/tmp/temp_3.0.20170224142641_35932/arthas/install-local.sh
update completed.
Calculating attach excecution time...
Attaching to 53090...
real 0m0.336s
user 0m0.498s
sys 0m0.075s
Attach success.
Connecting to arthas server... current timestamp is 1488178414
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki: https://github.com/alibaba/arthas/wiki/
version: 3.0.20170227131708
pid: 53090
timestamp: 1488178414548
```
### telnet远程诊断
只要在上一步中启动了Arthas Server, 那么你可以直接在本地(针对日常环境的机器),或者是跳板机(针对预发和线上机器)上,通过telnet命令直接远程连上去诊断,使用上的体验完全一致。
```
➜ telnet 11.164.45.24 3658
Trying 11.164.45.24...
Connected to 11.164.45.24.
Escape character is '^]'.
,---. ,------. ,--------.,--. ,--. ,---. ,---.
/ O \ | .--. ''--. .--'| '--' | / O \ ' .-'
| .-. || '--'.' | | | .--. || .-. |`. `-.
| | | || |\ \ | | | | | || | | |.-' |
`--' `--'`--' '--' `--' `--' `--'`--' `--'`-----'
wiki: https://github.com/alibaba/arthas/wiki/home
version: 3.0.20170315140000
pid: 1463
timestamp: 1490938898194
$
```
## 新特性介绍
请参考[Arthas 3.0新特性](https://github.com/alibaba/arthas/wiki/arthas_3_0/new_feature)
## FAQ
首先请确保你的目标机器上,Arthas 2.0的server正常的shutdown了。否则,Arthas 3.0连上去之后不会正常启动。
### 关于web console中文本的复制粘贴
目前不同浏览器对复制粘贴的支持程度各不相同,mac下的Chrome是支持的最好的,目前的支持情况如下,我们正在想办法提供更好的复制粘贴体验
| 操作系统 | 浏览器 | 复制 | 粘贴 |
| ------- | ------- | -------------- | ---------------- |
| macOS | Chrome | COMMAND-C,鼠标右键-复制 | COMMAND-V,鼠标右键-粘贴 |
| macOS | Safari | 鼠标右键-复制 | 鼠标右键-粘贴 |
| macOS | Firefox | | |
| Windows | Chrome | Ctrl + C | Ctrl + Shift + V |
| Windows | Firefox | | |
### 关于字体大小
如果觉得字体太小,可以通过浏览器内置的字体调整功能进行,web console支持自适应调整。
| 操作系统 | 浏览器 | 增大字体 | 减小字体 |
| ------- | ------- | -------------- | ---------------- |
| macOS | Chrome | COMMAND加= | COMMAND加- |
| macOS | Safari | COMMAND加= | COMMAND加- | |
| macOS | Firefox | | |
| Windows | Chrome | | |
| Windows | Firefox | | |
@@ -63,7 +63,7 @@ watch com.alibaba.sample.petstore.web.store.module.screen.ItemList add "params +
为了避免这个问题,Arthas 3.0中使用了ognl这个更加轻量的表达式求值库来代替groovy,彻底解决了groovy引起的FGC风险。但由于这个替换,导致原来使用groovy脚本编写的自定义脚本失效。这个问题留待后续解决。
在3.0中,watch命令的表达式部分的书写有了一些改变,详见[这里](https://github.com/alibaba/arthas/wiki/watch)
在3.0中,watch命令的表达式部分的书写有了一些改变,详见[这里](https://alibaba.github.io/arthas/watch)
### 提升rt统计精度
Arthas 2.0中,统计rt都是以`ms`为单位,对于某些比较小的方法调用,耗时在毫秒以下的都会被认为是0ms,造成trace总时间和各方法的时间相加不一致等问题(虽然这里面确实会有误差,主要Arthas自身的开销)。Arthas 3.0中所有rt的单位统一改为使用`ns`来统计,精准捕获你的方法耗时,让0ms这样无意义的统计数据不再出现!
-245
View File
@@ -1,245 +0,0 @@
AutoStructify Component
=======================
AutoStructify is a component in recommonmark that takes a parsed docutil AST by `CommonMarkParser`,
and transform it to another AST that introduces some of more. This enables additional features
of recommonmark syntax, to introduce more structure into the final generated document.
Configuring AutoStructify
-------------------------
The behavior of AutoStructify can be configured via a dict in document setting.
In sphinx, you can configure it by `conf.py`. The following snippet
is what is actually used to generate this document, see full code at [conf.py](conf.py).
```python
github_doc_root = 'https://github.com/rtfd/recommonmark/tree/master/doc/'
def setup(app):
app.add_config_value('recommonmark_config', {
'url_resolver': lambda url: github_doc_root + url,
'auto_toc_tree_section': 'Contents',
}, True)
app.add_transform(AutoStructify)
```
All the features are by default enabled
***List of options***
* __enable_auto_toc_tree__: whether enable [Auto Toc Tree](#auto-toc-tree) feature.
* __auto_toc_tree_section__: when enabled, [Auto Toc Tree](#auto-toc-tree) will only be enabled on section that matches the title.
* __enable_auto_doc_ref__: whether enable [Auto Doc Ref](#auto-doc-ref) feature. **Deprecated**
* __enable_math__: whether enable [Math Formula](#math-formula)
* __enable_inline_math__: whether enable [Inline Math](#inline-math)
* __enable_eval_rst__: whether [Embed reStructuredText](#embed-restructuredtext) is enabled.
* __url_resolver__: a function that maps a existing relative position in the document to a http link
Auto Toc Tree
-------------
One of important command in tools like sphinx is `toctree`. This is a command to generate table of contents and
tell sphinx about the structure of the documents. In markdown, usually we manually list of contents by a bullet list
of url reference to the other documents.
AutoStructify will transforms bullet list of document URLs
```
* [Title1](doc1.md)
* [Title2](doc2.md)
```
will be translated to the AST of following reStructuredText code
```rst
.. toctree::
:maxdepth: 1
doc1
doc2
```
You can also find the usage of this feature in `index.md` of this document.
Auto Doc Ref
------------
```eval_rst
.. note:: **This option is deprecated.**
This option has been superseded by the default linking behavior, which
will first try to resolve as an internal reference, and then as an
external reference.
```
It is common to refer to another document page in one document. We usually use reference to do that.
AutoStructify will translate these reference block into a structured document reference. For example
```
[API Reference](api_ref.md)
```
will be translated to the AST of following reStructuredText code
```
:doc:`API Reference </api_ref>`
```
And it will be rendered as [API Reference](api_ref)
URL Resolver
------------
Sometimes in a markdown, we want to refer to the code in the same repo.
This can usually be done by a reference by reference path. However, since the generated document is hosted elsewhere,
the relative path may not work in generated document site. URL resolver is introduced to solve this problem.
Basically, you can define a function that maps an relative path of document to the http path that you wish to link to.
For example, the setting mentioned in the beginning of this document used a resolver that maps the files to github.
So `[parser code](../recommonmark/parser.py)` will be translated into [parser code](../recommonmark/parser.py)
Note that the reference to the internal document will not be passed to url resolver, and will be linked to the internal document pages correctly, see [Auto Doc Ref](#auto-doc-ref).
Codeblock Extensions
--------------------
In markdown, you can write codeblocks fenced by (at least) three backticks
(```` ``` ````). The following is an example of codeblock.
````
``` language
some code block
```
````
Codeblock extensions are mechanism that specialize certain codeblocks to different render behaviors.
The extension will be trigger by the language argument to the codeblck
### Syntax Highlight
You can highlight syntax of codeblocks by specifying the language you need. For example,
````
```python
def function():
return True
```
````
will be rendered as
```python
def function():
return True
```
### Math Formula
You can normally write latex math formula with `math` codeblock. See also [Inline Math](#inline-math).
Example
````
```math
E = m c^2
```
````
will be rendered as
```math
E = m c^2
```
### Embed reStructuredText
Recommonmark also allows embedding reStructuredText syntax in the codeblocks.
There are two styles for embedding reStructuredText. The first is enabled by `eval_rst` codeblock. The content of codeblock will be parsed as reStructuredText and insert into the document. This can be used to quickly introduce some of reStructuredText command that not yet available in markdown. For example,
````
```eval_rst
.. autoclass:: recommonmark.transform.AutoStructify
:show-inheritance:
```
````
will be rendered as
```eval_rst
.. autoclass:: recommonmark.transform.AutoStructify
:show-inheritance:
```
This example used to use sphinx autodoc to insert document of AutoStructify class definition into the document.
The second style is a shorthand of the above style. It allows you to leave off the eval_rst .. portion and directly render directives. For example,
````rst
``` important:: Its a note! in markdown!
```
````
will be rendered as
``` important:: Its a note! in markdown!
```
#### An Advanced Example
````rst
``` sidebar:: Line numbers and highlights
emphasis-lines:
highlights the lines.
linenos:
shows the line numbers as well.
caption:
shown at the top of the code block.
name:
may be referenced with `:ref:` later.
```
``` code-block:: markdown
:linenos:
:emphasize-lines: 3,5
:caption: An example code-block with everything turned on.
:name: Full code-block example
# Comment line
import System
System.run_emphasis_line
# Long lines in code blocks create a auto horizontal scrollbar
System.exit!
```
````
will be rendered as
``` sidebar:: Line numbers and highlights
emphasis-lines:
highlights the lines.
linenos:
shows the line numbers as well.
caption:
shown at the top of the code block.
name:
may be referenced with `:ref:` later.
```
``` code-block:: markdown
:linenos:
:emphasize-lines: 3,5
:caption: An example code-block with everything turned on.
:name: Full code-block example
# Comment line
import System
System.run_emphasis_line
# Long lines in code blocks create a auto horizontal scrollbar
System.exit!
```
The `<div style="clear: right;"></div>` line clears the sidebar for the next title.
<div style="clear: right;"></div>
Inline Math
-----------
Besides the [Math Formula](#math-formula), you can also write latex math in inline codeblock text. You can do so by inserting `$`
in the beginning and end of inline codeblock.
Example
```
This formula `$ y=\sum_{i=1}^n g(x_i) $`
```
will be rendered as:
This formula `$ y=\sum_{i=1}^n g(x_i) $`
+5
View File
@@ -21,6 +21,11 @@ curl -L https://alibaba.github.io/arthas/install.sh | sh
Windows用户如果在cmd里不能正常显示颜色,可以使用[conemu](https://sourceforge.net/projects/conemu)。
## 手动安装
[手动安装](manual-install.md)
## 离线帮助文档
下载地址:[arthas-packaging-3.0.0-RC-doc.zip](https://search.maven.org/remotecontent?filepath=com/taobao/arthas/arthas-packaging/3.0.0-RC/arthas-packaging-3.0.0-RC-doc.zip)
+20 -18
View File
@@ -1,25 +1,27 @@
手动安装Arthas
===
1. 从[这里](TODO)下载指定的版本, 以`3.0.20171103142340`这个版本为例。
```
wget TODO arthas-3.0.20171103142340-bin.zip
```
1. 从[这里](http://search.maven.org/classic/#search%7Cga%7C1%7Cg%3A%22com.taobao.arthas%22%20AND%20a%3A%22arthas-packaging%22)下载最新版本, 以`3.0.0-RC`这个版本为例。
```
wget https://search.maven.org/remotecontent?filepath=com/taobao/arthas/arthas-packaging/3.0.0-RC/arthas-packaging-3.0.0-RC-bin.zip -o arthas-packaging-bin.zip
```
2. 解压缩arthas的压缩包
```
unzip arthas-3.0.20171103142340-bin.zip
```
```
unzip arthas-packaging-bin.zip
```
3. 安装Arthas: 安装之前最好把所有老版本的Arthas全都删掉
```
sudo su admin
rm -rf /home/admin/.arthas/lib/*
cd arthas
./install-local.sh
```
> 注意,这里根据你需要诊断的Java进程的所属用户进行切换,例如集团规范是admin用户,而阿里云的可能是tomcat用户。否则会安装到个人目录下,这样的安装是无效的。
3. 启动Arthas: 启动之前,请确保老版本的Arthas已经shutdown.
```
./as.sh
```
```
sudo su admin
rm -rf /home/admin/.arthas/lib/*
cd arthas
./install-local.sh
```
> 注意,这里根据你需要诊断的Java进程的所属用户进行切换
4. 启动Arthas: 启动之前,请确保老版本的Arthas已经shutdown.
```
./as.sh
```
-10
View File
@@ -1,10 +0,0 @@
![arthas-roadmap](TODO/arthas-roadmap.png)
### 设计原则
* microservices envy: 理想状态下,所有数据通过 /metrics, /health, /config 暴露
* endpoint 可扩展
* endpoint 数据本身就应该可以判定子系统有无问题,而平台只是做展示和聚合。有无平台并不妨碍用户获取数据 (devops)
* 但是平台要成为开发的第一入口,因为其他方式太麻烦了
* 集群数据、单机历史数据作为单机诊断的依据,单纯的展示没有意义
* 场景优先,有助于曝光的场景优先实施
+1 -1
View File
@@ -18,7 +18,7 @@ sysprop
sysprop production.mode true
WIKI:
https://github.com/alibaba/arthas/wiki/sysprop
https://alibaba.github.io/arthas/sysprop
OPTIONS:
-h, --help this help
-5
View File
@@ -1,5 +0,0 @@
## 用户使用arthas案例
收集典型的用户使用案例,可以参考。
* [如何使图片空间机器成本降低50%](TODO)