1、 Configuration config = HBaseConfiguration.create(); 书上说是会自动加载hbase-site.xml里面配置的zookeeper 配置
但是实际上是访问的是localhost本地的zookeeper2181端口
2、因此如果本地不是zookeeper server 的话就无法访问hbase 了
3、解决办法通过参数传给程序
例子:
public static class CountReducer extends Reducer<Text, IntWritable, Text, Text> {
private Text TABLE_NAME = new Text();
private Text ZOOKEEPER = new Text();
@Override
protected void setup(Context context) throws IOException, InterruptedException {
// 读取配置
Configuration conf = context.getConfiguration();
TABLE_NAME = new Text(conf.get("TABLE_NAME"));
ZOOKEEPER = new Text(conf.get("hbase.zookeeper.quorum"));
super.setup(context);
}
protected void reduce(Text text, Iterable<IntWritable> values,Context conte