Ranger 完整编译教程

一、Ranger适配列表

为了方便开发者在未来能够快速集成更多版本的 Ranger,此处将对 Ranger 编译过程进行详细说明,希望能够为大家带来一些参考。

本次准备编译的 Ranger 版本为 2.4.0,准备兼容的服务列表如下。

服务名称版本号
Ranger2.4.0
Hadoop3.2.4
Atlas2.2.0
ElasticSearch7.10.2
HBase2.5.9
Hive3.1.3
Kafka2.6.0
Kms2.3.0
Knox1.4.0
Kylin3.1.3
Ozone1.0.0
Presto333
Solr8.11.3
Sqoop1.99.7
Storm1.2.4
Trino377
Zookeeper3.8.2

注:后续操作过程中,会涉及到源码与 maven 源修改,如果使用了不同的服务版本,可能会涉及到不同的修改内容,本例中将按照上述适配列表的内容进行修改。

二、准备环境

当前系统中已安装的工具如下。

工具版本
CentOS7.6
JDK1.8
Python3.9.0
Maven3.8.6

其中 JDK、Maven 的安装与环境变量配置过程比较常见,此处直接省略,下面详细介绍一下 Python-3.9.0 的安装过程。

2.1 安装 Python3

2.1.1 安装系统依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make

yum -y install wget
2.1.2 下载 Python 包
mkdir -p /data/install/resources

cd /data/install/resources

wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tgz
2.1.3 解压 Python 包
tar -zxf Python-3.9.0.tgz -C /opt
2.1.4 创建安装目录
mkdir -p /usr/local/python3
2.1.5 配置 Python 包
cd /opt/Python-3.9.0

./configure --prefix=/usr/local/python3
2.1.6 编译 Python 包
make && make install
2.1.7 软连接可执行工具
ln -s /usr/local/python3/bin/python3.9 /usr/bin/python3

ln -s /usr/local/python3/bin/pip3.9 /usr/bin/pip3
2.1.8 配置用户环境变量
vi ~/.bash_profile

# 添加内容如下
export PYTHON_HOME=/usr/local/python3

export PATH=$PYTHON_HOME/bin:$PATH

source ~/.bash_profile
2.1.9 验证

输入查看版本的命令:

python3 --version

三、下载源码

前往 Github 下载 ranger-2.4.0-release 源码

git clone --branch release-ranger-2.4.0 --single-branch https://github.com/apache/ranger.git

四、修改源码

4.1 Maven settings.xml 镜像仓库配置

<mirrors>
        <mirror>
            <id>aliyunmaven-central</id>
            <mirrorOf>central</mirrorOf>
            <name>Aliyun Central</name>
            <url>https://maven.aliyun.com/repository/central</url>
        </mirror>
    
        <mirror>
            <id>alimaven-central</id>
            <mirrorOf>central</mirrorOf>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
        </mirror>

        <!-- 华为云镜像 -->
        <mirror>
            <id>huaweicloud</id>
            <name>Huawei Cloud Mirror</name>
            <url>https://repo.huaweicloud.com/repository/maven/</url>
            <mirrorOf>*,!cloudera</mirrorOf>
        </mirror>

        <!-- 阿里云镜像 -->
        <mirror>
            <id>aliyun</id>
            <name>Aliyun Maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>*,!cloudera</mirrorOf>
        </mirror>

        <!-- Cloudera 镜像 -->
        <mirror>
            <id>cloudera</id>
            <name>cloudera Mirror</name>
            <mirrorOf>cloudera</mirrorOf>
            <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
        </mirror>

        <!-- 其他镜像 -->
        <mirror>
            <id>apache-snapshots</id>
            <mirrorOf>snapshots</mirrorOf>
            <name>Apache Snapshots Mirror</name>
            <url>https://repository.apache.org/snapshots/</url>
        </mirror>
    
        <mirror>
            <id>central</id>
            <name>Maven Repository Switchboard</name>
            <url>http://repo1.maven.org/maven2/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://repo2.maven.org/maven2/</url>
        </mirror>
    
        <mirror>
            <id>ibiblio</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
        </mirror>
    
        <mirror>
            <id>jboss-public-repository-group</id>
            <mirrorOf>central</mirrorOf>
            <name>JBoss Public Repository Group</name>
            <url>http://repository.jboss.org/nexus/content/groups/public/</url>
        </mirror>
    
        <mirror>
            <id>google-maven-central</id>
            <name>Google Maven Central</name>
            <url>https://maven-central.storage.googleapis.com/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    
        <mirror>
            <id>maven.net.cn</id>
            <name>one of the central mirrors in china</name>
            <url>http://maven.net.cn/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>


    </mirrors>

