confluent入库hive安全认证问题

使用confluent将Kafka中的数据入库hive失败的解决方案


应用场景:
用户想在 HD平台使用confluent开源组件将Kafka中的数据直接导入到hive中,测试环境中已经实现,但生产环境中由于平台开启了Kerberos安全认证服务,所以一直报认证失败的日志.
5caab36655bd3

confluent:
confluent将数据导入hive库: 先将数据导入到hdfs上指定的目录下,然后通过外表的形式入库hive.
confluent通过metastore服务(thirft://url:9083))获取hive的元数据.
官网配置文档:
数据导入hdfs的配置:
           `name=hdfs-sink`

           `connector.class=io.confluent.connect.hdfs.HdfsSinkConnector`

           `tasks.max=1`

           `topics=test_hdfs`

           `hdfs.url=hdfs://localhost:9000`

           `flush.size=3`
数据直接入户hive需要增加的配置:
           `hive.integration=true`


           `hive.metastore.uris=thrift://localhost:9083 `

          `schema.compatibility=BACKWARD`
如果平台有Kerberos安全认证需要增加的配置:
           `hdfs.authentication.kerberos=true`


           `connect.hdfs.principal=connect-hdfs/[email protected]`

           `connect.hdfs.keytab=path to the connector `              

           `keytab

hdfs.namenode.principal=namenode principal`


问题排查:
通过查看confluent和hive的部分代码发现confluent导入数据到hive共需要两次认证:
第一次登陆是在io.confluent.connect.hdfs.DataWriter中使用confluent配置文件中connect.hdfs.principal提供的principal登陆
第一次登陆
第二次登陆是在org.apache.hadoop.hive.metastore.HiveMetaStoreClient中通过hive-site.xml文件中的配置信息登陆
如果sasl参数设置为true则先认证,然后获取client,如果sasl参数为false,则先获取client,然后进行非安全模式下的认证.两种模式通过不同的方式获取道德用户信息是不同的,安全模式下用户为Kerberos用户(如principal=connect-hdfs/[email protected],则用户名为connect-hdfs),非安全模式下的用户为Linux上的用户(whoami).
5caabc66094d8
hive-site.xml文件加载
5caac039ca5ee
5caac0573ffa6
由于confluent的配置文件中没有配置hive.conf.dir参数,因此使用了sasl的默认值false,导致认证失败.
5caac119c3fc6

解决办法:
在confluent关于导入hdfs的connector的配置文件中加入hive.conf.dir参数,并且该参数指定的文件不支持_HOST通配符的写法.

你可能感兴趣的:(confluent入库hive安全认证问题)