1. 程式人生 > >Apache Ranger 1.1.0源碼導入IDEA並運行調試security-admin web模塊

Apache Ranger 1.1.0源碼導入IDEA並運行調試security-admin web模塊

-s location cti its word spa .net 頂級 preview

前言

Apache Ranger是什麽,它是一個為Hadoop平臺提供了全面的數據安全訪問控制及監控的集中式管理框架,Apache頂級項目。不廢話了,其實本篇沒那麽高大上,就是一步步教你如何將Ranger源碼導入到IDEA,並運行調試其web模塊。

導入源碼

  • 第一步當然是下載源碼,這裏選用了最新版1.1.0
git clone https://github.com/apache/ranger.git
git checkout release-ranger-1.1.0
  • 編譯,這裏選擇編譯全部,當然也可以選擇具體模塊進行編譯,耗時會比較長
mvn clean compile package install assembly:assembly
  • 添加idea相關配置及依賴
mvn idea:idea
  • 直接導入就行了,what?你不會連導入都不會吧
    技術分享圖片

運行調試security-admin web模塊

先初始化數據庫,這裏推薦選用MySQL,PostgreSQL我初始化的時候報了N多錯,直接放棄了。

更改security-admin/src/main/resources/conf.dist/ranger-admin-site.xml

配置審計日誌,沒有裝solr可以不用管

    <property>
        <name>ranger.audit.solr.urls</name>
        <value>http://localhost:6083/solr/ranger_audits</value>
        <description></description>
    </property>

    <property>
        <name>ranger.audit.source.type</name>
        <value>solr</value>
        <description></description>
    </property> 

配置Ranger數據庫及用戶名密碼

    <property>
        <name>ranger.jpa.jdbc.url</name>
        <value>jdbc:log4jdbc:mysql://localhost:3306/pranger3</value>
        <description></description>
    </property>
    <property>
        <name>ranger.jpa.jdbc.user</name>
        <value>admin</value>
        <description></description>
    </property>
    <property>
        <name>ranger.jpa.jdbc.password</name>
        <value>admin</value>
        <description></description>
    </property>

配置web.xml

這裏有二種方式:

第一種 security-admin/src/main/resources/conf.dist 設置為resources目錄
技術分享圖片

修改security-admin/src/main/webapp/WEB-INF/web.xml

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>META-INF/applicationContext.xml
            WEB-INF/classes/security-applicationContext.xml
            META-INF/scheduler-applicationContext.xml</param-value>
  </context-param>

修改security-admin/src/main/webapp/META-INF/applicationContext.xml

        <property name="locations">
            <list>
                <!-- <value>classpath:xa_default.properties</value> -->
                <!-- <value>classpath:xa_system.properties</value> -->
                <!-- <value>classpath:xa_custom.properties</value> -->
                <!-- <value>classpath:xa_ldap.properties</value> -->
                <value>classpath:core-site.xml</value>
                <value>classpath:ranger-admin-default-site.xml</value>
                <value>classpath:ranger-admin-site.xml</value>
            </list>
        </property>
第二種只改配置文件

修改security-admin/src/main/webapp/WEB-INF/web.xml

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>META-INF/applicationContext.xml
            WEB-INF/classes/conf.dist/security-applicationContext.xml
            META-INF/scheduler-applicationContext.xml</param-value>
  </context-param>

修改security-admin/src/main/webapp/META-INF/applicationContext.xml

        <property name="locations">
            <list>
                <!-- <value>classpath:xa_default.properties</value> -->
                <!-- <value>classpath:xa_system.properties</value> -->
                <!-- <value>classpath:xa_custom.properties</value> -->
                <!-- <value>classpath:xa_ldap.properties</value> -->
                <value>classpath:conf.dist/core-site.xml</value>
                <value>classpath:conf.dist/ranger-admin-default-site.xml</value>
                <value>classpath:conf.dist/ranger-admin-site.xml</value>
            </list>
        </property>

添加tomcat
技術分享圖片

然後就可以運行調試了,盡情的debug調試吧。

Apache Ranger 1.1.0源碼導入IDEA並運行調試security-admin web模塊