当前位置:网站首页>Jvm-Sandbox-Repeater的部署
Jvm-Sandbox-Repeater的部署
2022-07-04 21:57:00 【Wu_Candy】
1.什么是jvm-sandbox-repeater?
jvm-sandbox-repeater 是 JVM-Sandbox 生态体系下的重要模块,它具备了JVM-Sandbox 的所有特点,插件式设计便于快速适配各种中间件,封装请求录制/回放基础协议,也提供了通用可扩展的各种丰富API。jvm-sandbox 是指 JVM 沙箱容器,一种 JVM 的非侵入式运行期 AOP 解决方案。
2.它的核心能力是什么?
2.1 通用录制/回放能力
(1).无侵入式录制 HTTP/Java/Dubbo 入参/返回值录制能力(业务系统无感知)
(2).基于 TTL 提供多线程子调用追踪,完整追踪一次请求的调用路径
(3).入口请求(HTTP/Dubbo/Java)流量回放、子调用(Java/Dubbo)返回值 Mock 能力
2.2 快速可扩展API实现
(1).录制/回放插件式架构
(2).提供标准接口,可通过配置/简单编码实现一类通用插件
2.3. standalone工作模式
无需依赖任何服务端/存储,可以单机工作,提供录制/回放能力
3.如何部署?
3.1 Console部署
setp1: 下载源码
git clone https://github.com/alibaba/jvm-sandbox-repeater
step2: 配置数据库信息 application.properties 及初始化数据库相关的初始化 sql 文件地址为:
./jvm-sandbox-repeater/repeater-console/repeater-console-dal/src/main/resources/database.sql
step3: 在服务器上配置mvn命令
如果是配置好了yum 源,可以使用以下命令直接安装maven
yum install maven
step4: 编译并启动console命令
cd ./jvm-sandbox-repeater
mvn install -DskipTests && nohup java -jar repeater-console/repeater-console-start/target/repeater-console.jar > console.log 2>&1 &
3.2 Repeater部署
setp1: 在上面的源码下载目录下
cd ./jvm-sandbox-repeater/bin && sh install-local.sh
install-local.sh脚本内容如下:
[email protected] bin # more sh install-local.sh
#!/usr/bin/env bash
# repeater's target dir
REPEATER_TARGET_DIR=../target/repeater
# exit shell with err_code
# $1 : err_code
# $2 : err_msg
exit_on_err()
{
[[ ! -z "${2}" ]] && echo "${2}" 1>&2
exit ${1}
}
# package
sh ./package.sh || exit_on_err 1 "install failed cause package failed" #此处调用到了package.sh 脚本,下面会单独分析
# extract sandbox to ${HOME}
curl -s http://sandbox-ecological.oss-cn-hangzhou.aliyuncs.com/sandbox-1.2.1-bin.tar | tar xz -C ${HOME} || exit_on_err 1 "extract sandbox failed" #下载并解压sandbox文件包
# copy module to ~/.sandbox-module
mkdir -p ${HOME}/.sandbox-module || exit_on_err 1 "permission denied, can not mkdir ~/.sandbox-module" #创建目录
cp -r ${REPEATER_TARGET_DIR}/* ${HOME}/.sandbox-module || exit_on_err 1 "permission denied, can not copy module to ~/.sandbox-module" #复制../target/repeater目录下的所有文件到上一个命令创建的目录下
package.sh脚本内容如下:
[email protected] bin # more package.sh
#!/usr/bin/env bash
# repeater's target dir
REPEATER_TARGET_DIR=../target/repeater #定义变量
# exit shell with err_code
# $1 : err_code
# $2 : err_msg
exit_on_err()
{
[[ ! -z "${2}" ]] && echo "${2}" 1>&2
exit ${1}
}
# maven package the sandbox
mvn clean package -Dmaven.test.skip=true -f ../pom.xml || exit_on_err 1 "package repeater failed." #编译打包
mkdir -p ${REPEATER_TARGET_DIR}/plugins #创建目录
mkdir -p ${REPEATER_TARGET_DIR}/cfg #创建目录
cp ./repeater-logback.xml ${REPEATER_TARGET_DIR}/cfg/repeater-logback.xml \ #拷贝文件到repeater目录
&& cp ./repeater.properties ${REPEATER_TARGET_DIR}/cfg/repeater.properties \
&& cp ./repeater-config.json ${REPEATER_TARGET_DIR}/cfg/repeater-config.json \
&& cp ../repeater-module/target/repeater-module-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/repeater-module.jar \
&& cp ../repeater-console/repeater-console-start/target/repeater-console.jar ${REPEATER_TARGET_DIR}/repeater-bootstrap.jar \
&& cp ../repeater-plugins/ibatis-plugin/target/ibatis-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/ibatis-plugin.jar \
&& cp ../repeater-plugins/java-plugin/target/java-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/java-plugin.jar \
&& cp ../repeater-plugins/mybatis-plugin/target/mybatis-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/mybatis-plugin.jar \
&& cp ../repeater-plugins/dubbo-plugin/target/dubbo-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/dubbo-plugin.jar \
&& cp ../repeater-plugins/redis-plugin/target/redis-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/redis-plugin.jar \
&& cp ../repeater-plugins/http-plugin/target/http-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/http-plugin.jar \
&& cp ../repeater-plugins/hibernate-plugin/target/hibernate-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/hibernate-plugin.jar \
&& cp ../repeater-plugins/spring-data-jpa-plugin/target/spring-data-jpa-plugin-*-jar-with-dependencies.jar ${REPEATER_TARGET_DIR}/plugins/spring-data-jpa-plugin.jar
repeater 日志配置文件如下:
repeater的日志路径为:~/logs/sandbox/repeater/repeater.log --》这是由于logback.xml 配置决定的 repeater-logback.xml文件内容如下:
[email protected] bin #more repeater-logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="10000">
<appender name="REPEATER-FILE-APPENDER" class="ch.qos.logback.core.rolling.Ro
llingFileAppender">
<file>${user.home}/logs/sandbox/repeater/repeater.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"> <FileNamePattern>${user.home}/logs/sandbox/repeater/repeater.log.%d{y
yyy-MM-dd}</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %-5level %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="info">
<appender-ref ref="REPEATER-FILE-APPENDER"/>
</root>
</configuration>
3.3 Sandbox 部署
https://github.com/alibaba/jvm-sandbox
- JVM-SANDBOX(沙箱)实现了一种在不重启、不侵入目标JVM应用的AOP解决方案
- 操作步骤:下载最新版本的JVM-SANDBOX
wget http://ompc.oss-cn-hangzhou.aliyuncs.com/jvm-sandbox/release/sandbox-stable-bin.zip
# 解压
unzip sandbox-stable-bin.zip
# 进入沙箱执行脚本
cd sandbox/bin
#在~/sandbox/bin/sandbox.sh 启动的cfg目录下有一个sandbox.properties文件,目录为/root/sandbox/cfg
sandbox.properties 文件里面指定了user_module=~/.sandbox-module
# 挂载目标JVM进程,这里以console应用为示例来挂载,一条命令搞定:
sh ~/sandbox/bin/sandbox.sh -p `ps -ef | grep "console" | grep -v grep | awk '{print $2}'` -P 12250 【这个命令会将console JVM进程进行挂载】
~/.sandbox-module目录下可以看到:
[email protected] .sandbox-module # tree
.
├── cfg
│ ├── repeater-config.json
│ ├── repeater-logback.xml #这个repeater 启动后的日志配置文件
│ └── repeater.properties #把repeater.properties里面的ip and port 修改为为console 所在机器启动的ip and port
├── plugins
│ ├── dubbo-plugin.jar
│ ├── hibernate-plugin.jar
│ ├── http-plugin.jar
│ ├── ibatis-plugin.jar
│ ├── java-plugin.jar
│ ├── mybatis-plugin.jar
│ ├── redis-plugin.jar
│ └── spring-data-jpa-plugin.jar
├── repeater-bootstrap.jar
└── repeater-module.jar #repeater 模块的启动jar
Sandbox 日志配置:
#more sandbox-logback.xml
<?xml version="1.0" encoding="UTF-8" ?>
<configuration scan="true" scanPeriod="10000">
<appender name="SANDBOX-FILE-APPENDER" class="ch.qos.logback.core.rolling.Rol
lingFileAppender">
<file>${user.home}/logs/sandbox/sandbox.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy"
>
<FileNamePattern>${user.home}/logs/sandbox/sandbox.log.%d{yyyy-MM-dd}
</FileNamePattern>
<MaxHistory>30</MaxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss} %SANDBOX_NAMESPACE %-5level %msg%n</
pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<root level="info">
<appender-ref ref="SANDBOX-FILE-APPENDER"/>
</root>
</configuration>
4.Console部署后的启动页面如下图所示
end
边栏推荐
- 常用的开源无代码测试工具
- WebGIS framework -- kalrry
- 可视化任务编排&拖拉拽 | Scaleph 基于 Apache SeaTunnel的数据集成
- KDD2022 | 什么特征进行交互才是有效的?
- Open3d surface normal vector calculation
- Representation of confidence interval
- # 2156. Find the substring of the given hash value - post order traversal
- Huawei Nova 10 series released Huawei application market to build a solid application security firewall
- B站大量虚拟主播被集体强制退款:收入蒸发,还倒欠B站;乔布斯被追授美国总统自由勋章;Grafana 9 发布|极客头条
- Telephone encryption, middle 4 is replaced by * * * *
猜你喜欢
将QA引入软件开发生命周期是工程师要遵循的最佳实践
VS2019 C# release下断点调试
复数在数论、几何中的用途 - 曹则贤
Energy momentum: how to achieve carbon neutralization in the power industry?
[advanced C language] array & pointer & array written test questions
Use blocconsumer to build responsive components and monitor status at the same time
BigFilter全局交易防重组件的介绍与应用
Xiangjiang Kunpeng joined the shengteng Wanli partnership program and continued to write a new chapter of cooperation with Huawei
广电五舟与华为签署合作协议,共同推进昇腾AI产业持续发展
i.MX6ULL驱动开发 | 24 - 基于platform平台驱动模型点亮LED
随机推荐
GTEST from ignorance to proficiency (3) what are test suite and test case
QT - double buffer plot
TCP protocol three times handshake process
Representation of confidence interval
抖音实战~评论数量同步更新
ApacheCN 翻译、校对、笔记整理活动进度公告 2022.7
GTEST from ignorance to proficient use (2) what is test fixture
能源势动:电力行业的碳中和该如何实现?
Implementation rules for archiving assessment materials of robot related courses 2022 version
MongoDB中的索引操作总结
The drawing method of side-by-side diagram, multi row and multi column
HDU - 2859 Phalanx(DP)
Force buckle 2_ 1480. Dynamic sum of one-dimensional array
Locust性能测试 —— 环境搭建及使用
El tree combined with El table, tree adding and modifying operations
服装企业为什么要谈信息化?
TCP协议三次握手过程
Energy momentum: how to achieve carbon neutralization in the power industry?
Sorting and sharing of selected papers, systems and applications related to the most comprehensive mixed expert (MOE) model in history
AscendEX 上线 Walken (WLKN) - 一款卓越领先的“Walk-to-Earn”游戏