HBASE
Each user is allocated a namespace (a logical grouping of tables) where they create, modify and delete tables. The namespace id is identical to the username. If your enconter permission error, make sure your are using your own namespace instead of the default one.
SHELL
HBase shell allows user to interact with HBase in command line. To start HBase shell:
hbase shell
Option | Description |
---|---|
create '<username>:<tablename>' |
create a table named |
disable '<username>:<tablename>' |
disable the table named |
enable '<username>:<tablename>' |
enable the table named |
drop '<username>:<tablename>' |
delete the table named |
list |
List your tables |
get '<username>:<tablename>', '<rowid>' |
get all cells with key |
put '<username>:<tablename>', '<rowid>','<columnid>','value' |
insert value in cell with columnid |
scan '<username>:<tablename>', {STARTROW => '<startid>',STOPROW => '<stopid>',LIMIT => 10 } |
get at most 10 cells with key between |
help |
list all commands |
help '<command>' |
get documentation and examples for a command |
Programmatically
Java
HBase can also be interacted through its java interface. A Connection first needs to be created through ConnectionFactory createConnection method. The Connection instance may be used to get an Admin instance through its getAdmin method. Admin is used to create, disable, enable or drop a Table.
A Table may be obtained through Connection getTable method. A Table instance can be used for read (such as get or scan) or write operation (such as put).
An example of a MapReduce job reading a file on HDFS and inserting data into an HBase table is available on the University of Bordeaux GitLab forge.
REST API
HBase host a REST API. Available servers are listed here. The list of all url path are available here.
NODEJS
The hbase nodejs package may be used to interact with hbase through its REST API. An additional configuration needs to be set to use the platform authentification:
const hbase =require('hbase')
const krb5=require('krb5')
//create the js client object, giving the appropriate kerberos configuration
client = hbase({
host: 'lsd-prod-namenode-0.lsd.novalocal',
protocol: 'https',
port:8080,
krb5:{
service_principal: 'HTTP/lsd-prod-namenode-0.lsd.novalocal',//the actual server principal needs to be given to avoid an incorrect value inferred py the hbase package
principal:"<username>@LSD.NOVALOCAL"
}
})
//the client can now be used to interact with HBase, such as get the schema of an existing table :
client.table('<namespace>:<tablename>').schema(function(error, schema){
console.info(schema)
});
Note that, as the installation of the krb5
package includes the compilation of a binary library, it must be installed on the gateway. Copying the installation( directory node_modules/krb5
) from another machine is likely to cause issues regarding conflicting versions of the standard library.
Such an error might look like the following :
Error: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by <current_directory>/node_modules/krb5/build/Release/krb5.node)
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (<current_directory>/node_modules/krb5/lib/index.js:4:5)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12) {
code: 'ERR_DLOPEN_FAILED'
To install krb5
package on the gateway, you need to activate either devtoolset-7 (which is active by default) or devtoolset-11.
A basic example af an express server using these packages to query HBase is available on the University Gitlab Forge