This article describes how to install hbase in standalone mode in Linux and how to connect to hbase during development using eclipse in windows.
1. Install the Linux system (Ubuntu 10.04 server) and install the additional open SSH-server. Machine name: ubuntu (CAT/etc/hostname, the result is UBUNTU)
2. install Java and set environment variables. Append the following three rows to the end of/etc/profile.
Exportjava_home = "/home/had/jdk1.6.0 _ 20"
Exportclasspath =.: $ classpath: $ java_home/lib
Export Path =.: $ path: $ java_home/bin
Java_home points to the Java installation directory.
3. Upload hbase-0.90.4.tar.gz to the/home/had directory on ssh. Tar xzf hbase-0.90.4.tar.gz unzip
4. Enter the hbase-0.90.4 directory, edit the conf/hbase-site.xml file, and add the following in the Configuration:
<Property>
<Name> hbase. rootdir </Name>
<Value>/home/had/hbase-0.90.4/Data </value>
</Property>
Set the data storage path to 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 of 192.168.128.128 Ubuntu
I. 192.168.128.128 is the IP address of the local machine.
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 it succeeds, the following results are displayed:
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
7. Add a line to the Windows C:/Windows/system32/dirvers/hosts file:
192.168.128.128 Ubuntu
Enables Windows to resolve Ubuntu to the IP address 192.168.128.128
8. Open eclipse, create a new project, copy the lib directory under the hbase-0.90.4 to the project, add the jar package to classpath
9. Create 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:
Database
Cf
If no, the configuration fails. Check other settings.
Among them, steps 5th and 7 and the conf. Set ("hbase. zookeeper. Quorum", "192.168.128.128") in the Code are crucial. Determines whether hbase can be connected to Windows.
References:
Hbase official documentation: http://hbase.apache.org/book/quickstart.html
Hbase Chinese document: http://www.yankay.com/wp-content/hbase/book.html
To solve the problem of other machines using eclipse to develop a connection to hbase when an exception occurs: http://hi.baidu.com/laozhenghit/blog/item/987608440c76d5146a63e523.html