在 CentOS 上“连接 HBase”通常有两种场景:
下面分别说明,最常用的是第一种。
# 下载 HBase(版本要和 HBase 服务端一致)
wget https://archive.apache.org/dist/hbase/2.4.17/hbase-2.4.17-bin.tar.gz
tar -zxvf hbase-2.4.17-bin.tar.gz
mv hbase-2.4.17 /opt/hbase
编辑:
vi /opt/hbase/conf/hbase-site.xml
最小配置示例:
<configuration>
<property>
<name>hbase.zookeeper.quorum</name>
<value>hbase-host1,hbase-host2,hbase-host3</value>
</property>
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
</property>
</configuration>
/opt/hbase/bin/hbase shell
连接成功后:
status
list
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>2.4.17</version>
</dependency>
Configuration config = HBaseConfiguration.create();
config.set("hbase.zookeeper.quorum", "hbase-host1");
config.set("hbase.zookeeper.property.clientPort", "2181");
Connection conn = ConnectionFactory.createConnection(config);
Admin admin = conn.getAdmin();
System.out.println(admin.listTables());
适合测试:
# 配置 JAVA_HOME
vi /opt/hbase/conf/hbase-env.sh
export JAVA_HOME=/usr/java/jdk1.8.0_xxx
# 启动
/opt/hbase/bin/start-hbase.sh
# 进入 shell
/opt/hbase/bin/hbase shell
单机模式使用本地文件系统,不需要 Hadoop
systemctl stop firewalld
telnet hbase-host 2181
HBase 客户端和服务端大版本必须一致
需要:
kinithbase-site.xml 配置 hbase.security.authentication=kerberos如果你能告诉我:
我可以给你更精确的命令和配置。