作者:鮑鳳其
愛可生 dble 團隊開發成員,主要負責 dble 需求開發,故障排查和社區問題解答。少說廢話,放碼過來。
-
https://github.com/alibaba/arthas -
https://github.com/alibaba/arthas/blob/master/README_CN.md -
https://www.cnkirito.moe/arthas-redefine/ -
https://manuals.jrebel.com/jrebel/standalone/maven.html -
https://manuals.jrebel.com/jrebel/advanced/launch-quick-start.html#quick-start
-
arthas -
jrebel
前置環境
-
jre,使用 dble 的 jre 即可 -
搭建好的 3.20.10.0 版本 dble 環境
arthas 使用
安裝
$ cd /opt/arthas
$ wget https://github.com/alibaba/arthas/releases/download/arthas-all-3.4.5/arthas-bin.zip
$ unzip arthas-bin.zip
使用
java -jar arthas-boot.jar <dble_pid>
jad 反編譯
source-only com.actiontech.dble.server.ServerQueryHandler > /tmp/ServerQueryHandler.java jad --
case 254: {
LOGGER.info("Unsupported statement:" + sql);
this.service.writeErrMessage(1149, "Unsupported statement");
return;
}
sc 查找類加載器
sc -d com.actiontech.dble.server.ServerQueryHandler | grep classLoaderHash
classLoaderHash 18b4aac2
mc 內存編譯
在編譯之前可以將之前反編譯源碼文件裏的代碼修改掉,比如修改爲如下片段:
case 254: {
LOGGER.info("Unsupported statement test test test test test:" + sql);
this.service.writeErrMessage(1149, "Unsupported statement");
return;
}
redefine 熱更新代碼
其實在這裏我們也可以通過在本地修改對應版本的源文件,本地編譯好後上傳到 /tmp/com/actiontech/dble/server/ 路徑下,再執行 redefine,效果是一樣的:
$ redefine /tmp/com/actiontech/dble/server/ServerQueryHandler.class
redefine success, size: 1, classes:
com.actiontech.dble.server.ServerQueryHandler
$ java -jar arthas-boot.jar <dble_pid> -c "redefine /tmp/com/actiontech/dble/server/ServerQueryHandler.class" > /dev/null
通過此方式,可以更方便的通過腳本管理整個流程。
分佈式 | Prepare Statement 協議遊標可行性
社區近期動態
本文分享自微信公衆號 - 愛可生開源社區(ActiontechOSS)。
如有侵權,請聯繫 [email protected] 刪除。
本文參與“OSC源創計劃”,歡迎正在閱讀的你也加入,一起分享。