4.2 Ranger 根目录 pom.xml 配置

此处仅罗列被修改的条目,其中服务版本号的修改不再展示,请参考 ”一“ 中的适配列表中的版本。

4.2.1 增加 dependencies

在 dependencyManagement 标签下新增如下依赖。

<!-- DLC-FIX -->
<dependency>
    <groupId>org.apache.ranger</groupId>
    <artifactId>ranger-plugins-common</artifactId>
    <version>2.4.0</version>
    <scope>compile</scope>
</dependency>
<!-- DLC-FIX -->
4.2.2 跳过代码覆盖率检查

修改 jacoco-maven-plugin 插件配置为如下内容。

<plugin>
    <groupId>org.jacoco</groupId>
    <artifactId>jacoco-maven-plugin</artifactId>
    <version>${jacoco.version}</version>
    <executions>
        <execution>
            <id>jacoco-initialize</id>
            <goals>
                <goal>prepare-agent</goal>
            </goals>
        </execution>
        <execution>
            <id>jacoco-site</id>
            <phase>package</phase>
            <goals>
                <goal>report</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <skip>true</skip>
    </configuration>
</plugin>
4.2.3 跳过代码质量检查

修改 maven-pmd-plugin 插件配置为如下内容。

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-pmd-plugin</artifactId>
    <version>${maven.pmd.plugin.version}</version>
    <executions>
        <execution>
            <phase>verify</phase>
            <goals>
                <goal>check</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <skip>true</skip>
        <rulesets>
            <ruleset>${project.parent.basedir}/dev-support/ranger-pmd-ruleset.xml</ruleset>
        </rulesets>
        <sourceEncoding>UTF-8</sourceEncoding>
        <failOnViolation>true</failOnViolation>
        <linkXRef>false</linkXRef>
        <includeTests>true</includeTests>
        <verbose>true</verbose>
        <excludeRoots>
            <excludeRoot>${basedir}/src/main/generated</excludeRoot>
        </excludeRoots>
    </configuration>
</plugin>
4.2.4 修改 assembly 插件版本

将 assembly 插件版本修改为 3.3.0

<!-- DLC-FIX -->
<assembly.plugin.version>3.3.0</assembly.plugin.version>
<!-- DLC-FIX -->
4.2.5 修改 assembly 插件配置
<!-- DLC-FIX -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>${assembly.plugin.version}</version>
    <configuration>
        <skipAssembly>false</skipAssembly>
    </configuration>
</plugin>
<!-- DLC-FIX -->
4.2.6 修改 repositories 源

<repository>标签下新增源:

<!-- 华为云镜像 -->
<repository>
    <id>huaweicloud</id>
    <name>Huawei Cloud Mirror</name>
    <url>https://repo.huaweicloud.com/repository/maven/</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

<!-- 阿里云镜像 -->
<repository>
    <id>aliyun</id>
    <name>Aliyun Maven</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
    <releases>
        <enabled>true</enabled>
    </releases>
    <snapshots>
        <enabled>true</enabled>
    </snapshots>
</repository>

<!-- Cloudera -->
<repository>
    <id>cloudera</id>
    <url>https://repository.cloudera.com/artifactory/cloudera-repos/</url>
</repository>
4.2.7 增加 Maven 插件

pom.xml 中增加如下插件。

<!-- DLC-FIX -->
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-dependency-plugin</artifactId>
    <version>3.1.1</version>
    <executions>
        <execution>
            <id>copy-dependencies</id>
            <phase>package</phase>
            <goals>
                <goal>copy-dependencies</goal>
            </goals>
            <configuration>
                <outputDirectory>${project.build.directory}/lib</outputDirectory>
                <overWriteReleases>false</overWriteReleases>
                <overWriteSnapshots>false</overWriteSnapshots>
                <overWriteIfNewer>true</overWriteIfNewer>
            </configuration>
        </execution>
    </executions>
</plugin>
<!-- DLC-FIX -->

4.3 修改 Kafka 插件源码

4.3.1 KafkaRangerAuthorizerGSSTest.java
  • 模块

    plugin-kafka
    
  • 包路径

    org.apache.ranger.authorization.kafka.authorizer.KafkaRangerAuthorizerGSSTest
    
  • 待修改部分

    kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerAuthorizerGSSTest"), false);
    
  • 修改后部分

    // DLC-FIX
    // kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerAuthorizerGSSTest"), false);
    kafkaServer = new KafkaServer(
            config,
            Time.SYSTEM,
            new Some<>("KafkaRangerAuthorizerGSSTest"),
            new ArrayBuffer<>() // Assuming no custom KafkaMetricsReporters are needed
    );
    // DLC-FIX
    
