在Debian上使用HBase Shell,你需要先安装HBase。以下是详细的步骤:
HBase需要Java运行环境,首先确保你的系统上安装了Java。
sudo apt update
sudo apt install openjdk-11-jdk
验证Java安装:
java -version
从Apache HBase官方网站下载最新版本的HBase,并解压到你选择的目录。
wget https://archive.apache.org/dist/hbase/2.4.9/hbase-2.4.9-bin.tar.gz
tar -xzvf hbase-2.4.9-bin.tar.gz
sudo mv hbase-2.4.9 /usr/local/hbase
编辑HBase的配置文件/usr/local/hbase/conf/hbase-site.xml。
<configuration>
<property>
<name>hbase.rootdir</name>
<value>hdfs://localhost:9000/hbase</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/var/lib/zookeeper</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>localhost</value>
</property>
</configuration>
启动HBase Master和RegionServer。
cd /usr/local/hbase
start-hbase.sh
打开一个新的终端窗口,运行以下命令来验证HBase是否正常运行。
hbase shell
如果一切正常,你应该会看到HBase Shell的提示符:
hbase(main):001:0>
在HBase Shell中,你可以执行各种HBase操作,例如创建表、插入数据、查询数据等。
create 'my_table', 'cf1'
put 'my_table', 'row1', 'cf1:col1', 'value1'
get 'my_table', 'row1'
scan 'my_table'
disable 'my_table'
drop 'my_table'
当你完成操作后,可以停止HBase集群。
stop-hbase.sh
通过以上步骤,你可以在Debian上成功安装并使用HBase Shell。