OS版本:Centos 7.8
Hadoop版本:Hadoop 2.7.7
Hbase版本:hbase 1.4.13
Hadoop与Hbase版本对应关系:
1?Hadoop安装
https://blog.csdn.net/linwenhai2018/article/details/116026236
2?Hbase安装
cd /opt
wget https://mirrors.tuna.tsinghua.edu.cn/apache/hbase/1.4.13/hbase-1.4.13-bin.tar.gz
tar -zxvf hbase-1.4.13-bin.tar.gz
ln -s hbase-1.4.13 hbase
2.1 配置 hbase-site.xml
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://mycluster/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>hadoop03:hadoop04:hadoop05:2181</value>
</property>
</configuration>
2.2 配置 hbase-env.sh
# 设置使用hbase自带ZK
export JAVA_HOME=/opt/jdk
export HBASE_MANAGES_ZK=false
2.3 配置?regionservers
hadoop03
hadoop04
hadoop05
2.4 配置 backup-masters
hadoop02
2.5?拷贝Hadoop文件
cp /opt/hadoop/etc/hadoop/core-site.xml /opt/hbase/conf/
cp /opt/hadoop/etc/hadoop/hdfs-site.xml /opt/hbase/conf/
2.6 同步hbase目录到其他节点
2.7 配置环境变量
vi ~/.bashrc
##################################
export HBASE_HOME=/opt/hbase
export PATH=$PATH:$HBASE_HOME/bin
3 启停
bin/start-hbase.sh
226608 ResourceManager 225495 NameNode 226026 DFSZKFailoverController 254954 JobHistoryServer 259790 Jps 249804 HMaster
?223286 NodeManager 222964 DataNode 220795 JournalNode 246618 HRegionServer 122234 QuorumPeerMain 250414 Jps
浏览器访问:http://hadoop01:16010/
?
### 单独启动命令
hbase-daemon.sh start master
hbase-daemon.sh start regionserver
4?测试
bin/hbase shell
hbase(main):018:0> exit
# 查看所有表
hbase(main):001:0> list
# 创建表t1,列族为f1
hbase(main):002:0> create 't1',{NAME => 'f1'}
# 描述表信息
hbase(main):004:0> describe 't1'
# 测试写入数据
hbase(main):005:0> create 'test','c1','c2'
hbase(main):005:0>
put 'test','r1','c1:1','11'
put 'test','r1','c1:2','12'
put 'test','r1','c1:3','13'
put 'test','r1','c2:1','21'
put 'test','r1','c2:2','22'
put 'test','r2','c1:1','31'
put 'test','r2','c1:2','32'
hbase(main):014:0> scan 'test'
hbase(main):015:0> get 'test','r1',{COLUMN => 'c2:2'}
hbase(main):016:0> disable 'test'
hbase(main):017:0> drop 'test'
|