4.3.2 KafkaRangerAuthorizerSASLSSLTest.java
  • 模块

    plugin-kafka
    
  • 包路径

    org.apache.ranger.authorization.kafka.authorizer.KafkaRangerAuthorizerSASLSSLTest
    
  • 待修改部分

    kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerAuthorizerSASLSSLTest"), false);
    
  • 修改后部分

    // DLC-FIX
    kafkaServer = new KafkaServer(
            config,
            Time.SYSTEM,
            new Some<>("KafkaRangerAuthorizerSASLSSLTest"),
            new ArrayBuffer<>() // Assuming no custom KafkaMetricsReporters are needed
    );
    // DLC-FIX
    
4.3.3 KafkaRangerAuthorizerTest.java
  • 模块

    plugin-kafka
    
  • 包路径

    org.apache.ranger.authorization.kafka.authorizer.KafkaRangerAuthorizerTest
    
  • 待修改部分

    kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerAuthorizerTest"), false);
    
  • 修改后部分

    // DLC-FIX
    // kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerAuthorizerTest"), false);
    kafkaServer = new KafkaServer(
            config,
            Time.SYSTEM,
            new Some<>("KafkaRangerAuthorizerTest"),
            new ArrayBuffer<>() // Assuming no custom KafkaMetricsReporters are needed
    );
    // DLC-FIX
    
4.3.4 KafkaRangerTopicCreationTest.java
  • 模块

    plugin-kafka
    
  • 包路径

    org.apache.ranger.authorization.kafka.authorizer.KafkaRangerTopicCreationTest
    
  • 待修改部分

    kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerTopicCreationTest"), false);
    
  • 修改后部分

    // DLC-FIX
    // kafkaServer = new KafkaServer(config, Time.SYSTEM, new Some<String>("KafkaRangerTopicCreationTest"), false);
    kafkaServer = new KafkaServer(
            config,
            Time.SYSTEM,
            new Some<>("KafkaRangerAuthorizerTest"),
            new ArrayBuffer<>() // Assuming no custom KafkaMetricsReporters are needed
    );
    // DLC-FIX
    

4.4 修改 HBase 插件源码

4.4.1 RangerAuthorizationCoprocessor.java [1]
  • 模块

    hbase-agent
    
  • 包路径

    org.apache.ranger.authorization.hbase.RangerAuthorizationCoprocessor
    
  • 待修改部分

    @Override
    public void preBalance(...) throws IOException {...}
    
  • 修改后部分

    // DLC-FIX
    // @Override
    // public void preBalance(...) throws IOException {...}
    @Override
    public void preBalance(ObserverContext<MasterCoprocessorEnvironment> c, BalanceRequest request) throws IOException {
        requirePermission(c,"balance", Permission.Action.ADMIN);
    }
    // DLC-FIX
    
4.4.2 RnagerAuthorizationCoprocessor.java [2]
  • 模块

    ranger-hbase-plugin-shim
    
  • 包路径

    org.apache.ranger.authorization.hbase.RangerAuthorizationCoprocessor
    
  • 待修改部分

    @Override
    public void preBalance(...)	throws IOException {...}
    
  • 修改后部分

    // DLC-FIX
    // @Override
    // public void preBalance(...)	throws IOException {...}
    
    @Override
    public void preBalance(ObserverContext<MasterCoprocessorEnvironment> c, BalanceRequest request)	throws IOException {
        if(LOG.isDebugEnabled()) {
            LOG.debug("==> RangerAuthorizationCoprocessor.preBalance()");
        }
    
        try {
            activatePluginClassLoader();
            implMasterObserver.preBalance(c, request);
        } finally {
            deactivatePluginClassLoader();
        }
    
        if(LOG.isDebugEnabled()) {
            LOG.debug("<== RangerAuthorizationCoprocessor.preBalance()");
        }
    }
    // DLC-FIX
    

4.5 修改 ElasticSearch 插件源码

4.5.1 RangerElasticsearchPlugin.java
  • 模块

    ranger-elasticsearch-plugin-shim
    
  • 包路径

    org.apache.ranger.authorization.elasticsearch.plugin.RangerElasticsearchPlugin
    
  • 待修改部分

    @Override
    public Collection<Object> createComponents(...){...}
    
  • 修改后部分

    // DLC-FIX
    //	@Override
    // DLC-FIX
    public Collection<Object> createComponents(...){...}
    

4.6 修改 HDFS 插件源码

4.6.1 RangerHdfsAuthorizer.java
  • 模块

    hdfs-agent
    
  • 包路径

    org.apache.ranger.authorization.hadoop.RangerHdfsAuthorizer
    
  • 待修改部分

    // 整体替换
    
  • 修改后部分

    此处因需要适配 Hadoop 3.2.4 ,因此整体将该文件替换为 Ranger 2.1.0 版本的对应文件。

    // 由于篇幅过长,该文件可前往 DataLight 开源仓库 中的 docs 目录中下载
    
