Storm消费kafka写入华为云Hbase

最近遇到一个华为云Hbase的问题,在网上没有找到解决的方法,所以在这记录一下。
问题描述:
storm消费kafka数据写入Hbase。storm与kafka都是自己安装的,Hbase是华为云的。
如果按照正常的storm消费kafka然后直接存入hbase会出现zookeeper链接问题,因为这边用了两个zookeeper。
这里写图片描述
主要是在里面加上了init();和login();这两个方法

public static void init(){
    Configuration conf = new Configuration();
     String path =AttributeCommon.hbase_path;
     String conFilesPath =path + "conf" + File.separator;
     conf.addResource(new Path(conFilesPath + "core-site.xml"));
     conf.addResource(new Path(conFilesPath + "hdfs-site.xml"));
     conf.addResource(new Path(conFilesPath + "hbase-site.xml"));
}

public static void login(){
        try {
            String path =AttributeCommon.hbase_path;
            String auth = path+ "auth" + File.separator;
            String userPrincipal = "dinfo";
            String userKeytabPath = auth+"user.keytab";
            String krb5ConfPath = auth+"krb5.conf";
            String ZKServerPrincipal = "zookeeper/hadoop.hadoop.com";
            String ZOOKEEPER_DEFAULT_LOGIN_CONTEXT_NAME = "Client";
            String ZOOKEEPER_SERVER_PRINCIPAL_KEY = "zookeeper.server.principal";
            Configuration hadoopConf = new Configuration();
            LoginUtil.setJaasConf(ZOOKEEPER_DEFAULT_LOGIN_CONTEXT_NAME, userPrincipal, userKeytabPath);
            LoginUtil.setZookeeperServerPrincipal(ZOOKEEPER_SERVER_PRINCIPAL_KEY, ZKServerPrincipal);
            LoginUtil.login(userPrincipal, userKeytabPath, krb5ConfPath, hadoopConf);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
     }

LoginUtil这个类在华为云的hbase的demo程序里有。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值