1、HBase安装配置
(1)下载压缩包(选择与自己安装的Hadoop版本的兼容版本) 去官网下,选择稳定版hbase-1.4.9-bin.tar.gz,在Windows里面下载
(2)将压缩包从Windows传输到Linux当前目录下
SecureCRT 【File】→【Connect SFTP Session】开启sftp操作
(3)安装
解压安装到指定目录下/opt/module(/opt是系统自带目录,之下的/module是自己创建的)
(4)配置环境变量
在/etc/profile文件里添加HBase安装路径的配置信息,之后用source命令使配置生效。安装之后的目录为hbase-1.4.9,修改为hbase,所以HBase安装路径是/opt/module/hbase。
source /etc/profile配置生效 (基于上一个文档增加的内容)
测试HBase安装成功,命令hbase version,或hbase。
(5)修改配置信息
修改slaves里的内容,改成虚拟机的主机名
把zoo_sample.cfd文件名称改为zoo.cfg,
2、HBase伪分布式模式配置
配置文件位于HBase安装路径的conf目录(/opt/module/hbase/conf)下面
(1)配置Hbase-env.sh
设置Java,HBase,zookeeper安装路径
设置HBase的配置文件路径(/opt/module/hbase/conf)
采用HBase自带Zookeeper,设置参数true
(2)在eclipse里创建一个ExampleForHbase.java代码
(3)修改eclipse的内容
在【Properties】 里的【Java Build Path】 中【Libraries】添加【hbase-1.4.9】中【lib】的除了【slf4j-log4j12-1.7.10.jar】其它所有jar文件都要添加;并添加【conf】文件夹,把【hbase-1.4.9】中【conf】的【hbase-site.xml】添加到【conf】文件夹里。
把F:\大数据软件\hbase-1.4.9-bin\hbase-1.4.9\conf里的hbase-site.xml
文件复制到conf文件夹下
(4)配置hbase-site.xml,注:bigdata128,localhost改成虚拟机的主机名
<!--hbase共享目录,持久化hbase数据
<!--配置为core-site.xml 中的fs.defaultFS
<property>
<name>hbase.rootdir</name>
<value>hdfs://bigdata128:9000/hbase</value>
</property>
<!--分布式运行模式,false(默认)为单机模式-->
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<!--Zookeeper集群的地址列表,伪分布式用默认 localhst-->
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
(5)在TRC启动并运行HBase(之前启动Hadoop)
启动HBase,并jps查看!
start-all.sh
start-hbase.sh
zkServer.sh start
用完停止HBase运行(之后停止Hadoop)
3、进入HBase数据库
进入HBase的shell命令行模式
1、 创建表
2、 添加数据
3、查看数据
4 、删除数据
删除一个单元格
删除一行
删除表
4、运行Hbase的错误
WARN [main] zookeeper.ZooKeeperNodeTracker: Can’t get or delete the master znode
Will not attempt to authenticate using SASL (unknown error)
建表之后查看log报错
ERROR [main] client.ConnectionManager$HConnectionImplementation: Can't get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase
建表时报错
Can't get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase
重新停止、启动HBASE,查看logs,报错2019-04-04 10:41:52,238 INFO [M:0;bigdata128:35321-SendThread(localhost:2181)] zookeeper.ClientCnxn: Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
Hbase shell 运行status
报错2019-04-04 10:49:55,710 ERROR [main] client.ConnectionManager$HConnectionImplementation: Can’t get connection to ZooKeeper: KeeperErrorCode = ConnectionLoss for /hbase
启动hbase,报错:
ERROR [main] server.ZooKeeperServer: ZKShutdownHandler is not registered
ERROR [main] master.HMasterCommandLine: Master exiting
java.io.IOException: Could not start ZK at requested port of 2181. ZK was started at port: 2182. Aborting as clients (e.g. shell) will not be able to find this ZK quorum.
关闭防火墙 service iptables stop