update doc

This commit is contained in:
hengyunabc
2020-09-22 14:13:20 +08:00
parent 5ccb3e21a4
commit c1dcc8ff9e
12 changed files with 397 additions and 4 deletions
+53
View File
@@ -1,6 +1,59 @@
Docker
===
## 在Docker里使用JDK
很多时候,应用在docker里出现arthas无法工作的问题,是因为应用没有安装 JDK ,而是安装了 JRE 。如果只安装了 JRE,则会缺少很多JAVA的命令行工具和类库,Arthas也没办法正常工作。下面介绍两种常见的在Docker里使用JDK的方式。
### 使用公开的JDK镜像
* https://hub.docker.com/_/openjdk/
比如:
```
FROM openjdk:8-jdk
```
或者:
```
FROM openjdk:8-jdk-alpine
```
### 通过包管理软件来安装
比如:
```bash
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
```
或者:
```bash
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME
```
## 通过Docker快速入门
1. 删除本地已有的`arthas-demo` docker container(非必要)
+46
View File
@@ -183,3 +183,49 @@ $ profiler version
Async-profiler 1.6 built on Sep 9 2019
Copyright 2019 Andrei Pangin
```
### 配置 framebuf 参数
> 如果遇到生成的svg图片有 `[frame_buffer_overflow]`,则需要增大 framebuf(默认值是 1'000'000),可以显式配置,比如:
```bash
profiler start --framebuf 5000000
```
### 配置 include/exclude 来过滤数据
如果应用比较复杂,生成的内容很多,想只关注部分数据,可以通过 include/exclude 来过滤。比如
```bash
profiler start --include 'java/*' --include 'demo/*' --exclude '*Unsafe.park*'
```
> include/exclude 都支持设置多个值 ,但是需要配置在命令行的最后。
### 指定执行时间
比如,希望profiler执行 300 秒自动结束,可以用 `-d`/`--duration` 参数指定:
```bash
profiler start --duration 300
```
### 生成 jfr格式结果
> 注意,jfr只支持在 `start`时配置。如果是在`stop`时指定,则不会生效。
```
profiler start --file /tmp/test.jfr
```
`file`参数支持一些变量:
* 时间戳: `--file /tmp/test-%t.jfr`
* 进程ID: `--file /tmp/test-%p.jfr`
生成的结果可以用支持jfr格式的工具来查看。比如:
* JDK Mission Control : https://github.com/openjdk/jmc
* JProfiler : https://github.com/alibaba/arthas/issues/1416
+2
View File
@@ -18,6 +18,8 @@ Arthas Spring Boot Starter
应用启动后,spring会启动arthas,并且attach自身进程。
> 一键创建包含 Arthas Spring Boot Starter 的工程:[点击](http://start.aliyun.com/bootstrap.html/#!dependencies=arthas)
### 配置属性
比如,通过配置tunnel server实现远程管理:
+51 -2
View File
@@ -111,7 +111,12 @@
<li class="toctree-l1"><a class="reference internal" href="web-console.html">WebConsole</a></li>
<li class="toctree-l1"><a class="reference internal" href="http-api.html">Http API</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Docker</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#id1">通过Docker快速入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="#dockerjdk">在Docker里使用JDK</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#jdk">使用公开的JDK镜像</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id1">通过包管理软件来安装</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#id2">通过Docker快速入门</a></li>
<li class="toctree-l2"><a class="reference internal" href="#dockerjava">诊断Docker里的Java进程</a></li>
<li class="toctree-l2"><a class="reference internal" href="#k8sjava">诊断k8s里容器里的Java进程</a></li>
<li class="toctree-l2"><a class="reference internal" href="#arthas">把Arthas安装到基础镜像里</a></li>
@@ -193,8 +198,52 @@
<div class="section" id="docker">
<h1>Docker<a class="headerlink" href="#docker" title="永久链接至标题"></a></h1>
<div class="section" id="dockerjdk">
<h2>在Docker里使用JDK<a class="headerlink" href="#dockerjdk" title="永久链接至标题"></a></h2>
<p>很多时候,应用在docker里出现arthas无法工作的问题,是因为应用没有安装 JDK ,而是安装了 JRE 。如果只安装了 JRE,则会缺少很多JAVA的命令行工具和类库,Arthas也没办法正常工作。下面介绍两种常见的在Docker里使用JDK的方式。</p>
<div class="section" id="jdk">
<h3>使用公开的JDK镜像<a class="headerlink" href="#jdk" title="永久链接至标题"></a></h3>
<ul class="simple">
<li><p>https://hub.docker.com/_/openjdk/</p></li>
</ul>
<p>比如:</p>
<div class="highlight-default notranslate"><pre class="literal-block">FROM openjdk:8-jdk</pre>
</div>
<p>或者:</p>
<div class="highlight-default notranslate"><pre class="literal-block">FROM openjdk:8-jdk-alpine</pre>
</div>
</div>
<div class="section" id="id1">
<h2>通过Docker快速入门<a class="headerlink" href="#id1" title="永久链接至标题"></a></h2>
<h3>通过包管理软件来安装<a class="headerlink" href="#id1" title="永久链接至标题"></a></h3>
<p>比如:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash"># Install OpenJDK-8
RUN apt-get update &amp;&amp; \
apt-get install -y openjdk-8-jdk &amp;&amp; \
apt-get install -y ant &amp;&amp; \
apt-get clean;
# Fix certificate issues
RUN apt-get update &amp;&amp; \
apt-get install ca-certificates-java &amp;&amp; \
apt-get clean &amp;&amp; \
update-ca-certificates -f;
# Setup JAVA_HOME -- useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME</pre></div>
</div>
<p>或者:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME</pre></div>
</div>
</div>
</div>
<div class="section" id="id2">
<h2>通过Docker快速入门<a class="headerlink" href="#id2" title="永久链接至标题"></a></h2>
<ol>
<li><p>删除本地已有的<code class="docutils literal notranslate"><span class="pre">arthas-demo</span></code> docker container(非必要)</p>
<div class="highlight-sh notranslate"><div class="highlight hljs"><pre class="sh">$ docker stop arthas-demo || true &amp;&amp; docker rm arthas-demo || true</pre></div>
+55
View File
@@ -1,6 +1,61 @@
Docker
===
## Use JDK in Docker
Many times, the problem that arthas can't work with the application in docker is because the docker does not install JDK, but installs JRE. If only JRE is installed, many JAVA command line tools and class libraries will be missing, and Arthas will not work properly. Here are two common ways to use JDK in Docker.
### Use public JDK image
* https://hub.docker.com/_/openjdk/
such as:
```
FROM openjdk:8-jdk
```
or:
```
FROM openjdk:8-jdk-alpine
```
### Install via package management software
such as:
```bash
# Install OpenJDK-8
RUN apt-get update && \
apt-get install -y openjdk-8-jdk && \
apt-get install -y ant && \
apt-get clean;
# Fix certificate issues
RUN apt-get update && \
apt-get install ca-certificates-java && \
apt-get clean && \
update-ca-certificates -f;
# Setup JAVA_HOME - useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME
```
or:
```bash
RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME
```
## Quick start with Docker
1. Delete the existing `arthas-demo` docker container (not necessary)
+46
View File
@@ -181,3 +181,49 @@ $ profiler version
Async-profiler 1.6 built on Sep 9 2019
Copyright 2019 Andrei Pangin
```
### Configure framebuf option
> If you encounter `[frame_buffer_overflow]` in the generated svg image, you need to increase the framebuf (the default value is 1'000'000), which can be configured explicitly, such as:
```bash
profiler start --framebuf 5000000
```
### Configure include/exclude to filter data
If the application is complex and generates a lot of content, and you want to focus on only part of the data, you can filter by include/exclude. such as
```bash
profiler start --include'java/*' --include'demo/*' --exclude'*Unsafe.park*'
```
> Both include/exclude support setting multiple values, but need to be configured at the end of the command line.
### Specify execution time
For example, if you want the profiler to automatically end after 300 seconds, you can specify it with the `-d`/`--duration` parameter:
```bash
profiler start --duration 300
```
### Generate jfr format result
> Note that jfr only supports configuration at `start`. If it is specified at `stop`, it will not take effect.
```
profiler start --file /tmp/test.jfr
```
The `file` parameter supports some variables:
* Timestamp: `--file /tmp/test-%t.jfr`
* Process ID: `--file /tmp/test-%p.jfr`
The generated results can be viewed with tools that support the jfr format. such as:
* JDK Mission Control: https://github.com/openjdk/jmc
* JProfiler: https://github.com/alibaba/arthas/issues/1416
+49
View File
@@ -108,6 +108,11 @@
<li class="toctree-l1"><a class="reference internal" href="web-console.html">WebConsole</a></li>
<li class="toctree-l1"><a class="reference internal" href="http-api.html">Http API</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Docker</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#use-jdk-in-docker">Use JDK in Docker</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#use-public-jdk-image">Use public JDK image</a></li>
<li class="toctree-l3"><a class="reference internal" href="#install-via-package-management-software">Install via package management software</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#quick-start-with-docker">Quick start with Docker</a></li>
<li class="toctree-l2"><a class="reference internal" href="#diagnose-the-java-process-in-docker">Diagnose the Java process in Docker</a></li>
<li class="toctree-l2"><a class="reference internal" href="#diagnose-the-java-process-in-the-container-in-k8s">Diagnose the Java process in the container in k8s</a></li>
@@ -190,6 +195,50 @@
<div class="section" id="docker">
<h1>Docker<a class="headerlink" href="#docker" title="Permalink to this headline"></a></h1>
<div class="section" id="use-jdk-in-docker">
<h2>Use JDK in Docker<a class="headerlink" href="#use-jdk-in-docker" title="Permalink to this headline"></a></h2>
<p>Many times, the problem that arthas can’t work with the application in docker is because the docker does not install JDK, but installs JRE. If only JRE is installed, many JAVA command line tools and class libraries will be missing, and Arthas will not work properly. Here are two common ways to use JDK in Docker.</p>
<div class="section" id="use-public-jdk-image">
<h3>Use public JDK image<a class="headerlink" href="#use-public-jdk-image" title="Permalink to this headline"></a></h3>
<ul class="simple">
<li><p>https://hub.docker.com/_/openjdk/</p></li>
</ul>
<p>such as:</p>
<div class="highlight-default notranslate"><pre class="literal-block">FROM openjdk:8-jdk</pre>
</div>
<p>or:</p>
<div class="highlight-default notranslate"><pre class="literal-block">FROM openjdk:8-jdk-alpine</pre>
</div>
</div>
<div class="section" id="install-via-package-management-software">
<h3>Install via package management software<a class="headerlink" href="#install-via-package-management-software" title="Permalink to this headline"></a></h3>
<p>such as:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash"># Install OpenJDK-8
RUN apt-get update &amp;&amp; \
apt-get install -y openjdk-8-jdk &amp;&amp; \
apt-get install -y ant &amp;&amp; \
apt-get clean;
# Fix certificate issues
RUN apt-get update &amp;&amp; \
apt-get install ca-certificates-java &amp;&amp; \
apt-get clean &amp;&amp; \
update-ca-certificates -f;
# Setup JAVA_HOME - useful for docker commandline
ENV JAVA_HOME /usr/lib/jvm/java-8-openjdk-amd64/
RUN export JAVA_HOME</pre></div>
</div>
<p>or:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">RUN yum install -y \
java-1.8.0-openjdk \
java-1.8.0-openjdk-devel
ENV JAVA_HOME /usr/lib/jvm/java-1.8.0-openjdk/
RUN export JAVA_HOME</pre></div>
</div>
</div>
</div>
<div class="section" id="quick-start-with-docker">
<h2>Quick start with Docker<a class="headerlink" href="#quick-start-with-docker" title="Permalink to this headline"></a></h2>
<ol>
+45
View File
@@ -145,6 +145,10 @@
<li class="toctree-l3"><a class="reference internal" href="#use-execute-action-to-execute-complex-commands">Use <code class="docutils literal notranslate"><span class="pre">execute</span></code> action to execute complex commands</a></li>
<li class="toctree-l3"><a class="reference internal" href="#view-all-supported-actions">View all supported actions</a></li>
<li class="toctree-l3"><a class="reference internal" href="#view-version">View version</a></li>
<li class="toctree-l3"><a class="reference internal" href="#configure-framebuf-option">Configure framebuf option</a></li>
<li class="toctree-l3"><a class="reference internal" href="#configure-include-exclude-to-filter-data">Configure include/exclude to filter data</a></li>
<li class="toctree-l3"><a class="reference internal" href="#specify-execution-time">Specify execution time</a></li>
<li class="toctree-l3"><a class="reference internal" href="#generate-jfr-format-result">Generate jfr format result</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="cat.html">cat</a></li>
@@ -406,6 +410,47 @@ Async-profiler 1.6 built on Sep 9 2019
Copyright 2019 Andrei Pangin</pre></div>
</div>
</div>
<div class="section" id="configure-framebuf-option">
<h2>Configure framebuf option<a class="headerlink" href="#configure-framebuf-option" title="Permalink to this headline"></a></h2>
<blockquote>
<div><p>If you encounter <code class="docutils literal notranslate"><span class="pre">[frame_buffer_overflow]</span></code> in the generated svg image, you need to increase the framebuf (the default value is 1’000’000), which can be configured explicitly, such as:</p>
</div></blockquote>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --framebuf 5000000</pre></div>
</div>
</div>
<div class="section" id="configure-include-exclude-to-filter-data">
<h2>Configure include/exclude to filter data<a class="headerlink" href="#configure-include-exclude-to-filter-data" title="Permalink to this headline"></a></h2>
<p>If the application is complex and generates a lot of content, and you want to focus on only part of the data, you can filter by include/exclude. such as</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --include&#x27;java/*&#x27; --include&#x27;demo/*&#x27; --exclude&#x27;*Unsafe.park*&#x27;</pre></div>
</div>
<blockquote>
<div><p>Both include/exclude support setting multiple values, but need to be configured at the end of the command line.</p>
</div></blockquote>
</div>
<div class="section" id="specify-execution-time">
<h2>Specify execution time<a class="headerlink" href="#specify-execution-time" title="Permalink to this headline"></a></h2>
<p>For example, if you want the profiler to automatically end after 300 seconds, you can specify it with the <code class="docutils literal notranslate"><span class="pre">-d</span></code>/<code class="docutils literal notranslate"><span class="pre">--duration</span></code> parameter:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --duration 300</pre></div>
</div>
</div>
<div class="section" id="generate-jfr-format-result">
<h2>Generate jfr format result<a class="headerlink" href="#generate-jfr-format-result" title="Permalink to this headline"></a></h2>
<blockquote>
<div><p>Note that jfr only supports configuration at <code class="docutils literal notranslate"><span class="pre">start</span></code>. If it is specified at <code class="docutils literal notranslate"><span class="pre">stop</span></code>, it will not take effect.</p>
</div></blockquote>
<div class="highlight-default notranslate"><pre class="literal-block">profiler start --file /tmp/test.jfr</pre>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">file</span></code> parameter supports some variables:</p>
<ul class="simple">
<li><p>Timestamp: <code class="docutils literal notranslate"><span class="pre">--file</span> <span class="pre">/tmp/test-%t.jfr</span></code></p></li>
<li><p>Process ID: <code class="docutils literal notranslate"><span class="pre">--file</span> <span class="pre">/tmp/test-%p.jfr</span></code></p></li>
</ul>
<p>The generated results can be viewed with tools that support the jfr format. such as:</p>
<ul class="simple">
<li><p>JDK Mission Control: https://github.com/openjdk/jmc</p></li>
<li><p>JProfiler: https://github.com/alibaba/arthas/issues/1416</p></li>
</ul>
</div>
</div>
+1 -1
View File
File diff suppressed because one or more lines are too long
+45
View File
@@ -148,6 +148,10 @@
<li class="toctree-l3"><a class="reference internal" href="#execute">使用<code class="docutils literal notranslate"><span class="pre">execute</span></code>来执行复杂的命令</a></li>
<li class="toctree-l3"><a class="reference internal" href="#action">查看所有支持的action</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id6">查看版本</a></li>
<li class="toctree-l3"><a class="reference internal" href="#framebuf">配置 framebuf 参数</a></li>
<li class="toctree-l3"><a class="reference internal" href="#include-exclude">配置 include/exclude 来过滤数据</a></li>
<li class="toctree-l3"><a class="reference internal" href="#id7">指定执行时间</a></li>
<li class="toctree-l3"><a class="reference internal" href="#jfr">生成 jfr格式结果</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="cat.html">cat</a></li>
@@ -409,6 +413,47 @@ Async-profiler 1.6 built on Sep 9 2019
Copyright 2019 Andrei Pangin</pre></div>
</div>
</div>
<div class="section" id="framebuf">
<h2>配置 framebuf 参数<a class="headerlink" href="#framebuf" title="永久链接至标题"></a></h2>
<blockquote>
<div><p>如果遇到生成的svg图片有 <code class="docutils literal notranslate"><span class="pre">[frame_buffer_overflow]</span></code>,则需要增大 framebuf(默认值是 1’000’000),可以显式配置,比如:</p>
</div></blockquote>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --framebuf 5000000</pre></div>
</div>
</div>
<div class="section" id="include-exclude">
<h2>配置 include/exclude 来过滤数据<a class="headerlink" href="#include-exclude" title="永久链接至标题"></a></h2>
<p>如果应用比较复杂,生成的内容很多,想只关注部分数据,可以通过 include/exclude 来过滤。比如</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --include &#x27;java/*&#x27; --include &#x27;demo/*&#x27; --exclude &#x27;*Unsafe.park*&#x27;</pre></div>
</div>
<blockquote>
<div><p>include/exclude 都支持设置多个值 ,但是需要配置在命令行的最后。</p>
</div></blockquote>
</div>
<div class="section" id="id7">
<h2>指定执行时间<a class="headerlink" href="#id7" title="永久链接至标题"></a></h2>
<p>比如,希望profiler执行 300 秒自动结束,可以用 <code class="docutils literal notranslate"><span class="pre">-d</span></code>/<code class="docutils literal notranslate"><span class="pre">--duration</span></code> 参数指定:</p>
<div class="highlight-bash notranslate"><div class="highlight hljs"><pre class="bash">profiler start --duration 300</pre></div>
</div>
</div>
<div class="section" id="jfr">
<h2>生成 jfr格式结果<a class="headerlink" href="#jfr" title="永久链接至标题"></a></h2>
<blockquote>
<div><p>注意,jfr只支持在 <code class="docutils literal notranslate"><span class="pre">start</span></code>时配置。如果是在<code class="docutils literal notranslate"><span class="pre">stop</span></code>时指定,则不会生效。</p>
</div></blockquote>
<div class="highlight-default notranslate"><pre class="literal-block">profiler start --file /tmp/test.jfr</pre>
</div>
<p><code class="docutils literal notranslate"><span class="pre">file</span></code>参数支持一些变量:</p>
<ul class="simple">
<li><p>时间戳: <code class="docutils literal notranslate"><span class="pre">--file</span> <span class="pre">/tmp/test-%t.jfr</span></code></p></li>
<li><p>进程ID: <code class="docutils literal notranslate"><span class="pre">--file</span> <span class="pre">/tmp/test-%p.jfr</span></code></p></li>
</ul>
<p>生成的结果可以用支持jfr格式的工具来查看。比如:</p>
<ul class="simple">
<li><p>JDK Mission Control : https://github.com/openjdk/jmc</p></li>
<li><p>JProfiler : https://github.com/alibaba/arthas/issues/1416</p></li>
</ul>
</div>
</div>
+1 -1
View File
File diff suppressed because one or more lines are too long
+3
View File
@@ -204,6 +204,9 @@
&lt;/dependency&gt;</pre></div>
</div>
<p>应用启动后,spring会启动arthas,并且attach自身进程。</p>
<blockquote>
<div><p>一键创建包含 Arthas Spring Boot Starter 的工程:<a class="reference external" href="http://start.aliyun.com/bootstrap.html/#%21dependencies=arthas">点击</a></p>
</div></blockquote>
<div class="section" id="id1">
<h2>配置属性<a class="headerlink" href="#id1" title="永久链接至标题"></a></h2>
<p>比如,通过配置tunnel server实现远程管理:</p>