Arthas实操2-Web Console

作者: AC编程 | 来源:发表于2022-08-31 10:28 被阅读0次

一、Arthas Web Console简介

Web Console是arthas提供的web页面,它可以让用户在自己的电脑上,连接远程服务器的arthas执行命令,命令的执行方式和在服务器直接操作没有任何区别。Web Console连接远程服务器成功后是这样的,几乎和服务器的界面一样。

二、开放端口

因为需要访问远程服务器,所以要在远程服务器上对本地网络开放 ip 和端口策略,否则无法使用 Web Console。在远程服务器上启动 arthas,启动时要指定 ip 和端口。在阿里云ECS上开放85633658两个端口。

  • Web Console默认使用8563端口。--http-port 参数可以修改Web Console端口。

  • telnet默认使用3658端口。--telnet-port 可以修改telnet端口。

三、操作

3.1 下载并启动math-game

1、登录连接到ECS服务器(窗口1)

ssh root@47.105.*.74

#输入登录密码

2、下载并启动math-game

curl -O https://arthas.aliyun.com/math-game.jar

java -jar math-game.jar
3.2 下载并启动 arthas

1、登录连接到ECS服务器(窗口2)

ssh root@47.105.*.74

#输入登录密码

2、下载并启动arthas

curl -O https://arthas.aliyun.com/arthas-boot.jar

java -jar arthas-boot.jar

运行结果:

root@iZm5eetszs07500os8erolZ:~/data/arthas# java -jar arthas-boot.jar
[INFO] arthas-boot version: 3.6.5
[INFO] Found existing java process, please choose one and input the serial number of the process, eg : 1. Then hit ENTER.
* [1]: 24865 demo-0.0.1-SNAPSHOT.jar
  [2]: 25771 math-game.jar

可以看到math-game运行的进程ID是25771,这个进程ID后面会用到。

3.3 启动时指定 ip 和端口

在窗口2中执行:关闭arthas,重新启动。在远程服务器上启动arthas,启动时要指定IP和端口。

java -jar arthas-boot.jar --target-ip 0.0.0.0 --http-port 8563 25771

参数说明:

java -jar arthas.jar:启动命令
--target-ip:指定Web Console连接的IP,也就是服务器的外网IP
--http-port:指定Web Console连接的端口,也就是服务器对外暴露的端口
25771:要监听的java程序的进程ID,即math-game.jar进程ID

运行结果:

root@iZm5eetszs07500os8erolZ:~/data/arthas# java -jar arthas-boot.jar --target-ip 0.0.0.0 --http-port 8563 25771
[INFO] arthas-boot version: 3.6.5
[INFO] arthas home: /root/.arthas/lib/3.6.5/arthas
[INFO] Try to attach process 25771
[INFO] Attach process 25771 success.
[INFO] arthas-client connect 0.0.0.0 3658
  ,---.  ,------. ,--------.,--.  ,--.  ,---.   ,---.
 /  O  \ |  .--. ''--.  .--'|  '--'  | /  O  \ '   .-'
|  .-.  ||  '--'.'   |  |   |  .--.  ||  .-.  |`.  `-.
|  | |  ||  |\  \    |  |   |  |  |  ||  | |  |.-'    |
`--' `--'`--' '--'   `--'   `--'  `--'`--' `--'`-----'

wiki       https://arthas.aliyun.com/doc
tutorials  https://arthas.aliyun.com/doc/arthas-tutorials.html
version    3.6.5
main_class
pid        25771
time       2022-08-31 16:01:23

[arthas@25771]$
3.4 在浏览器中访问Web Console

在浏览器中输入地址:http://47.105.xxx.74:8563

效果如下:


Web Console
3.5 scrollback URL 参数

scrollback URL 参数3.5.5 版本后支持,默认 Web Console 支持向上回滚的行数是1000。可以在 URL 里用scrollback指定。比如:http://127.0.0.1:8563/?scrollback=3000

四、注意

Web Console需要服务器暴露IP和端口,如果服务器是云端部署,需要考虑网络安全的问题,比如端口只开放给某一个来源IP。

