具体请参见 https://blog.csdn.net/u011095110/article/details/83791734
#进入hadoop主目录
cd /hadoop
#下载zookeeper
wget http://mirrors.hust.edu.cn/apache/zookeeper/zookeeper-3.4.13/zookeeper-3.4.13.tar.gz
cd /hadoop/zookeeper-3.4.13/conf
cp zoo_sample.cfg zoo.cfg
dataDir为存储myid的地址,需要创建,server.1/2/3 myid就为对应的1,2,3
vim myid
1
dataDir=/hadoop/data
server.1=master.hadoop:2888:3888
server.2=slave1.hadoop:2888:3888
server.3=slave2.hadoop:2888:3888
在每个机器上进入/hadoop/zookeeper-3.4.13/bin并执行
./zkServer.sh start
[root@master bin]# ./zkServer.sh status
ZooKeeper JMX enabled by default
Using config: /hadoop/zookeeper-3.4.13/bin/../conf/zoo.cfg
Mode: leader
进入hadoop主目录
cd /hadoop/
下载hbase2.1.1
wget http://mirrors.hust.edu.cn/apache/hbase/2.1.1/hbase-2.1.1-bin.tar.gz
解压hbase2.1.1
tar -zxvf hbase-2.1.1-bin.tar.gz
hbase.master
hdfs://master.hadoop:60000
hbase.cluster.distributed
true
hbase.zookeeper.quorum
master.hadoop,slave1.hadoop,slave2.hadoop
hbase.zookeeper.property.dataDir
/hadoop/zookeeper-3.4.13
hbase.zookeeper.property.clientPort
2181
dfs.replication
1
hbase.unsafe.stream.capability.enforce
false
配置hbase.unsafe.stream.capability.enforce是解决下面的启动错误
Please check the config value of 'hbase.procedure.store.wal.use.hsync' to set the desired level of robustness and ensure the config value of 'hbase.wal.dir' points to a FileSystem mount that can provide it
slave1.hadoop
slave2.hadoop
2018-11-16 16:16:27,914 ERROR [main] regionserver.HRegionServer: Failed construction RegionServer
java.lang.NoClassDefFoundError: org/apache/htrace/SamplerBuilder
cd /hadoop/hbase-2.1.1/lib/client-facing-thirdparty
cp htrace-core-3.1.0-incubating.jar …/
cp htrace-core4-4.2.0-incubating.jar …/
[root@master bin]# jps
836 HMaster
29797 QuorumPeerMain
22150 ResourceManager
21976 SecondaryNameNode
21742 NameNode
10030 Jps
[root@slave2 conf]# jps
15889 HRegionServer
19364 Jps
26437 NodeManager
26333 DataNode
14574 QuorumPeerMain
//进入HBase Shell
[root@vnet ~] hbase shell
//查看当前HBase有哪些表
hbase(main):> list
//创建表t_user,cf1和cf2是列族,列族一般不超过3个
hbase(main):> create 't_user','name','password'
//获得表t_user的描述信息
hbase(main):> describe 't_user'
//禁用表
hbase(main):> disable 't_user'
//删除表,删除表之前要先把表禁用掉
hbase(main):> drop 't_user'
//查询表是否存在
hbase(main):> exists 't_user'
//查看全表数据
hbase(main):> scan 't_user'
//插入数据,分别是表名、key、列(列族:具体列)、值。HBase是面向列的数据库,列可无限扩充
hbase(main):> put 't_user' ,'001','cf1:name','chenxj'
hbase(main):> put 't_user' ,'001','cf1:age','18'
hbase(main):> put 't_user' ,'001','cf2:sex','man'
hbase(main):> put 't_user' ,'002','cf1:name','chenxj'
hbase(main):> put 't_user' ,'002','cf1:address','fuzhou'
hbase(main):> put 't_user' ,'002','cf2:sex','man'
//获取数据,可根据key、key和列族等进行查询
hbase(main):> get 't_user','001'
hbase(main):> get 't_user','002','cf1'
hbase(main):> get 't_user','001','cf1:age'