here is a quick tutorial to setup hbase instance and hook up with a basic coprocessor.
Download the tar file and unzip it from http://mirror.tcpdiag.net/apache/hbase/hbase-0.94.11/
Change the Hbase-site.xml, point the hbase.rootdir to the local folder, by default Hbase will load the default one embedded in the hbase-x.jar, and default setting is local temp folder,
change it to a folder you fell comfortable,
also change the hbase.temp.dir to a well know folder, you can see all the underlying folder it used,
My final change,
then you can start the hbase server ./bin/start-hbase.sh
check the port it listened, should be a port called 60030
then you can go the http://ip:60030 to see the hbase console of the given region. and 60010 for the hbase master
then create a table and put a record
check the folder
Now let’s write a basic java program to read the data in hbase.
Create a new maven project by clicking the eclipse wizard,
Click the pom.xml, right click to add one dependency hbase.
Simple Query in another server, make sure the zookeeper ip and host name are accessible from client machine,
for the coprocessor, they are bascailly observers in 3 levels.
Master level, you can hookup with all the DDL like create table,update column,etc (check BaseMasterObserver)
and DML level in the region servers,
And WAL level, all changes going to WAL, basically you can see all the changes. you can even reject the change
I will put the WALobserver as a example, just dump out any changes to the cluseter, we can send the changeset to another server do secondary indexing, or for logging /auditing purpose.
compile and package it to a jar file,then copy to the hbase lib folder, or any folder which is in the HBASE_CLASSPATH
then change hbase-site.xml, point to our WALobserver
then restart the instance, from the region server, you can see our WAL is loaded,
then make some changes to the data,
from the log, you should see our logging , data changes captured here
Please note the WALobserver runs in the same JVM of the hbase, make sure not fail safe and no huge extra performance hit.
No comments:
Post a Comment