分享

使用eclipse运行MapReduce程序时,是不是只用到Linux服务器上的HDFS文件系统?

chenhaoyes 发表于 2014-8-20 20:44:00 [显示全部楼层] 回帖奖励 阅读模式 关闭右栏 2 6500
感觉在Eclipse调试执行MapReduce程序时,只在参数设置时用到Linux服务器上的HDFS文件系统下的input,output目录,跟Linux系统上的集群啥的都没有关系吧?因为在windows本地也会配置HADOOP_HOME的目录,运行时所需要的环境也应该是从本地的hadoop中读取的,希望高手解答一下。

已有(2)人评论

跳转到指定楼层
desehawk 发表于 2014-8-20 21:39:04
跟你的理解一样,所以在本地开发的时候,有些参数,需要设置和覆盖,达到和集群环境一致
回复

使用道具 举报

desehawk 发表于 2014-8-20 21:42:39
比如下面程序就是对配置文件的覆盖,达到能够连接到集群的目的


package www.aboutyun.com.hbase;

import java.io.IOException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.util.Bytes;

public class OperateTable {
         public static void main(String[] args) throws IOException {
         
         Configuration conf = HBaseConfiguration.create();
         conf.set("hbase.zookeeper.quorum", "master");//使用eclipse时必须添加这个,否则无法定位
         conf.set("hbase.zookeeper.property.clientPort", "2181");
         HBaseAdmin admin = new HBaseAdmin(conf);// 新建一个数据库管理员//新api
         HTableDescriptor desc=new HTableDescriptor(TableName.valueOf("blog"));
         //HTableDescriptor desc = new HTableDescriptor("blog");
         desc.addFamily(new HColumnDescriptor("article"));
         desc.addFamily(new HColumnDescriptor("author"));
         admin.createTable(desc );
         admin.close();
         //admin.disableTable("blog");
         //admin.deleteTable("blog");
         //assertThat(admin.tableExists("blog"),is(false));
   }
}








回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关闭

推荐上一条 /2 下一条