下面给你一份在 CentOS 上部署 HBase(单机 / 伪分布式)的实用步骤,适合学习和测试。如果你需要完全分布式(多节点),我也可以补充。
yum install -y java-1.8.0-openjdk-devel
java -version
hostnamectl set-hostname hbase-node
以 HBase 2.4.x 为例:
cd /opt
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 hbase
vi /etc/profile
添加:
export HBASE_HOME=/opt/hbase
export PATH=$PATH:$HBASE_HOME/bin
生效:
source /etc/profile
hbase-env.shvi $HBASE_HOME/conf/hbase-env.sh
关键配置:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0
export HBASE_MANAGES_ZK=true
hbase-site.xml<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///opt/hbase/data</value>
</property>
<property>
<name>hbase.zookeeper.property.dataDir</name>
<value>/opt/hbase/zookeeper</value>
</property>
</configuration>
前提:Hadoop 已启动
<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.quorum</name>
<value>localhost</value>
</property>
</configuration>
start-hbase.sh
检查进程:
jps
应看到:
Web 界面:
http://<ip>:16010
hbase shell
create 'test', 'cf'
put 'test', 'row1', 'cf:name', 'zhangsan'
scan 'test'
stop-hbase.sh
firewall-cmd --add-port=16010/tcp --permanent
firewall-cmd --reload
伪分布式必须先:
start-dfs.sh
如果你需要:
告诉我你的使用场景,我可以直接给你完整方案。