五、实操遇到的问题

5.1 Connect to telnet server error

一开始我将--target-ip设置成了我ECS外网的IP,47.105.xxx.74,启动arthas失败,提示Connect to telnet server error异常。将IP改成--target-ip 0.0.0.0就可以了。

错误场景:

root@iZm5eetszs07500os8erolZ:~/data/arthas# java -jar arthas-boot.jar --target-ip 47.105.xxx.74 --http-port 8563 25771
[INFO] arthas-boot version: 3.6.5
[INFO] arthas home: /root/.arthas/lib/3.6.5/arthas
[INFO] Try to attach process 25771
[INFO] Attach process 25771 success.
[INFO] arthas-client connect 47.105.146.74 3658
Connect to telnet server error: 47.105.xxx.74 3658
java.net.ConnectException: Connection refused (Connection refused)
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
        at java.net.Socket.connect(Socket.java:607)
        at org.apache.commons.net.SocketClient.connect(SocketClient.java:188)
        at org.apache.commons.net.SocketClient.connect(SocketClient.java:209)
        at com.taobao.arthas.client.TelnetConsole.process(TelnetConsole.java:306)
        at com.taobao.arthas.client.TelnetConsole.main(TelnetConsole.java:166)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at com.taobao.arthas.boot.Bootstrap.main(Bootstrap.java:615)
Usage: arthas-client [--help] [-c <value>] [-f <value>] [-w <value>] [-t
       <value>] [-h <value>] [target-ip] [port]

Arthas Telnet Client

EXAMPLES:
  java -jar arthas-client.jar 127.0.0.1 3658
  java -jar arthas-client.jar -c 'dashboard -n 1'
  java -jar arthas-client.jar -f batch.as 127.0.0.1

Options and Arguments:
    --help                        Print usage
 -c,--command <value>             Command to execute, multiple commands
                                  separated by ;
 -f,--batch-file <value>          The batch file to execute
 -w,--width <value>               The terminal width
 -t,--execution-timeout <value>   The timeout (ms) of execute commands or batch
                                  file
 -h,--height <value>              The terminal height
 <target-ip>                      Target ip
 <port>                           The remote server port

root@iZm5eetszs07500os8erolZ:~/data/arthas#

参考资料:
Arthas-Web Console官方文档

在 Web Console 复制粘贴快捷键参考

arthas的webconsole操作详细搭建步骤说明

相关文章

  • Arthas实操2-Web Console

    一、Arthas Web Console简介 Web Console是arthas提供的web页面,它可以让用户在...

  • Arthas实操1-快速入门

    一、简介 Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息,并...

  • 实操Redission

    实操Redission 分布式对象(一)实操Redission 分布式Map集合(二)实操Redission 分布...

  • 生信星球学习记录Day2-HEYi😛

    Linux 基本命令 实操一 实操二 实操三3 实操四 练习题 如何输出长格式列表,以及显示文件大小ls -l ...

  • Arthas入门篇

    系列 Arthas入门篇Arthas功能介绍Arthas 启动过程分析 Arthas介绍 Arthas(阿尔萨斯)...

  • Arthas 启动过程分析

    系列 Arthas入门篇Arthas功能介绍Arthas 启动过程分析 arthas组成模块 arthas-boo...

  • 上海会计培训 实战教学适应更多企业会计工作

    会计培训学校包含初级实操会计师考前冲刺 、中级实操会计师考前冲刺和高级实操会计师考前冲刺。学员拥有实操会计师证,找...

  • 实操

  • 实操

    1。。。是时候面对和成长自己了,就是从现在开始,我决定改变,让你的决定在今后的至少半年里,陪伴你度过每一个重要的时...

  • 22组7054 六歌第9课#裂变增长实验室#

    今天实操了建了抖音个人实操付费社群, 今天抖音个人实操付费社群拉群了 准备24号开始正式教大家实操,感兴趣的小伙伴...

网友评论

    本文标题:Arthas实操2-Web Console

    本文链接:https://www.haomeiwen.com/subject/wjudnrtx.html