To set up a functional HBase cluster across three Ubuntu servers and insert sample data, follow this guide. The setup assumes the following IP addresses:
- Master node:
192.168.1.101 - RegionServer nodes:
192.168.1.102,192.168.1.103
1. System Preparation
On all three machines, begin by updating the system and installing Java:
sudo apt update && sudo apt upgrade -y
sudo apt install openjdk-8-jdk -y
Confirm the Java installation:
java -version
2. Install HBase
On the master node (192.168.1.101), download and extract HBase:
wget https://archive.apache.org/dist/hbase/2.4.10/hbase-2.4.10-bin.tar.gz
tar -xzf hbase-2.4.10-bin.tar.gz
sudo mv hbase-2.4.10 /usr/local/hbase
Copy the HBase directory to the other two nodes:
scp -r /usr/local/hbase user@192.168.1.102:/usr/local/
scp -r /usr/local/hbase user@192.168.1.103:/usr/local/
3. Configure Environment Variables
Add the following lines to ~/.bashrc on all nodes:
export HBASE_HOME=/usr/local/hbase
export PATH=$PATH:$HBASE_HOME/bin
Reload the shell configuraton:
source ~/.bashrc
4. Set Up SSH Key-Based Authentication
On the master node, generate an SSH key pair (if not already present):
ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
Distribute the public key to all nodes:
ssh-copy-id user@192.168.1.101
ssh-copy-id user@192.168.1.102
ssh-copy-id user@192.168.1.103
5. Configure HBase
Edit $HBASE_HOME/conf/hbase-site.xml on all nodes with the following content:
<configuration>
<property>
<name>hbase.rootdir</name>
<value>file:///usr/local/hbase/data</value>
</property>
<property>
<name>hbase.zookeeper.quorum</name>
<value>192.168.1.101</value>
</property>
<property>
<name>hbase.cluster.distributed</name>
<value>true</value>
</property>
</configuration>
Create or edit $HBASE_HOME/conf/regionservers on all nodes and list the RegionServer hostnames or IPs:
192.168.1.102
192.168.1.103
6. Start the Cluster
On the master node, start HBase:
$HBASE_HOME/bin/start-hbase.sh
This command starts the HMaster, ZooKeeper, and any local RegionServer. Remote RegionServers must be started manually on each node:
# On 192.168.1.102 and 192.168.1.103:
$HBASE_HOME/bin/hbase-daemon.sh start regionserver
7. Insert and Query Data
Launch the HBase shell on the master:
$HBASE_HOME/bin/hbase shell
Create a table with one column family:
create 'users', 'info'
Insert sample records:
put 'users', 'user001', 'info:name', 'Alice'
put 'users', 'user001', 'info:email', 'alice@example.com'
put 'users', 'user002', 'info:name', 'Bob'
Rertieve data:
get 'users', 'user001'
scan 'users'
8. Monitor the Cluster
Access the HBase Web UI at:
http://192.168.1.101:16010