Prerequisites
Server Specifications
- Cloud Instance: Basic tier (pay-as-you-go)
- Operating System: Linux CentOS 6.8
- CPU: 1 core
- Memory: 1GB
- Storage: 40GB
Software Stack
- Java Development Kit: Version 1.8 (jdk-8u144-linux-x64.tar.gz)
- Apache Hadoop: Version 2.8.2 (hadoop-2.8.2.tar.gz)
- Apache HBase: Version 1.2.6 (hbase-1.2.6-bin.tar.gz)
Download Sources
Official Websites:
- JDK: http://www.oracle.com/technetwork/java/javase/downloads
- Hadoop: http://www.apache.org/dyn/closer.cgi/hadoop/common
- HBase: http://mirror.bit.edu.cn/apache/hbase/
System Configuration
Hostname Configuration
Begin by setting up the hostname for easier management.
Check current hostname:
hostname
Edit the network configuration file:
vim /etc/sysconfig/network
Modify the HOSTNAME parameter to your desired name.
Note: Reboot the system for changes to take effect.
Update the hosts file:
vim /etc/hosts
Add IP address and corresponding hostname mappings.
Note: This mapping is essential when using hostnames in configuration files!
Firewall Management
Disable firewall for etxernal access:
For CentOS 7 and below:
service iptables stop
For CentOS 7 and above:
systemctl stop firewalld.service
Time Synchronization
Verify server time consistency:
date
Adjust time if necessary:
date -s 'MMDDhhmmYYYY.ss'
HBase Installation Process
HBase Package Extraction
Extract the downloaded HBase archive:
tar -xvf hbase-1.2.6-bin.tar.gz
Move to designated directory:
mv hbase-1.2.6 /home/hbase
Environment Setup
System Variables Configuration
Edit the profile file /etc/profile and add:
export HBASE_HOME=/home/hbase/hbase-1.2.6
export PATH=.:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HBASE_HOME}/bin:$PATH
Apply the configuration:
source /etc/profile
Verify installation:
hbase version
Directory Structure Creation
Create necessary directories:
mkdir /root/hbase
mkdir /root/hbase/temp_data
mkdir /root/hbase/process_ids
Navigate to configuration directory:
/home/hbase/hbase-1.2.6/conf
hbase-env.sh Modification
Edit hbase-env.sh and include these settings:
export JAVA_HOME=/home/java/jdk1.8
export HADOOP_HOME=/home/hadoop/hadoop2.8
export HBASE_HOME=/home/hbase/hbase-1.2.6
export HBASE_CLASSPATH=/home/hadoop/hadoop2.8/etc/hadoop
export HBASE_PID_DIR=/root/hbase/process_ids
export HBASE_MANAGES_ZK=false
Explanation: Adjust paths according to your setup. HBASE_MANAGES_ZK=false disables HBase's built-in Zookeeper cluster.
hbase-site.xml Configuration
Edit hbase-site.xml within <configuration> tags:
<!-- Storage directory -->
<property>
<name>hbase.rootdir</name>
<value>hdfs://test1:9000/hbase</value>
<description>The directory shared by region servers.</description>
</property>
<!-- HBase port -->
<property>
<name>hbase.zookeeper.property.clientPort</name>
<value>2181</value>
<description>Property from ZooKeeper's config zoo.cfg. The port at which the clients will connect.</description>
</property>
<!-- Timeout duration -->
<property>
<name>zookeeper.session.timeout</name>
<value>120000</value>
</property>
<!-- Zookeeper cluster configuration -->
<property>
<name>hbase.zookeeper.quorum</name>
<value>test1</value>
</property>
<property>
<name>hbase.tmp.dir</name>
<value>/root/hbase/temp_data</value>
</property>
<!-- Mode selection: false=single node, true=distributed -->
<property>
<name>hbase.cluster.distributed</name>
<value>false</value>
</property>
Explanation: hbase.rootdir serves as the shared directory for region servers, enabling HBase persistence. hbase.cluster.distributed determines operational mode. When set to false, HBase and Zookeeper run within the same JVM.
Starting HBase Service
After successfully starting Hadoop:
Navigate to HBase bin directory:
cd /home/hbase/hbase-1.2.6/bin
Start HBase:
./start-hbase.sh
Access the web interface at:
http://39.108.208.105:16010/
Successful deployment displays the HBase management interface.
HBase Shell Operations
Access HBase shell:
hbase shell
List existing tables:
list
Since HBase uses columnar storage, table creation differs from traditional relational databases.
Create a user table t_user with two column families cf1 and cf2:
create 't_user', 'cf1', 'cf2'
Insert data into the table:
put 't_user', '1001', 'cf1:age', '18'
put 't_user', '1001', 'cf2:name', 'john_doe'
Scan table contents:
scan 't_user'
View table schema:
describe 't_user'
Delete specific record:
delete 't_user', '1001', 'cf1:age'
Remove entire table: First disable the table:
disable 't_user'
Then drop it:
drop 't_user'