In this tutorial, we will learn how to setup and start the HBase server in Standalone mode. Usually, we would require to run Standalone mode during the development phase and it’s not recommended for a production environment.
- You should have Java 8 or later installed on your system
- Hbase Installation
In this tutorial, we consider you already have a Java and HBase installed on your system and reset of the sections provides a step-by-step guide of setting up HBase in standalone mode.
We can also run HBase in Pseudo-distribution mode – where it runs all HBase services (Master, RegionServers and Zookeeper) in a single node but each service in its own JVM. and Cluster mode – Where all services run in different nodes; this would be used for production.
Regardless of which environment you wanted to setup and run HBase, you would require to edit
conf/hbase-env.sh file and set JAVA_HOME to the Java installation location as shown below.
HBase Standalone Configuration setup
As mentioned earlier, Standalone setup is usually used for the development environment and runs on single-node with all Hbase services (Master, RegionServers and Zookeeper) running on single JVM and stores data to the local filesystem.
HBase needs a directory location to store the HBase and Zookeeper files; you should configure the location by editing
conf/hbase-site.xml file. When not specified, it automatically creates directories under /tmp directory. The following configuration will store HBase’s data in the /Users/hbaseuser/hbase directory and Zookeeper files at /Users/hbaseuser/zookeeper
<configuration> <property> <name>hbase.rootdir</name> <value>file:///Users/hbaseuser/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/Users/hbaseuser/zookeeper</value> </property> <property> <name>hbase.unsafe.stream.capability.enforce</name> <value>false</value> </property> </configuration>
hbase.rootdir in the above example points to a directory in the local filesystem. The ‘file://‘ prefix is how we denote local filesystem. In case if you wanted to run Standalone Hbase on HDFS, configure
hbase.rootdir property to
hdfs://namenode.example.org:8020/hbase. In order to use HDFS, you should have Apache Hadoop Installed and run on your cluster.
Starting HBase server
HBase binary comes with bin/start-hbase.sh script to start HBase server. By running this script, you should see below output.
system:bin hbaseuser$ ./start-hbase.sh running master, logging to /Users/hbaseuser/Applications/hbase-2.2.0/bin/../logs/hbase-hbaseuser-master-system.out
jps command to verify HMaster service running – which denotes HMaster, single HRegionServer and Zookeeper services are running in single JVM.
system:bin hbaseuser$ jps 16360 HMaster 54027 16860 Jps
Now, Access http://localhost:16010 from browser to view the HBase Web UI.
Connect to Server Using HBase Shell
HBase distribution comes with “hbase shell” command to interact with HBase server. This comes in handy when you need to manually run commands like creating a table, truncating table, configuration e.t.c
system:bin hbaseuser$ ./hbase shell 2019-08-22 12:44:29,966 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable HBase Shell Use "help" to get list of supported commands. Use "exit" to quit this interactive shell. For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell Version 2.2.0, rUnknown, Tue Jun 11 04:30:30 UTC 2019 Took 0.0017 seconds hbase(main):001:0>
Ignore the WARNING for now. This disappears when you run HBase on Hadoop cluster.
Now enter ‘help’ on hbase shell to know all commands by the group.