4.6.2 RangerHdfsAuthorizerTest.java
  • 模块

    hdfs-agent
    
  • 包路径

    org.apache.ranger.services.hdfs.RangerHdfsAuthorizerTest
    
  • 待修改部分

    // 整体替换
    
  • 修改后部分

    此处因需要适配 Hadoop 3.2.4 ,因此整体将该文件替换为 Ranger 2.1.0 版本的对应文件。

    // 由于篇幅过长,该文件可前往 DataLight 开源仓库 中的 docs 目录中下载
    

4.7 Ranger 源码

4.7.1 RangerConfiguration.java
  • 模块

    agents-common
    
  • 包路径

    org.apache.ranger.authorization.hadoop.config.RangerConfiguration
    
  • 待修改部分

    // 无
    
  • 修改后部分

    新增如下代码(DLC-FIX 包裹部分)。

    protected RangerConfiguration() {...}
    
    // DLC-FIX
    private static volatile RangerConfiguration config;
    public static RangerConfiguration getInstance() {
        RangerConfiguration result = config;
        if (result == null) {
            synchronized (RangerConfiguration.class) {
                result = config;
                if (result == null) {
                    config = result = new RangerConfiguration();
                }
            }
        }
        return result;
    }
    // DLC-FIX
    
    public boolean addResourceIfReadable(...) {...}
    
4.7.2 RangerDefaultAuditHandler.java
  • 模块

    agents-common
    
  • 包路径

    org.apache.ranger.plugin.audit.RangerDefaultAuditHandler
    
  • 待修改部分

    // 无
    
  • 修改后部分

    新增如下代码(DLC-FIX 包裹部分)。

    private static final Logger LOG = LoggerFactory.getLogger(RangerDefaultAuditHandler.class);
    
    // DLC-FIX
    protected static final String RangerModuleName =  RangerConfiguration.getInstance().get(RangerHadoopConstants.AUDITLOG_RANGER_MODULE_ACL_NAME_PROP , RangerHadoopConstants.DEFAULT_RANGER_MODULE_ACL_NAME);
    // DLC-FIX
    
    private static final String       CONF_AUDIT_ID_STRICT_UUID     = "xasecure.audit.auditid.strict.uuid";
    
4.7.3 修改 Ranger Admin 依赖
  • 模块

    security-admin
    
  • 修改文件

    pom.xml
    
  • 待修改部分

    <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.12.1</version>
        <configuration>
            <workingDirectory>${project.build.directory}</workingDirectory>
            <installDirectory>${project.build.directory}</installDirectory>
        </configuration>
        <executions>
            <execution>
                <phase>process-resources</phase>
                <id>install node and npm</id>
                <goals>
                    <goal>install-node-and-npm</goal>
                </goals>
                <configuration>
                    <nodeVersion>v8.12.0</nodeVersion>
                    <npmVersion>6.4.1</npmVersion>
                </configuration>
            </execution>
            <execution>
                <phase>prepare-package</phase>
                <id>npm install for packaging</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <workingDirectory>${project.build.directory}/jsmain</workingDirectory>
                    <arguments>install</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>prepare-package</phase>
                <id>npm run r.js</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <workingDirectory>${project.build.directory}/jsmain</workingDirectory>
                    <arguments>run r.js -- -o ../${project.build.finalName}/minify.build.js</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>test</phase>
                <id>npm install for tests</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <arguments>install</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>test</phase>
                <id>karma dev</id>
                <goals>
                    <goal>karma</goal>
                </goals>
                <configuration>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <karmaConfPath>../../src/test/javascript/karma-dev.conf.js</karmaConfPath>
                </configuration>
            </execution>
            <execution>
                <phase>integration-test</phase>
                <id>karma prd</id>
                <goals>
                    <goal>karma</goal>
                </goals>
                <configuration>
                    <environmentVariables>
                        <buildDir>${project.build.finalName}</buildDir>
                    </environmentVariables>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <karmaConfPath>../../src/test/javascript/karma-prd.conf.js</karmaConfPath>
                </configuration>
            </execution>
        </executions>
    </plugin>
    
  • 修改后部分

    <plugin>
        <groupId>com.github.eirslett</groupId>
        <artifactId>frontend-maven-plugin</artifactId>
        <version>1.12.1</version>
        <configuration>
            <workingDirectory>${project.build.directory}</workingDirectory>
            <installDirectory>${project.build.directory}</installDirectory>
        </configuration>
        <executions>
            <execution>
                <phase>process-resources</phase>
                <id>install node and npm</id>
                <goals>
                    <goal>install-node-and-npm</goal>
                </goals>
                <configuration>
                    <nodeVersion>v8.12.0</nodeVersion>
                    <npmVersion>6.4.1</npmVersion>
                    <!-- DLC-FIX -->
                    <nodeDownloadRoot>http://nodejs.org/dist/</nodeDownloadRoot>
                    <npmDownloadRoot>http://registry.npmjs.org/npm/-/</npmDownloadRoot>
                    <!-- DLC-FIX -->
                </configuration>
            </execution>
            <execution>
                <phase>prepare-package</phase>
                <id>npm install for packaging</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <workingDirectory>${project.build.directory}/jsmain</workingDirectory>
                    <arguments>install</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>prepare-package</phase>
                <id>npm run r.js</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <workingDirectory>${project.build.directory}/jsmain</workingDirectory>
                    <arguments>run r.js -- -o ../${project.build.finalName}/minify.build.js</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>test</phase>
                <id>npm install for tests</id>
                <goals>
                    <goal>npm</goal>
                </goals>
                <configuration>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <arguments>install</arguments>
                </configuration>
            </execution>
            <execution>
                <phase>test</phase>
                <id>karma dev</id>
                <goals>
                    <goal>karma</goal>
                </goals>
                <configuration>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <karmaConfPath>../../src/test/javascript/karma-dev.conf.js</karmaConfPath>
                </configuration>
            </execution>
            <execution>
                <phase>integration-test</phase>
                <id>karma prd</id>
                <goals>
                    <goal>karma</goal>
                </goals>
                <configuration>
                    <environmentVariables>
                        <buildDir>${project.build.finalName}</buildDir>
                    </environmentVariables>
                    <skip>${skipJSTests}</skip>
                    <workingDirectory>${project.build.directory}/jstest</workingDirectory>
                    <karmaConfPath>../../src/test/javascript/karma-prd.conf.js</karmaConfPath>
                </configuration>
            </execution>
        </executions>
    </plugin>
    

