HBase Configuration and connection HBase settings under Windows

Source: Internet
Author: User
Tags zookeeper

This article describes the installation of HBase in stand-alone mode in a Linux environment, and the related settings for connecting hbase when developing with eclipse under Windows.

1, install the Linux system (Ubuntu 10.04server) installation, please install the additional open ssh-server. Machine Name: Ubuntu (Cat/etc/hostname, the result is Ubuntu)

2, install Java, set environment variables. Append the following three lines to the end of the/etc/profile.

Exportjava_home= "/home/had/jdk1.6.0_20"

Exportclasspath=.: $CLASSPATH: $JAVA _home/lib

Export path=.: $PATH: $JAVA _home/bin

Where Java_home is pointing to the Java installation directory

3, SSH upload hbase-0.90.4.tar.gz to/home/had directory. Tar xzf hbase-0.90.4.tar.gz Decompression

4, enter hbase-0.90.4 directory, edit Conf/hbase-site.xml file, add in configuration:

<property>

<name>hbase.rootdir</name>

<value>/home/had/hbase-0.90.4/data</value>

</property>

The purpose is to set the data store path in the directory specified by value

5, Linux Ubuntu 10.04 server./etc/hosts

A) Comment out 127.0.1.1 ubuntu.localdomain ubuntu

b Add a line 192.168.128.128 Ubuntu

I. 192.168.128.128 is a native IP

Ii. Ubuntu is the machine name

6, Test HBase:

A) CD hbase-0.90.4

b) bin/start-hbase.sh

c) Bin/hbase Shell

D create ' database ', ' CF '

e) List

f) If successful you can see the following results:

HBase (main): 001:0>list

table                                                                                                                                                                                      

database                                                                                                                                                                                   

1 row (s) in 0.5910 seconds

HBase (Main):002:0>

Http://192.168.128.128:60010/master.jsp This page can also see the appropriate information

7. Windows c:/windows/system32/dirvers/hosts file plus one line:

192.168.128.128 Ubuntu

Enables Windows to resolve Ubuntu to IP addresses 192.168.128.128

8. Open Eclipse, create a new project, copy the Lib directory below hbase-0.90.4 to the project, and add the jar package to the Classpath

9, a new type of hellohbase:

Package demo;


Import java.io.IOException;


Import org.apache.hadoop.conf.Configuration;
Import org.apache.hadoop.hbase.HBaseConfiguration;
Import Org.apache.hadoop.hbase.HColumnDescriptor;
Import Org.apache.hadoop.hbase.HTableDescriptor;
Import Org.apache.hadoop.hbase.client.HBaseAdmin;
Import org.apache.hadoop.hbase.util.Bytes;


public class Hellohbase {
public static void Main (string[] args) throws IOException {
Configuration conf = hbaseconfiguration.create ();
Conf.set ("Hbase.zookeeper.quorum", "192.168.128.128");
Hbaseadmin admin = new hbaseadmin (conf);
Htabledescriptor tabledescriptor = Admin.gettabledescriptor (bytes.tobytes ("Database"));
byte[] name = Tabledescriptor.getname ();
System.out.println (new String (name));
hcolumndescriptor[] columnfamilies = Tabledescriptor.getcolumnfamilies ();
for (Hcolumndescriptor d:columnfamilies) {
System.out.println (D.getnameasstring ());
}
}
}

Run, you should print the following two lines at this time:

Database

Cf

If not, the configuration fails, please check the other settings.

Of these, the 5th, 7 steps and Conf.set in the code ("Hbase.zookeeper.quorum", "192.168.128.128"); Determines whether you can connect hbase on Windows.

Resources:

HBase Official Document: http://hbase.apache.org/book/quickstart.html

HBase Chinese Document: http://www.yankay.com/wp-content/hbase/book.html

Resolve references when other machines are using Eclipse development connection HBase exception: http://hi.baidu.com/laozhenghit/blog/item/987608440c76d5146a63e523.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.