Friday, November 16, 2018

How to write an example MapR Drill JDBC code which connects to a MapR-Drill Cluster with MapRSASL authentication

Goal:

How to write an example MapR Drill JDBC code which connects to a MapR-Drill Cluster with MapRSASL authentication.
The reason why we are using Simba Drill JDBC Driver instead of open source JDBC Driver is:
The open-source JDBC driver is not tested on the MapR Converged Data Platform. The driver supports Kerberos and Plain authentication mechanisms, but does not support the MapR-SASL authentication mechanism. 

Env:

Drill 1.14 using MapRSASL authentication
MapR 6.1 secure Cluster
Simba Drill JDBC 1.6.0

Solution:

1. Download example JAVA code

https://github.com/viadea/MapRDrillJDBCExample
git clone git@github.com:viadea/MapRDrillJDBCExample.git

2. Compile

mvn clean package
The compiled jar is here:
./target/MapRDrillJDBCExample-1.0.jar

3. Copy the jar dependencies and remove possible jar conflict

mkdir drilljars
cp /opt/mapr/drill/drill-1.14.0/jars/*.jar ./drilljars/
cp /opt/mapr/drill/drill-1.14.0/jars/3rdparty/*.jar ./drilljars/
cp /opt/mapr/drill/drill-1.14.0/jars/classb/reflections-0.9.10.jar ./drilljars/
cp /opt/mapr/drill/drill-1.14.0/jars/classb/javax.servlet-api-3.1.0.jar ./drilljars/
rm ./drilljars/drill-jdbc-1.14.0-mapr-SNAPSHOT.jar

mkdir maprjars
cp /opt/mapr/lib/*.jar ./maprjars/
rm ./maprjars/slf4j-log4j12-1.7.12.jar

4. Download Simba Drill JDBC Driver

Please always follow below documentation for the correct version of the driver:
https://mapr.com/docs/home/Drill/drill_jdbc_connector.html
wget https://package.mapr.com/tools/MapR-JDBC/MapR_Drill/MapRDrill_jdbc_v1.6.0.1001/MapRDrillJDBC-1.6.0.1001.zip
unzip MapRDrillJDBC-1.6.0.1001.zip
cd MapRDrillJDBC41-1.6.0.1001
unzip MapRDrillJDBC41-1.6.0.1001.zip

5. Run the program

java -cp ./MapRDrillJDBC41-1.6.0.1001/DrillJDBC41.jar:./drilljars/*:./target/MapRDrillJDBCExample-1.0.jar:./maprjars/* openkb.drill.MapRDrillJDBCExample
This program will run "select hostname from sys.drillbits" and display the results. For example:
hostname: v1.poc.com
hostname: v4.poc.com
hostname: v3.poc.com
hostname: v2.poc.com


1 comment:

Popular Posts