4.8 修改 jisql 源码

4.8.1 pom.xml
  • 模块

    jisql
    
  • 修改文件

    pom.xml
    
  • 待修改部分

    # 需新增
    
  • 修改后部分

    <?xml version="1.0" encoding="UTF-8"?>
    <!--
      Licensed to the Apache Software Foundation (ASF) under one or more
      contributor license agreements.  See the NOTICE file distributed with
      this work for additional information regarding copyright ownership.
      The ASF licenses this file to You under the Apache License, Version 2.0
      (the "License"); you may not use this file except in compliance with
      the License.  You may obtain a copy of the License at
    
          http://www.apache.org/licenses/LICENSE-2.0
    
      Unless required by applicable law or agreed to in writing, software
      distributed under the License is distributed on an "AS IS" BASIS,
      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      See the License for the specific language governing permissions and
      limitations under the License.
    -->
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <artifactId>jisql</artifactId>
        <name>Jdbc SQL Connector</name>
        <description>Jdbc SQL Connector to execute sql statement in any db</description>
        <packaging>jar</packaging>
        <parent>
            <groupId>org.apache.ranger</groupId>
            <artifactId>ranger</artifactId>
            <version>2.4.0</version>
            <relativePath>..</relativePath>
        </parent>
        <dependencies>
            <dependency>
                <groupId>net.sf.jopt-simple</groupId>
                <artifactId>jopt-simple</artifactId>
                <version>${jopt-simple.version}</version>
            </dependency>
        </dependencies>
    
        <!-- DLC-FIX -->
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-shade-plugin</artifactId>
                    <version>3.2.4</version>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>shade</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
        <!-- DLC-FIX -->
    </project>
    

4.9 修改 embeddedwebserver 源码

4.9.1 pom.xml
  • 模块

    embeddedwebserver
    
  • 修改文件

    pom.xml
    
  • 待修改部分

    # 需新增
    
  • 修改后部分

    <!-- DLC-FIX -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <!-- DLC-FIX -->
    

4.10 修改 ugsync 源码

4.9.1 pom.xml
  • 模块

    ugsync
    
  • 修改文件

    pom.xml
    
  • 待修改部分

    # 需新增
    
  • 修改后部分

    <!-- DLC-FIX -->
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.1.1</version>
        <executions>
            <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                    <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                    <outputDirectory>${project.build.directory}/lib</outputDirectory>
                    <overWriteReleases>false</overWriteReleases>
                    <overWriteSnapshots>false</overWriteSnapshots>
                    <overWriteIfNewer>true</overWriteIfNewer>
                </configuration>
            </execution>
        </executions>
    </plugin>
    <!-- DLC-FIX -->
    

4.11 修改 tagsync 源码

