读取hbase启动master需要配置master吗

博客分类:
hbase的安装和配置请看
使用shell建表
create 'gpsinfo','gpsdata'
gpsinfo为表名
gpsdata为columnfamily
import java.io.IOE
import java.util.D
import org.apache.hadoop.conf.C
import org.apache.hadoop.hbase.HBaseC
import org.apache.hadoop.hbase.client.HBaseA
import org.apache.hadoop.hbase.client.HT
import org.apache.hadoop.hbase.client.P
import org.apache.hadoop.hbase.util.B
public class HbaseSave {
public static void main(String[] args) throws Exception {
//建表 create 'gpsinfo','gpsdata'
Configuration HBASE_CONFIG = new Configuration();
HBASE_CONFIG.set("hbase.zookeeper.quorum", "192.168.3.206");
Configuration configuration = HBaseConfiguration.create(HBASE_CONFIG);
HBaseAdmin admin =new HBaseAdmin(configuration);
if (admin.tableExists("gpsinfo")) {
System.out.println("表已经存在!");
HTable table = new HTable(configuration, "gpsinfo");
Put put = new Put(Bytes.toBytes(""+new Date().getTime()));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("unitid"),Bytes.toBytes(""));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("lon"),Bytes.toBytes(111.321f));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("lat"),Bytes.toBytes(23.4687f));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("direction"),Bytes.toBytes(180));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("speed"),Bytes.toBytes(62.2f));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("locationstatus"),Bytes.toBytes(1));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("vehiclestatus"),Bytes.toBytes("点火"));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("gpstime"),Bytes.toBytes(new Date().getTime()));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("referenceposition"),Bytes.toBytes("意隆路22号"));
put.add(Bytes.toBytes("gpsdata"),Bytes.toBytes("rawdata"),Bytes.toBytes("7b217d"));
table.put(put);
table.close();
System.out.println("表不存在");
configuration.clear();
} catch (IOException e) {
e.printStackTrace();
在此过程中碰到的一些问题:
1. [root@localhost bin]# hadoop namenode -format
-bash: hadoop: command not found
将hadoop/bin路径加入PATH,需要重启机器
[root@localhost bin]# vi /etc/profile
export PATH=$JAVA_HOME/bin:$PATH:/root/Desktop/hadoop-1.1.1/bin
2. myeclipse连接报错:
警告: Possibly transient ZooKeeper exception: org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /hbase/master
10:22:36 org.apache.hadoop.hbase.util.RetryCounter sleepUntilNextRetry
确保hbase正常启动了
禁用IPV6,将/etc/hosts文件里面的::1 localhost那一行删掉重启
关闭防火墙
3. hadoop启动,namenode日志文件中
org.apache.hadoop.mon.InconsistentFSStateException: Directory /var/log/hadoop_data/dfs/name is in an inconsistent state: storage directory does not exist or is not accessible.
at org.apache.hadoop.hdfs.server.namenode.FSImage.recoverTransitionRead(FSImage.java:303)
at org.apache.hadoop.hdfs.server.namenode.FSDirectory.loadFSImage(FSDirectory.java:100)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.initialize(FSNamesystem.java:411)
at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.&init&(FSNamesystem.java:379)
at org.apache.hadoop.hdfs.server.namenode.NameNode.initialize(NameNode.java:277)
at org.apache.hadoop.hdfs.server.namenode.NameNode.&init&(NameNode.java:529)
at org.apache.hadoop.hdfs.server.namenode.NameNode.createNameNode(NameNode.java:1403)
at org.apache.hadoop.hdfs.server.namenode.NameNode.main(NameNode.java:1412)
格式化namenode
$ hadoop namenode –format
4. 客户端连接hbase报错:
java.net.UnknownHostException: unknown host: xiekang-pc
在本地配置host
192.168.3.206&&&&&& xiekang-pc
5. java.net.ConnectException: Connection refused: no further information
org.apache.hadoop.hbase.ipc.HBaseClient$FailedServerException: This server is in the failed servers list: localhost/127.0.0.1:60000
服务器上master地址和localhost/127.0.0.1:60000对不上。
查看http://192.168.3.206:60010/master-status的master地址。
浏览 24025
浏览: 178880 次
来自: 长沙
jquery全局ajax参数详细执行分析-$.ajax竟然可以 ...
原来的点传不到回调函数里,回调函数里获得的值在外面又取不到,请 ...
GPS坐标转百度坐标的功能 ,百度有这个api是吧,可是我调用 ...
我把配置中的所有地址用IP代替,终于解决了
你好!我服务器运行hbase后,页面访问http://192. ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'hbase.tmp.dir:本地文件系统的临时目录,默认是java.io.tmpdir/hbase&java.io.tmpdir/hbase&{user.name};
hbase.rootdir:hbase持久化的目录,被所有regionserver共享,默认${hbase.tmp.dir}/hbase,一般设置为hdfs://namenode.example.org:9000/hbase类似,带全限定名;
hbase.cluster.distributed:hbase集群模式运作与否的标志,默认是false,开启需要设置为true,false时启动hbase会在一个jvm中运行hbase和zk;
hbase.zookeeper.quorum:重要的也是必须设置的,启动zk的服务器列表,逗号分隔,cluster模式下必须设置,默认是localhost,hbase客户端也需要设置这个值去访问zk;
hbase.local.dir:本地文件系统被用在本地存储的目录,默认${hbase.tmp.dir}/local/;
hbase.master.port:hbase master绑定的端口,默认是60000;
.port:hbase master web 界面的端口,默认是60010,设置为-1可以禁用ui;
.bindAddress:master web界面的绑定地址,默认是0.0.0.0;
hbase.master.logcleaner.plugins:清理日志的插件列表,逗号分隔,被LogService调用的LogCleanerDelegate,可以自定义,顺序执行,清理WAL和HLog;默认org.apache.hadoop.hbase.master.cleaner.TimeToLiveLogCleaner
hbase.master.logcleaner.ttl:HLog在.oldlogdir目录中生存的最长时间,过期则被Master起线程回收,默认是600000;
hbase.master.hfilecleaner.plugins:HFile的清理插件列表,逗号分隔,被HFileService调用,可以自定义,默认org.apache.hadoop.hbase.master.cleaner.TimeToLiveHFileCleaner
hbase.master.catalog.timeout:Catalog Janitor从master到META的超时时间,我们知道这个Janitor是定时的去META扫描表目录,来决定回收无用的regions,默认是600000;
fail.fast.expired.active.master:如果master过期,那么不需要从zk恢复,直接终止,默认是false;
hbase.master.dns.interface:master的dns接口,向该接口提供ip,默认是default;
hbase.master.dns.nameserver:master使用的dns主机名或者ip,默认是default;
hbase.regionserver.port:regionserver绑定的端口,默认是60020;
.port:regionserver的web界面端口,-1取消界面,默认是60030;
.bindAddress:regionserver的web绑定,默认是0.0.0.0;
.port.auto:master或者regionserver是否自动搜索绑定的端口,默认是false;
hbase.regionserver.handler.count:regionserver上rpc listener的个数,把这个配置称为io线程数,其实雷同,就是说在regionserver上一个处理rpc的handler,默认是30;
hbase.regionserver.msginterval:regionserver向master发消息的间隔,默认3000毫秒;
hbase.regionserver.optionallogflushinterval:如果没有足够的entry触发同步,那么过了这个间隔后HLog将被同步到HDFS,默认是1000毫秒;
hbase.regionserver.regionSplitLimit:regionsplit的最大限额,默认是MAX_INT=,设置这个限制后,在到达限制时region split就不会再进行;
hbase.regionserver.logroll.period:不管有多少版本,直接roll掉commit log的周期,也就是说一个固定的时间周期,到期就roll,默认是3600000毫秒;
hbase.regionserver.logroll.errors.tolerated:可接受的WAL关闭错误个数,到达后将触发服务器终止;设置为0那么在WAL writer做log rolling失败时就停止region server,默认是2;
hbase.regionserver.hlog.reader.impl:HLog 文件reader的实现类,默认是org.apache.hadoop.hbase.regionserver.wal.ProtobufLogReader;
hbase.regionserver.hlog.writer.impl:HLog 文件writer的实现类,默认是org.apache.hadoop.hbase.regionserver.wal.ProtobufLogWriter;
hbase.regionserver.global.memstore.upperLimit:memstore在regionserver内存中的上限,届时新的update被阻塞并且flush被强制写,默认是0.4就是堆内存的40%;阻塞状态持续到regionserver的所有memstore的容量到达hbase.regionserver.global.memstore.lowerLimit;
hbase.regionserver.global.memstore.lowerLimit:memstore在regionserver内存中的最大上限,到达时flush就被强制写,默认是0.38等价于38%的内存容量;
hbase.regionserver.optionalcacheflushinterval:一个edit版本在内存中的cache时长,默认3600000毫秒,设置为0的话则禁止自动flush;
hbase.regionserver.catalog.timeout:regionserver的Catalog Janitor访问META的超时时间,默认是600000;
hbase.regionserver.dns.interface:同master类似~~不讲
hbase.regionserver.dns.nameserver:同master类似
zookeeper.session.timeout:这是个值得说道一下的配置,首先ZK客户端要用,Hbase使用zk的客户端联系总体,同时也被用来启动一个zk server,作为zk的maxSessionTimeout,总的来说就是regionserver与zk的关键参数,如果连接超时,master会重新的balance,regionserver也会被从集群名单中清除,默认是90000;一个问题是如果zk 由hbase自己维护,那么该参数作为regionserver连接是一个值,如果zk在另外的集群,那么zk自己的maxSessionTimeout参数将优先于Hbase的该参数,届时可能会发生超时时间不同的问题;
zookeeper.znode.parent:znode存放root region的地址,默认是root-region-server;
zookeeper.znode.acl.parent:root znode的acl,默认acl;
hbase.zookeeper.dns.interface:zk的dns接口,默认default;
hbase.zookeeper.dns.nameserver:zk的dns服务地址,默认default;
hbase.zookeeper.peerport:zk的peer之间的通讯端口,默认是2888;
hbase.zookeeper.leaderport:zk选leader的通讯端口,默认是3888;
hbase.zookeeper.useMulti:zk支持多重update,要求zk在3.4版本以上,默认是false;
hbase.config.read.zookeeper.config:让hbaseconfig去读zk的config,默认false,也不支持开启,这个功能很搞笑~~个人观点;
hbase.zookeeper.property.initLimit:zk的配置,同步的属性个数限制,默认10个~~没用;
hbase.zookeeper.property.syncLimit:zk的配置,同步时的每次请求的条数,默认5个;
hbase.zookeeper.property.dataDir:zk的配置,snapshot存放的目录,默认是${hbase.tmp.dir}/zookeeper;
hbase.zookeeper.property.clientPort:zk的配置,client连zk的端口,默认2181;
hbase.zookeeper.property.maxClientCnxns:zk的配置,允许接入zk的最大并发连接数的限制,按ip分配,默认300;
hbase.client.write.buffer:htable客户端写缓冲区大小,默认是2097152BYTE,这个缓冲区就是为了写数据的临时存放,设置大了,浪费客户端和服务端的存储,设置小了,如果写的数据多,太多的RPC又带来网络开销,官方给的一个服务端存储耗费评估计算是:hbase.client.write.buffer*hbase.regionserver.handler.count,服务端的rs的处理handler个数也很关键;
hbase.client.pause:pause时长,在hbase发生get或其他操作fail掉的时候进行pause的时间长度,默认是100;
hbase.client.retries.number:发生操作fail时的重试次数,结合上一个指标一起来控制总的重试时间,默认是35;
hbase.client.max.total.tasks:一个HTable实例可以提交给集群的最大并发任务数,默认是100;
hbase.client.max.perserver.tasks:一个HTable实例给一台regionserver提交的最大并发任务数,默认是5;
hbase.client.max.perregion.tasks:客户端连接一台region的最大连接数,换句话说,当你有这么多个连接在region时,新的操作不被发送直到有操作完成,默认是1;
hbase.client.scanner.caching:做scanner的next操作时(如果再本地client没找到)缓存的数据行数,这个值的设置也需要权衡,缓存的多则快,但吃内存,缓存的少则需要多的拉数据, 需要注意的事项是如果两次调用的时间差大于scanner的timeout,则不要设置该值,默认是100;
hbase.client.keyvalue.maxsize:一个KeyValue实例的最大大小,这是存储文件中一个entry的容量上限,合理的设置这个值可以控制regionserver的split,split不会拆keyvalue,所以把keyvalue的大小设置为regionserver大小的一个比例分数(可除)是个不错的选择,默认是;
hbase.client.scanner.timeout.period:结合刚才的caching做的一个,scanner的超时时间,默认是60000毫秒;
hbase.client.localityCheck.threadPoolSize:做localityCheck的线程池大小,默认是2;
hbase.bulkload.retries.number:做bulk load的最大重试次数,默认是0,即代表不断重试;
hbase.balancer.period:Master运行balancer的周期,默认是300000毫秒;
hbase.regions.slop:如果有regionserver的region数目超过average+(average*slop),则rebalance,默认是0.2;
hbase.server.thread.wakefrequency:服务线程的sleep时间,默认10000毫秒,比如log roller;
hbase.server.versionfile.writeattempts:退出前写 version file的重试次数,默认3,每次尝试的间隔由上一个参数控制;
hbase.hregion.memstore.flush.size:Memstore写磁盘的flush阈值,超过这个大小就flush,默认是;
hbase.hregion.preclose.flush.size:如果一个region的memstore的大小等于或超过这个参数的量,在关闭region时(放置关闭flag),要提前flush,然后region关闭下线,默认大小是5242880;
hbase.hregion.memstore.block.multiplier:如果memstore的大小满足hbase.hregion.block.memstore * hbase.hregion.flush.size个byte,那么阻塞update,这个配置可以避免不必要的长时间split或者compact,甚至是OOME,默认是2;
hbase.hregion.memstore.mslab.enabled:开启MemStore-Local Allocation Buffer,这个配置可以避免在高写入的情况下的堆内存碎片,可以降低在大堆情况下的stop-the-world GC频率,默认是true;
hbase.hregion.max.filesize:HStoreFile的最大尺寸,换句话说,当一个region里的列族的任意一个HStoreFile超过这个大小,那么region进行split,默认是;
hbase.hregion.majorcompaction:一个region的所有HStoreFile进行major compact的时间周期,默认是 毫秒(7天);
hbase.hregion.majorcompaction.jitter:major compaction的发生抖动范围,这么理解比较容易,就是说上一个参数不是一个严格周期,会有个抖动,这个参数就是这个抖动的比例,默认是0.5;
pactionThreshold:一个HStore存储HStoreFile的个数阈值,超过这个阈值则所有的HStoreFile会被写到一个新的HStore,需要平衡取舍,默认是3;
hbase.hstore.blockingStoreFiles:一个HStore存储HStoreFile阻塞update的阈值,超过这个阈值,HStore就进行compaction,直到做完才允许update,默认是10;
hbase.hstore.blockingWaitTime:一个更强力的配置,配合上一个参数,当HStore阻塞update时,超过这个时间限制,阻塞取消,就算compaction没有完成,update也不会再被阻塞,默认是90000毫秒;
paction.max:每个minor compaction的HStoreFile个数上限,默认是10;
paction.kv.max:在flushing或者compacting时允许的最大keyvalue个数,如果有大的KeyValue或者OOME的话则配置一个小的值,如果行数多且小则配置大值,默认是10;
hbase.storescanner.parallel.seek.threads:如果并行查找开启的线程池大小,默认是10;
hfile.block.cache.size:一个配置比例,允许最大堆的对应比例的内存作为HFile和HStoreFile的block cache,默认是0.4,即40%,设置为0则disable这个比例,不推荐这么做;
hfile.block.index.cacheonwrite:在index写入的时候允许put无根(non-root)的多级索引块到block cache里,默认是false;
hfile.index.block.max.size:在多级索引的树形结构里,如果任何一层的block index达到这个配置大小,则block写出,同时替换上新的block,默认是131072;
hfile.format.version:新文件的HFile 格式版本,设置为1来测试向后兼容,默认是2;
hfile.block.bloom.cacheonwrite:对于组合布隆过滤器的内联block开启cache-on-write,默认是false;
io.storefile.bloom.block.size:一个联合布隆过滤器的单一块(chunk)的大小,这个值是一个逼近值,默认是131072;
hbase.rs.cacheblocksonwrite:当一个HFile block完成时是否写入block cache,默认是false;
hbase.rpc.server.engine:hbase 做rpc server的调度管理类,实现自org.apache.hadoop.ipc.RpcServerEngine,默认是org.apache.hadoop.hbase.ipc.ProtobufRpcServerEngine;
hbase.rpc.timeout:Hbase client发起远程调用时的超时时限,使用ping来确认连接,但是最终会抛出一个TimeoutException,默认值是60000;
hbase.rpc.shortoperation.timeout:另一个版本的hbase.rpc.timeout,控制短操作的超时时限,比如region server 汇报master的操作的超时时限可以设置小,这样有利于master的failover,默认是10000;
hbase.ipc.client.tcpnodelay:默认是true,具体就是在tcp socket连接时设置 no delay;
hbase.master.keytab.file:kerberos keytab 文件的全路径名,用来为HMaster做log,无默认值;
hbase.master.kerberos.principal:运行HMaster进程时需要kerberos的principal name,这个配置就是这个name的值,形如:;
hbase.regionserver.keytab.file:kerberos keytab 文件的全路径名,用来为HRegionServer做log,无默认值;
hbase.regionserver.kerberos.principal:运行HRegionServer进程时需要kerberos的principal name,这个配置就是这个name的值,形如:;
hadoop.policy.file:RPC服务器做权限认证时需要的安全策略配置文件,在Hbase security开启后使用,默认是habse-policy.xml;
hbase.superuser:Hbase security 开启后的超级用户配置,一系列由逗号隔开的user或者group;
hbase.auth.key.update.interval:Hbase security开启后服务端更新认证key的间隔时间:默认是毫秒;
hbase.auth.token.max.lifetime:Hbase security开启后,认证token下发后的生存周期,默认是毫秒;
hbase.ipc.client.fallback-to-simple-auth-allowed:client使用安全连接去链接一台非安全服务器时,服务器提示client切换到SASL SIMPLE认证模式(非安全),如果设置为true,则client同意切换到非安全连接,如果false,则退出连接;
hbase.coprocessor.region.classes:逗号分隔的Coprocessores列表,会被加载到默认所有表上。在自己实现了一个Coprocessor后,将其添加到Hbase的classpath并加入全限定名。也可以延迟加载,由HTableDescriptor指定;
hbase.rest.port:Hbase REST服务器的端口,默认是8080;
hbase.rest.readonly:定义REST服务器启动的模式,有两种方式,false:所有http方法都将被通过-GET/PUT/POST/DELETE,true:只有get方法ok。默认值是false;
hbase.rest.threads.max:REST服务器线程池的最大线程数,池满的话新请求会自动排队,限制这个配置可以控制服务器的内存量,预防OOM,默认是100;
hbase.rest.threads.min:同上类似,最小线程数,为了确保服务器的服务状态,默认是2;
hbase.rest.support.proxyuser:使REST服务器支持proxy-user 模式,默认是false;
hbase.defaults.for.version.skip:是否跳过hbase.defaults.for.version的检查,默认是false;
hbase.coprocessor.master.classes:由HMaster进程加载的coprocessors,逗号分隔,全部实现org.apache.hadoop.hbase.coprocessor.MasterObserver,同coprocessor类似,加入classpath及全限定名;
hbase.coprocessor.abortonerror:如果coprocessor加载失败或者初始化失败或者抛出Throwable对象,则主机退出。设置为false会让系统继续运行,但是coprocessor的状态会不一致,所以一般debug时才会设置为false,默认是true;
hbase.online.schema.update.enable:设置true来允许在线schema变更,默认是true;
hbase.table.lock.enable:设置为true来允许在schema变更时zk锁表,锁表可以组织并发的schema变更导致的表状态不一致,默认是true;
hbase.thrift.minWorkerThreads:线程池的core size,在达到这里配置的量级后,新线程才会再新的连接创立时创建,默认是16;
hbase.thrift.maxWorkerThreads:顾名思义,最大线程数,达到这个数字后,服务器开始drop连接,默认是1000;
hbase.thrift.maxQueuedRequests:Thrift连接队列的最大数,如果线程池满,会先在这个队列中缓存请求,缓存上限就是该配置,默认是1000;
hbase.thrift.htablepool.size.max:Thrift服务器上table pool的最大上限,默认是1000;
hbase.offheapcache.percentage:JVM参数-XX:MaxDirectMemorySize的百分比值,默认是0,即不开启堆外分配;
hbase.data.umask.enable:开启后,文件在regionserver写入时会 有权限相关设定,默认是false不开启;
hbase.data.umask:开启上面一项配置后,文件的权限umask,默认是000;
hbase.metrics.showTableName:是否为每个指标显示表名前缀,默认是true;
hbase.metrics.exposeOperationTimes:是否进行关于操作在使用时间维度的指标报告,比如GET PUT DELETE INCREMENT等,默认是true;
hbase.snapshot.enabled:是否允许snapshot被使用、存储和克隆,默认是true;
hbase.snapshot.restore.take.failsafe.snapshot:在restore过程中,如果失败则启用snapshot替换,成功则删除掉snapshot,默认开启true;
hbase.snapshot.restore.failsafe.name:刚才所说过程中snapshot的名字,默认是hbase-failsafe-{snapshot.name}-{restore.timestamp};
pactchecker.interval.multiplier:检查是否需要compact的时间间隔,一般情况是在比如memstore flush后或者其他事件触发compact的,但是有时也需要不同的compact策略,所以需要周期性的检查具体间隔=pactchecker.interval.multiplier * hbase.server.thread.wakefrequency,默认1000;
hbase.lease.recovery.timeout:在dfs 租约超时时限,超时则放弃,默认是900000;
hbase.lease.recovery.dfs.timeout:dfs恢复租约调用的超时时限,默认是64000;
阅读(...) 评论()博客分类:
Mapr框架安装完后,安装与配置hbase、hive。其中mapr框架的安装路径为/opt/maprHbase的安装路径为/opt/mapr/hbase/hbase-0.90.4Hive的安装路径为/opt/mapr/hive/hive-0.7.1整合hive与hbase的过程如下:1. 将文件 /opt/mapr/hbase/hbase-0.90.4/hbase-0.90.4.jar 与/opt/mapr/hbase/hbase-0.90.4/lib/zookeeper-3.3.2.jar拷贝到/opt/mapr/hive/hive-0.7.1/lib文件夹下面注意:如果hive/lib下已经存在这两个文件的其他版本(例如zookeeper-3.3.1.jar),建议删除后使用hbase下的相关版本2 修改hive/conf下hive-site.xml文件,在底部添加如下内容:&property&&name&hive.querylog.location&/name&&value&/opt/mapr/hive/hive-0.7.1/logs&/value&&/property&&property&&name&hive.aux.jars.path&/name& &value&file:///opt/mapr/hive/hive-0.7.1/lib/hive-hbase-handler-0.7.1.jar,file:///opt/mapr/hive/hive-0.7.1/lib/hbase-0.90.4.jar,file:///opt/mapr/hive/hive-0.7.1/lib/zookeeper-3.3.2.jar&/value&&/property&注意:如果hive-site.xml不存在则自行创建,或者把hive-default.xml.template文件改名后使用。3. 拷贝hbase-0.90.4.jar到所有hadoop节点(包括master)的hadoop/lib下。4. 拷贝hbase/conf下的hbase-site.xml文件到所有hadoop节点(包括master)的hadoop/conf下。
注意,如果3,4两步跳过的话,运行hive时很可能出现如下错误:org.apache.hadoop.hbase.ZooKeeperConnectionException: HBase is able to connect to ZooKeeper but the connection closes immediately.This could be a sign that the server has too many connections (30 is the default). Consider inspecting your ZK server logs for that error andthen make sure you are reusing HBaseConfiguration as often as you can. See HTable's javadoc for more information. at org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher.
5 启动hive单节点启动bin/hive -hiveconf hbase.master=master:60000集群启动bin/hive -hiveconf hbase.zookeeper.quorum=node1,node2,node3
(所有的zookeeper节点)如果hive-site.xml文件中没有配置hive.aux.jars.path,则可以按照如下方式启动。hive --auxpath /opt/mapr/hive/hive-0.7.1/lib/hive-hbase-handler-0.7.1.jar,/opt/mapr/hive/hive-0.7.1/lib/hbase-0.90.4.jar,/opt/mapr/hive/hive-0.7.1/lib/zookeeper-3.3.2.jar -hiveconf hbase.master=localhost:60000
经测试修改hive的配置文件hive-site.xml
&property&
&name&hive.zookeeper.quorum&/name&
&value&node1,node2,node3&/value&
&description&The list of zookeeper servers to talk to. This is only needed for read/write locks.&/description&&/property&
不用增加参数启动hive就可以联合hbase
6 启动后进行测试(1) 创建hbase识别的表CREATE TABLE hbase_table_1(key int, value string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val") TBLPROPERTIES ("hbase.table.name" = "xyz");hbase.table.name 定义在hbase的table名称,多列时,data:1,data:2;多列族时,data1:1,data2:1;hbase.columns.mapping 定义在hbase的列族,里面的:key 是固定值而且要保证在表pokes中的foo字段是唯一值
创建有分区的表
CREATE TABLE hbase_table_1(key int, value string)
partitioned by (day string) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:val") TBLPROPERTIES ("hbase.table.name" = "xyz");
(2) 使用sql导入数据新建hive的数据表create table pokes(foo int,bar string)row format delimited fields terminated by ',';批量导入数据load data local inpath '/home/1.txt' overwr
1.txt文件的内容为 1,hello 2,pear 3,world
使用sql导入hbase_table_1insert overwrite table hbase_table_1 select *
导入有分区的表
insert overwrite table hbase_table_1
partition (day='') select *
(3) 查看数据 hive& select * from hbase_table_1;OK1 hello2 pear3 world
(注:与hbase整合的有分区的表存在个问题
select * from table查询不到数据,select key,value from table可以查到数据)
(4)登录Hbase去查看数据hbase shell
hbase(main):002:0& describe 'xyz' DESCRIPTION ENABLED {NAME =& 'xyz', FAMILIES =& [{NAME =& 'cf1', BLOOMFILTER =& 'NONE', REPLICATION_S true COPE =& '0', COMPRESSION =& 'NONE', VERSIONS =& '3', TTL =& '', BLOCKSI ZE =& '65536', IN_MEMORY =& 'false', BLOCKCACHE =& 'true'}]} 1 row(s) in 0.0830 secondshbase(main):003:0& scan 'xyz'ROW COLUMN+CELL 1 column=cf1:val, timestamp=2, value=hello 2 column=cf1:val, timestamp=2, value=pear 3 column=cf1:val, timestamp=2, value=world
这时在Hbase中可以看到刚才在hive中插入的数据了。
7 对于在hbase已经存在的表,在hive中使用CREATE EXTERNAL TABLE来建立例如hbase中的表名称为test1,字段为 a: , b: ,c: 在hive中建表语句为
create external table hive_test (key int,gid map&string,string&,sid map&string,string&,uid map&string,string&) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" ="a:,b:,c:")
TBLPROPERTIES
("hbase.table.name" = "test1");在hive中建立好表后,查询hbase中test1表内容Select * from hive_
OK1 {"":"qqq"} {"":"aaa"} {"":"bbb"}2 {"":"qqq"} {} {"":"bbb"}
查询gid字段中value值的方法为select gid[''] from hbase2;得到查询结果Total MapReduce jobs = 1Launching Job 1 out of 1Number of reduce tasks is set to 0 since there's no reduce operatorStarting Job = job__0017, Tracking URL = Kill Command = /opt/mapr/hadoop/hadoop-0.20.2/bin/../bin/hadoop job -Dmapred.job.tracker=maprfs:/// -kill job__0017 14:38:29,141 Stage-1 map = 0%, reduce = 0% 14:38:33,171 Stage-1 map = 100%, reduce = 100%Ended Job = job__0017OKqqqqqq
如果hbase表test1中的字段为user:gid,user:sid,info:uid,info:level,在hive中建表语句为create external table hive_test(key int,user map&string,string&,info map&string,string&) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" ="user:,info:")
TBLPROPERTIES
("hbase.table.name" = "test1");
查询hbase表的方法为select user['gid'] from hbase2;
浏览: 70021 次
来自: 哈尔滨
107x 写道 不错,谢谢!很早之前搞的,希望对你有用。
chwshuang 写道感觉哥们是做开发的,不是专门做测试的! ...
感觉哥们是做开发的,不是专门做测试的!因为我也深有体会!不知道 ...
不错,谢谢!
java操作MemCached demo实例教程源代码下载:h ...
(window.slotbydup=window.slotbydup || []).push({
id: '4773203',
container: s,
size: '200,200',
display: 'inlay-fix'

我要回帖

更多关于 hbase master opts 的文章

 

随机推荐