GithubHelp home page GithubHelp logo

younes-abouelnagah / vagrant-hbase Goto Github PK

View Code? Open in Web Editor NEW

This project forked from zsiciarz/vagrant-hbase

0.0 1.0 0.0 161 KB

A Vagrantfile to get up and running with Hadoop and HBase development.

License: MIT License

Ruby 7.48% Python 20.90% Shell 71.62%

vagrant-hbase's Introduction

vagrant-hbase

A Vagrantfile to get up and running with Hadoop and HBase development.

Overview

The aim of this project is to set up a virtual machine ready for Hadoop and HBase development in just a few minutes. The VM is a Ubuntu 14.04 (trusty) box, which is provisioned with Ansible.

After running vagrant up, a single HBase node is set up in pseudo-distributed mode, running on a single-node Hadoop HDFS filesystem. A Thrift server is also running, allowing access from languages outside of the JVM.

Getting started

  1. install Ansible 1.4 or newer on your host machine
  2. git clone https://github.com/zsiciarz/vagrant-hbase.git && cd vagrant-hbase && vagrant up
  3. ????
  4. PROFIT!

Network and ports

The guest machine has a private IP address 192.168.15.166. HBase-related ports are forwarded according to the following rule:

hostPortNumber = guestPortNumber + 100

For example, HBase web UIs are available from the host machine at http://127.0.0.1:60110 (Master) and http://127.0.0.1:60130 (RegionServer).

Hadoop

Hadoop 2 is installed by default. If the following commands work, Hadoop is successfully running.

vagrant ssh
cd hadoop/
echo 'Hello world!' | ./bin/hadoop fs -put - hello.txt
./bin/hadoop fs -cat /user/vagrant/hello.txt

Initial data

The create_test_table.rb file can be loaded into HBase shell to define a dead simple test table with one column family cf. The table looks like this:

+--------+-----------+-----------+
| rowkey |  cf:col1  |  cf:col2  |
+========+===========+===========+
|  row1  |   value1  |
+--------+-----------+
|  row2  |   value2  |
+--------+-----------+-----------+
|  row3  |           |   value3  |
+--------+           +-----------+

To load the data, execute:

vagrant ssh
cd hbase/
./bin/hbase shell /vagrant/data/create_test_table.rb

Jython

A Jython interpreter is also installed in the VM. To access Java HBase API from Jython, you need to set the CLASSPATH environment variable correctly. HBase CLI tool can help in that matter.

vagrant ssh
cd hbase/
export CLASSPATH=`./bin/hbase classpath`
jython

This should drop you into Jython REPL where you can import Java classes and use them in a more Pythonic way. An example script that reads the data loaded with create_test_table.rb is at /vagrant/test.py.

Python and HappyBase

An alternative approach to access HBase from Python is to use a regular (CPython) interpreter and Thrift bindings. A Python library called HappyBase hides away all the necessary plumbing behind a simple, clean interface to your data. For your convenience, this package is installed into system-wide Python libraries when provisioning the guest machine.

An example Python session on the guest machine may look like this (assuming initial data were loaded):

vagrant@vagrant-hbase:~$ python
Python 2.7.3 (default, Apr 10 2013, 05:46:21)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import happybase
>>> conn = happybase.Connection()
>>> print conn.tables()
['test']
>>> table = conn.table('test')
>>> print table.row('row1')
{'cf:col1': 'value1'}

Author

License

This work is released under the MIT license. A copy of the license is provided in the LICENSE file.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.