4.9.1 pom.xml
  • 模块

    tagsync
    
  • 修改文件

    pom.xml
    
  • 待修改部分

    # 需新增
    
  • 修改后部分

    <!-- DLC-FIX -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.1.1</version>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <!-- DLC-FIX -->
    

注:编译后,如某些模块缺少对应 jar 包,可将对应模块 target/lib 目录下的内容拷贝至对应模块的 lib 目录下。

4.12 修改 distro 源码

  • 模块

    distro
    
  • 修改文件

    ranger-release-ranger-2.4.0\distro\src\main\assembly 目录下所有 xml 文件
    
  • 待修改部分

    <includeDependencies>false</includeDependencies>
    
  • 修改后部分

    所有该标签的 false 改为 true

    <!-- DLC-FIX -->
    <includeDependencies>true</includeDependencies>
    <!-- DLC-FIX -->
    <!-- 新增 -->
    <!-- DLC-FIX> -->
    <fileSet>
      <directory>${project.build.directory}/lib</directory>
      <outputDirectory>lib</outputDirectory>
      <includes>
          <include>**/*</include>
      </includes>
      <excludes>
          <exclude>aws-java-sdk-bundle*.jar</exclude>
      </excludes>
      <fileMode>644</fileMode>
      <directoryMode>755</directoryMode>
    </fileSet>
    <!-- DLC-FIX> -->
    

五、执行编译

5.1 执行命令

mvn -Pall clean

mvn -Pall -DskipTests=true clean compile package install

5.2 编译结果

[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for ranger 2.4.0:
[INFO] 
[INFO] ranger ............................................. SUCCESS [ 10.733 s]
[INFO] Jdbc SQL Connector ................................. SUCCESS [  8.324 s]
[INFO] Credential Support ................................. SUCCESS [  9.143 s]
[INFO] Audit Component .................................... SUCCESS [ 16.281 s]
[INFO] ranger-plugin-classloader .......................... SUCCESS [  5.574 s]
[INFO] Common library for Plugins ......................... SUCCESS [ 29.614 s]
[INFO] ranger-intg ........................................ SUCCESS [  7.952 s]
[INFO] Installer Support Component ........................ SUCCESS [  4.903 s]
[INFO] Credential Builder ................................. SUCCESS [  7.129 s]
[INFO] Embedded Web Server Invoker ........................ SUCCESS [  9.310 s]
[INFO] Key Management Service ............................. SUCCESS [ 19.391 s]
[INFO] HBase Security Plugin Shim ......................... SUCCESS [  9.276 s]
[INFO] HBase Security Plugin .............................. SUCCESS [ 14.499 s]
[INFO] Hdfs Security Plugin ............................... SUCCESS [ 12.243 s]
[INFO] Hive Security Plugin ............................... SUCCESS [ 18.394 s]
[INFO] Knox Security Plugin Shim .......................... SUCCESS [  6.335 s]
[INFO] Knox Security Plugin ............................... SUCCESS [ 13.202 s]
[INFO] Storm Security Plugin .............................. SUCCESS [ 12.402 s]
[INFO] YARN Security Plugin ............................... SUCCESS [  8.831 s]
[INFO] Ozone Security Plugin .............................. SUCCESS [  7.971 s]
[INFO] Ranger Util ........................................ SUCCESS [  7.127 s]
[INFO] Unix Authentication Client ......................... SUCCESS [  5.831 s]
[INFO] User Group Synchronizer Util ....................... SUCCESS [  4.873 s]
[INFO] Security Admin Web Application ..................... SUCCESS [03:10 min]
[INFO] KAFKA Security Plugin .............................. SUCCESS [ 10.058 s]
[INFO] SOLR Security Plugin ............................... SUCCESS [ 10.577 s]
[INFO] NestedStructure Security Plugin .................... SUCCESS [ 11.083 s]
[INFO] NiFi Security Plugin ............................... SUCCESS [  8.327 s]
[INFO] NiFi Registry Security Plugin ...................... SUCCESS [  7.917 s]
[INFO] Presto Security Plugin ............................. SUCCESS [ 10.722 s]
[INFO] Kudu Security Plugin ............................... SUCCESS [  5.746 s]
[INFO] Unix User Group Synchronizer ....................... SUCCESS [ 14.445 s]
[INFO] Ldap Config Check Tool ............................. SUCCESS [  6.275 s]
[INFO] Unix Authentication Service ........................ SUCCESS [  6.877 s]
[INFO] KMS Security Plugin ................................ SUCCESS [ 12.707 s]
[INFO] Tag Synchronizer ................................... SUCCESS [ 12.984 s]
[INFO] Hdfs Security Plugin Shim .......................... SUCCESS [  6.762 s]
[INFO] Hive Security Plugin Shim .......................... SUCCESS [  9.077 s]
[INFO] YARN Security Plugin Shim .......................... SUCCESS [  6.694 s]
[INFO] OZONE Security Plugin Shim ......................... SUCCESS [  6.179 s]
[INFO] Storm Security Plugin shim ......................... SUCCESS [  6.173 s]
[INFO] KAFKA Security Plugin Shim ......................... SUCCESS [  5.797 s]
[INFO] SOLR Security Plugin Shim .......................... SUCCESS [  7.166 s]
[INFO] Atlas Security Plugin Shim ......................... SUCCESS [  5.280 s]
[INFO] KMS Security Plugin Shim ........................... SUCCESS [  8.482 s]
[INFO] Presto Security Plugin Shim ........................ SUCCESS [  6.010 s]
[INFO] ranger-examples .................................... SUCCESS [  0.114 s]
[INFO] Ranger Examples - Conditions and ContextEnrichers .. SUCCESS [  8.036 s]
[INFO] Ranger Examples - SampleApp ........................ SUCCESS [  3.591 s]
[INFO] Ranger Examples - Ranger Plugin for SampleApp ...... SUCCESS [  5.770 s]
[INFO] sample-client ...................................... SUCCESS [  6.475 s]
[INFO] Apache Ranger Examples Distribution ................ SUCCESS [  4.848 s]
[INFO] Ranger Tools ....................................... SUCCESS [  9.479 s]
[INFO] Atlas Security Plugin .............................. SUCCESS [  8.644 s]
[INFO] SchemaRegistry Security Plugin ..................... SUCCESS [ 11.176 s]
[INFO] Sqoop Security Plugin .............................. SUCCESS [  9.243 s]
[INFO] Sqoop Security Plugin Shim ......................... SUCCESS [  5.234 s]
[INFO] Kylin Security Plugin .............................. SUCCESS [ 11.049 s]
[INFO] Kylin Security Plugin Shim ......................... SUCCESS [  6.607 s]
[INFO] Elasticsearch Security Plugin Shim ................. SUCCESS [  5.497 s]
[INFO] Elasticsearch Security Plugin ...................... SUCCESS [  7.844 s]
[INFO] Apache Ranger Distribution ......................... SUCCESS [ 49.062 s]
[INFO] Unix Native Authenticator .......................... SUCCESS [  2.549 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

5.3 查找二进制包

find ./ -name "*.tar.gz"

[root@node01 ranger-release-ranger-2.4.0]# find ./ -name "*.tar.gz"
./ranger-examples/target/ranger-examples-2.4.0-sampleapp.tar.gz
./ranger-examples/target/ranger-examples-2.4.0-sampleapp-plugin.tar.gz
./ranger-examples/target/ranger-examples-2.4.0-sample-client.tar.gz
./target/ranger-2.4.0-hdfs-plugin.tar.gz
./target/ranger-2.4.0-hive-plugin.tar.gz
./target/ranger-2.4.0-hbase-plugin.tar.gz
./target/ranger-2.4.0-knox-plugin.tar.gz
./target/ranger-2.4.0-storm-plugin.tar.gz
./target/ranger-2.4.0-kafka-plugin.tar.gz
./target/ranger-2.4.0-yarn-plugin.tar.gz
./target/ranger-2.4.0-ozone-plugin.tar.gz
./target/ranger-2.4.0-solr-plugin.tar.gz
./target/ranger-2.4.0-admin.tar.gz
./target/ranger-2.4.0-solr_audit_conf.tar.gz
./target/ranger-2.4.0-usersync.tar.gz
./target/ranger-2.4.0-tagsync.tar.gz
./target/ranger-2.4.0-migration-util.tar.gz
./target/ranger-2.4.0-kms.tar.gz
./target/ranger-2.4.0-ranger-tools.tar.gz
./target/ranger-2.4.0-src.tar.gz
./target/ranger-2.4.0-atlas-plugin.tar.gz
./target/ranger-2.4.0-sqoop-plugin.tar.gz
./target/ranger-2.4.0-kylin-plugin.tar.gz
./target/ranger-2.4.0-elasticsearch-plugin.tar.gz
./target/ranger-2.4.0-presto-plugin.tar.gz

5.4 取出全部压缩包

mkdir -p /data/install/RANGER

cd /data/install/apache-src/ranger-src/ranger-release-ranger-2.4.0/

find ./ -name "*.tar.gz" -exec cp {} /data/install/RANGER \;

# 检查
[root@node01 RANGER]# cd /data/install/RANGER
[root@node01 RANGER]# pwd
/data/install/RANGER
[root@node01 RANGER]# ll
total 446052
-rw-r--r-- 1 root root 391284796 Sep 11 19:56 ranger-2.4.0-admin.tar.gz
-rw-r--r-- 1 root root   2144230 Sep 11 19:56 ranger-2.4.0-atlas-plugin.tar.gz
-rw-r--r-- 1 root root   3415541 Sep 11 19:56 ranger-2.4.0-elasticsearch-plugin.tar.gz
-rw-r--r-- 1 root root   2226307 Sep 11 19:56 ranger-2.4.0-hbase-plugin.tar.gz
-rw-r--r-- 1 root root   2426986 Sep 11 19:56 ranger-2.4.0-hdfs-plugin.tar.gz
-rw-r--r-- 1 root root   2225136 Sep 11 19:56 ranger-2.4.0-hive-plugin.tar.gz
-rw-r--r-- 1 root root   4164191 Sep 11 19:56 ranger-2.4.0-kafka-plugin.tar.gz
-rw-r--r-- 1 root root   4573191 Sep 11 19:56 ranger-2.4.0-kms.tar.gz
-rw-r--r-- 1 root root   2165387 Sep 11 19:56 ranger-2.4.0-knox-plugin.tar.gz
-rw-r--r-- 1 root root   2129386 Sep 11 19:56 ranger-2.4.0-kylin-plugin.tar.gz
-rw-r--r-- 1 root root     34196 Sep 11 19:56 ranger-2.4.0-migration-util.tar.gz
-rw-r--r-- 1 root root   2399581 Sep 11 19:56 ranger-2.4.0-ozone-plugin.tar.gz
-rw-r--r-- 1 root root   2972774 Sep 11 19:56 ranger-2.4.0-presto-plugin.tar.gz
-rw-r--r-- 1 root root    988420 Sep 11 19:56 ranger-2.4.0-ranger-tools.tar.gz
-rw-r--r-- 1 root root     36907 Sep 11 19:56 ranger-2.4.0-solr_audit_conf.tar.gz
-rw-r--r-- 1 root root   2187795 Sep 11 19:56 ranger-2.4.0-solr-plugin.tar.gz
-rw-r--r-- 1 root root   2379364 Sep 11 19:56 ranger-2.4.0-sqoop-plugin.tar.gz
-rw-r--r-- 1 root root   6376330 Sep 11 19:56 ranger-2.4.0-src.tar.gz
-rw-r--r-- 1 root root   2919573 Sep 11 19:56 ranger-2.4.0-storm-plugin.tar.gz
-rw-r--r-- 1 root root    927366 Sep 11 19:56 ranger-2.4.0-tagsync.tar.gz
-rw-r--r-- 1 root root   1275385 Sep 11 19:56 ranger-2.4.0-usersync.tar.gz
-rw-r--r-- 1 root root   2655302 Sep 11 19:56 ranger-2.4.0-yarn-plugin.tar.gz
-rw-r--r-- 1 root root     12986 Sep 11 19:56 ranger-examples-2.4.0-sampleapp-plugin.tar.gz
-rw-r--r-- 1 root root      9652 Sep 11 19:56 ranger-examples-2.4.0-sampleapp.tar.gz
-rw-r--r-- 1 root root  14776660 Sep 11 19:56 ranger-examples-2.4.0-sample-client.tar.gz

5.5 补齐依赖

将 embeddedwebserver 模块中依赖的 jar 包拷贝至指定目录。

  • 原目录

    /data/install/apache-src/ranger-src/ranger-release-ranger-2.4.0/embeddedwebserver/target/lib
    
  • 拷贝至

    /srv/datalight/RANGER/ranger-2.4.0-admin/ews/webapp/WEB-INF/lib
    

5.6 修改 db_setup.py

在编译后,解压得到 ranger-2.4.0-admin 目录后,修改该目录下的 db_setup.py 文件。

  • 路径

    ./ranger-2.4.0-admin/db_setup.py
    
  • 待修改内容

    (key, _, value) = line.partition("=")
    
  • 修改后内容

    # (key, _, value) = line.partition("=")
    # DLC-FIX
    (key, _, value) = line.decode('utf8').partition("=")
    # DLC-FIX
    

以上步骤完成后,即可进行RangerAdmin等一系列部署工作。具体参考该专题下的部署教程。

关注我们


感谢您一直以来对 DataLight 的支持和信任。DataLight 将为您带来更加智能和高效的数据管理体验。期待您的使用和反馈!
——DataLight 团队


关注我们,获取更多最新资讯:

微信公众号:

QQ 交流群:

微信交流:

一起见证数据世界的无限可能!

开源协议

本项目采用 Apache 2.0 开源协议。有关详细内容,请查看 Apache 2.0 LICENSE

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值