HBase 如何添加其依赖 jar 并使用 HADOOP_CLASSPATH

How HBase add its dependency jars and use HADOOP_CLASSPATH

48. HBase, MapReduce, and the CLASSPATH

By default, MapReduce jobs deployed to a MapReduce cluster do not have access to either the HBase configuration under $HBASE_CONF_DIR or the HBase classes.

To give the MapReduce jobs the access they need, you could add hbase-site.xml_to _$HADOOP_HOME/conf and add HBase jars to the $HADOOP_HOME/lib directory. You would then need to copy these changes across your cluster. Or you could edit $HADOOP_HOME/conf/hadoop-env.sh and add hbase dependencies to the HADOOP_CLASSPATH variable. Neither of these approaches is recommended because it will pollute your Hadoop install with HBase references. It also requires you restart the Hadoop cluster before Hadoop can use the HBase data.

The recommended approach is to let HBase add its dependency jars and use HADOOP_CLASSPATH or -libjars.

我正在学习 HBase 如何与 MapReduce 交互

我知道上面两种方式是什么意思,但是不知道推荐的方式怎么配置

谁能告诉我如何按照推荐的方式配置它?

如文档所示,在 运行 hadoop jar 之前,您可以 export HADOOP_CLASSPATH=$(hbase classpath) 并且可以使用 hadoop jar ... -libjars [...]


真正推荐的方法是在您的 mapreduce 应用程序中

唯一需要注意的是,您需要确保您的项目使用 same/compatible hbase-mapreduce 客户端版本作为服务器。

这样,您不需要任何额外的配置,除了可能指定 hbase-site.xml