prestodb安裝ranger插件

一、背景

生產(chǎn)環(huán)境使用的prestodb為Facebook版本的prestodb,在安裝ranger插件時(shí)發(fā)現(xiàn)源碼中只支持prestosql版本,故考慮將ranger-presto-plugin的代碼改為支持prestodb版本的,同時(shí)去掉對(duì)show schemas、show catalogs、 show tables的鑒權(quán),因?yàn)樵谂c上層查詢系統(tǒng)對(duì)接時(shí)使用不到,只需要對(duì)select、insert、drop等操作的鑒權(quán)即可。

二、ranger presto插件源碼結(jié)構(gòu)

ranger中跟presto插件相關(guān)的模塊為plugin-presto、ranger-presto-plugin-shim兩個(gè),其中shim為入口,類似hive的shim,起到適配的作用,在shim中不實(shí)現(xiàn)具體的業(yè)務(wù)邏輯,均為轉(zhuǎn)調(diào)用plugin-presto模塊中的類方法,兩個(gè)模塊中均有類:org.apache.ranger.authorization.presto.authorizer.RangerSystemAccessControl,該類實(shí)現(xiàn)了各種具體的鑒權(quán)邏輯。

三、ranger插件被加載的過程

ranger-presto-plugin-shim的org.apache.ranger.authorization.presto.authorizer.PrestoRangerPlugin實(shí)現(xiàn)了presto的com.facebook.presto.spi.Plugin接口(此處已經(jīng)是換為prestodb下的類,修改前為prestosql中的類io.prestosql.spi.Plugin),同時(shí)在resouces/META-INF.services目錄下有spi相關(guān)的文件io.prestosql.spi.Plugin,文件內(nèi)容為Plugin的實(shí)現(xiàn)類org.apache.ranger.authorization.presto.authorizer.PrestoRangerPlugin;
presto進(jìn)程在啟動(dòng)時(shí)會(huì)使用java spi自動(dòng)裝載技術(shù)將Plugin接口的所有實(shí)現(xiàn)類都加載到進(jìn)程中,具體代碼在presto源碼的PluginManger#loadPlugin方法中:


image.png

四、ranger插件代碼修改內(nèi)容

1、兩個(gè)模塊的pom中中prestosql依賴,換為facebook的presto依賴,修改各類中引用的類為facebook的presto中的類,RangerSystemAcessControl實(shí)現(xiàn)的接口方法中有一些入?yún)⑿枰{(diào)整。
2、shim包: resouces/META-INF.services目錄下文件名修改為Facebook presto的包名:com.facebook.presto.spi.Plugin
3、打包兩個(gè)模塊,并替換安裝目錄下對(duì)應(yīng)的jar包
mvn clean package -Dmaven.test.skip=true -pl plugin-presto -am -amd
mvn clean package -Dmaven.test.skip=true -pl ranger-presto-plugin-shim -am -amd

4、修改后的代碼見github: zfqhd43/ranger-prestodb

五、其他

遠(yuǎn)程debug方式:
1、在/opt/software/presto/bin/launcher.py中添加:command += ['-agentlib:jdwp=transport=dt_socket,address=5007,server=y,suspend=n'],位置如下:


image.png

2、在idea中新建remote jvm debug


image.png
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容