# 动态安装卸载脚本使用手册
Sermant动态安装、卸载脚本 (opens new window)是基于Java Attach API实现的C语言脚本,可以将sermant挂载至虚拟机上的jvm进程或容器上的jvm进程。
注:该脚本仅限linux系统下使用
# 参数配置
-path=
:必填参数,后接sermant-agent.jar的绝对路径-pid=
:必填参数,后接宿主应用的pid,可使用ps -ef
等命令查看-command=
:必填参数,后接挂载sermant的指令,支持的指令见Sermant Agent使用手册。-nspid=
:当宿主应用容器运行时为必填参数,后接宿主应用的nspid,可使用cat /proc/{pid}/status
命令查看。当宿主应用非容器运行时,此参数请勿填写
# 脚本使用步骤
# 1. 编译jvm_attach.c
gcc attach.c -o attach
注:请确保已经安装gcc
# 2. 执行attach脚本
./attach -path={sermant-path}/sermant-agent.jar -pid={pid} -command={COMMAND}
脚本执行情况如下所示:
[root@b6b9af8e5610 root]# ./attach -path=/home/sermant-agent-1.0.0/agent/sermant-agent.jar -pid=494 -command=INSTALL-PLUGINS:database-write-prohibition
[INFO]: PATH: /home/sermant-agent-1.0.0/agent/sermant-agent.jar
[INFO]: PID: 494
[INFO]: COMMAND: INSTALL-PLUGINS:database-write-prohibition
[INFO]: Connected to remote JVM of pid 494
[INFO]: ret code is 0, Attach success!
← 动态配置中心使用手册 插件介绍 →