基本安装及使用

安装

使用arthas-boot

# 直接下载运行时自动下载Arthas到~/.arthas目录
curl -O https://arthas.aliyun.com/arthas-boot.jar
java -jar arthas-boot.jar

# 下载速度过慢 可以使用阿里云镜像
java -jar arthas-boot.jar --repo-mirror aliyun --use-http

# 帮助信息
java -jar arthas-boot.jar -h

Arthas自动下载安装目录为~/.arthas,日志目录为~/logs/arthas

使用as.sh

# Linux/Unix/Mac下一键安装
curl -L https://arthas.aliyun.com/install.sh | sh

# 进入交互界面
./as.sh

# 帮助信息
./as.sh -h

全量安装

Github下载arthas-bin.zipMaven下载, 解压后,直接运行文件夹中的arthas-boot.jar

建议

windows下建议添加编码参数 否则会出现中文乱码

java -Dfile.encoding=utf8 -jar arthas-boot.jar

参数选项

命令选项 描述
--disabled-commands <commands> 禁用一些命令逗号分隔
--repo-mirror <repo> maven仓库,仓库可为mavenaliyun或者http地址
--attach-only 仅attach目标进程,不做连接,attach成功后就结束
--arthas-home <path> Arthas目录
--telnet-port <number> Arthas监听端口,默认36580则为随机端口
--http-port <number> Arthas http监听端口,默认85630则为随机端口
--user-version <version> 使用特定的Arthas版本,版本号可从versions中选择
--versions 列出本地和远程可用的Arthas版本
--user-http 强制使用http方式下载,默认使用https方式下载
--target-ip telnet监听ip,默认为127.0.0.1
--tunnel-server <url> Tunnel服务url地址
--agent-id <id> 注册到Tunnel服务的代理id
--app-name <name> 应用名称
--height <number> Arthas客户端终端高度
--width <number> Arthas客户端终端宽度
--session-timeout <number> 会话超时秒数,默认1800
--stat-url <url> 统计url地址,参考实现
--select <value> 通过类名称或jar名称选择进程
--username <name> 授权用户名,默认arthas
--password <password> 授权密码
-f, --batch-file <file> 指定脚本执行,脚本建议以as结尾
-c, --command <commands> attach后直接执行命令,多个命令使用;分隔
-v, --verbose 打印debug信息
<pid> 根据进程号选择进程
-h, --help 帮助

配置文件

# 配置为-1 则不监听telnet端口
arthas.telnetPort=3658
# 配置为-1 则不监听http端口
arthas.httpPort=8563
# 默认为localhost 可为0.0.0.0
arthas.ip=127.0.0.1

# 会话超时时间(秒)
arthas.sessionTimeout=1800

#arthas.enhanceLoaders=java.lang.ClassLoader

# 授权用户名密码 默认用户名为arthas
arthas.username=arthas
# arthas.password=arthas

# local connection non auth, like telnet 127.0.0.1 3658
# 本机连接是否不需要授权
arthas.localConnectionNonAuth=true

# tunnel ws地址
arthas.tunnelServer=ws://127.0.0.1:7777/ws
# 应用名称
arthas.appName=demoapp
# agentId 若同时配置appName和agentId agentId应为${appName}_agentId
arthas.agentId=demoapp_agentId

# 禁用命令多个逗号分隔
arthas.disabledCommands=stop,dump
# 输出路径
arthas.outputPath=arthas-output