1.安装

前提条件成功启动zk集群,hdfs,yarn
通过hbase官网下载jar包

1.1hbase-env.sh修改

  1. export JAVA_HOME= 系统jdk安装目录
  2. export HBASE_MANAGES_ZK=false
  3. #export HBASE_MASTER_OPTS。。。。
  4. #export HBASE_REGIONSERVER_OPTS。。。

1.2hbase-size.xml

  1. <property>
  2. <name>hbase.rootdir</name>
  3. <value>hdfs://hadoop101:9000/hbase</value>
  4. </property>
  5. <property>
  6. <name>hbase.cluster.distributed</name>
  7. <value>true</value>
  8. </property>
  9. <!-- 0.98后的新变动,之前版本没有.port,默认端口为60000 -->
  10. <property>
  11. <name>hbase.master.port</name>
  12. <value>16000</value>
  13. </property>
  14. <property>
  15. <name>hbase.zookeeper.quorum</name>
  16. <value>hadoop101:2181,hadoop102:2181,hadoop103:2181</value>
  17. </property>
  18. <property>
  19. <name>hbase.zookeeper.property.dataDir</name>
  20. <value>/module/zookeeper3.6/zdata</value>
  21. </property>

1.3regionservers

  1. hadoop101
  2. hadoop102
  3. hadoop103

1.4建立软连接

ln -s /module/hadoop2.6/etc/hadoop/core-site.xml /module/hbase1.6/conf/core-site.xml
ln -s /module/hadoop2.6/etc/hadoop/hdfs-site.xml /module/hbase1.6/conf/hdfs-site.xml

1.5启动

  1. #启动方式1
  2. bin/hbase-daemon.sh start master
  3. bin/hbase-daemon.sh start regionserver
  4. #启动方式2
  5. bin/start-hbase.sh
  6. bin/stop-hbase.sh
  7. #页面访问
  8. http://hadoop102:60010/master-status

2.shell操作

  1. bin/hbase shell
  2. help
  3. list
  4. create 'student','info'
  5. put 'student','1001','info:sex','male'
  6. put 'student','1001','info:age','18'
  7. put 'student','1002','info:name','Janna'
  8. put 'student','1002','info:sex','female'
  9. put 'student','1002','info:age','20'
  10. scan 'student'
  11. scan 'student',{STARTROW => '1001', STOPROW => '1001'}
  12. scan 'student',{STARTROW => '1001'}
  13. describe 'student'
  14. put 'student','1001','info:name','Nick'
  15. put 'student','1001','info:age','100'
  16. get 'student','1001'
  17. get 'student','1001','info:name'
  18. count 'student'
  19. #删除某rowkey的全部数据
  20. deleteall 'student','1001'
  21. #删除某rowkey的某一列数据
  22. delete 'student','1002','info:sex'
  23. truncate 'student' #清空表的操作顺序为先disable,然后再truncate。
  24. disable 'student'
  25. drop 'student'
  26. alter 'student',{NAME=>'info',VERSIONS=>3}
  27. get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}
  28. 中文输出问题
  29. scan 'WATER_BILL',{LIMIT=> 3, FORMATTER=>'toString'}
  30. 导入导出
  31. 导入语法格式:
  32. hbase org.apache.hadoop.hbase.mapreduce.Import 表名 hdfs的数据所在路径
  33. 操作案例:
  34. hbase org.apache.hadoop.hbase.mapreduce.Import WATER_BILL /water_bill/output_ept_10w/part-m-00000_10w
  35. 导出语法格式:
  36. hbase org.apache.hadoop.hbase.mapreduce.Export 表名 导出hdfs的路径