DEV Community

Michael
Michael

Posted on

Loading Kerberos-Authenticated HDFS Files into GBase 8a

GBase 8a, the China-domestically developed MPP database from GBASE, can load files straight from Hadoop HDFS, including clusters secured with Kerberos. This post covers the parameters involved and a working load statement.

Configuration parameters

HDFS parameters go into the [gbased] section of the config file on every gcluster and gnode node. All of them can also be set temporarily with set, which is the recommended way to debug before writing anything permanent into the config.

gbase_hdfs_protocol

Protocol used to reach HDFS: http, https, or rpc. Each pairs with a port set by gbase_hdfs_port. Mixed-case values work, but sticking to all upper or all lower case keeps things simple.

gbase_hdfs_port

Default ports differ between Hadoop 2.X and 3.X:

Protocol hadoop 2.X port hadoop 3.X port
http 50070 9870
https 50470 9871
rpc 9000 / 8020 8020

gbase_hdfs_auth_mode

  • simple — basic authentication.
  • kerberos — Kerberos authentication, which additionally requires a keytab and a principal.

Again, all-upper or all-lower case is the safer choice.

gbase_hdfs_namenodes

One or more NameNode hosts (hostnames or IPs), separated by commas, each optionally followed by a :port. When several HDFS environments exist, separate the high-availability NameNode groups with |:

gbase_hdfs_namenodes='192.168.1.1,192.168.1.2'
gbase_hdfs_namenodes="192.168.1.1:50170,192.168.1.2"
gbase_hdfs_namenodes='192.168.1.1:50170,192.168.1.2:50180'
gbase_hdfs_namenodes='192.168.1.1,192.168.1.2|192.168.2.1,192.168.2.2'
Enter fullscreen mode Exit fullscreen mode

Hostnames are supported too:

gbase_hdfs_namenodes='hdfs_nn1:8020,hdfs_nn2:8020'
Enter fullscreen mode Exit fullscreen mode

gbase_hdfs_keytab

A string variable naming the keytab file for the Kerberos principal. Single quotes, double quotes, or no quoting at all all work — no quotes is the least surprising:

gbase_hdfs_keytab=$GBASE_BASE/config/gbase.keytab
gbase_hdfs_keytab='$GBASE_BASE/config/gbase.keytab'
gbase_hdfs_keytab="$GBASE_BASE/config/gbase.keytab"
Enter fullscreen mode Exit fullscreen mode

gbase_hdfs_principal

The security principal for Kerberos. In an HDFS cluster a valid principal has the form username/hostname@REALM.COM.

Additional host configuration

Every node in the cluster needs /etc/hosts entries mapping the Hadoop Namenode and Datanode IPs to hostnames:

10.0.2.141  hadoop141
10.0.2.142  hadoop142
Enter fullscreen mode Exit fullscreen mode

A working load statement

gbase> load data infile 'hdp://hdfs:hdfs2@hadoop141/*.txt' into table t2 fields terminated by ',';
Query OK, 2 rows affected (Elapsed: 00:00:01.02)
Task 4107 finished, Loaded 2 records, Skipped 0 records
Enter fullscreen mode Exit fullscreen mode

2 records loaded, 0 skipped, in about 1.02 seconds, as task 4107.

When authentication fails

A GBase 8a cluster can load HDFS files, but hardened Hadoop setups — especially those where http / https triggers a failed handshake — return:

401 Authentication required
Enter fullscreen mode Exit fullscreen mode

Try the rpc protocol instead. It talks to the NameNode RPC port and bypasses the WebHDFS HTTP authentication path entirely. On the gbase side you only change gbase_hdfs_protocol and its matching gbase_hdfs_port; the load statement itself stays untouched. That makes protocol switching a cheap first diagnostic when a secured HDFS source refuses a load into the database.

Top comments (0)