Ubuntu under HBase Installation

Source: Internet
Author: User
Tags apache download eval table name versions zookeeper hadoop fs
1.2. Quick Start-standalone HBase

This guide describes setup of a standalone HBase instance running against the local filesystem. This isn't an appropriate configuration for a production instance of HBase, but would allow you to experiment with HBase. This section shows the Create a table in HBase using the HBase shell CLI, insert rows into the table, perform put a ND scan operations against the table, enable or disable the table, and start and stop HBase. Apart from downloading HBase, this procedure should take less than.
Local Filesystem and durability
The below advice is to HBase 0.98.2 and earlier releases only. This is a fixed in HBase 0.98.3 and beyond. See HBASE-11272 and HBASE-11218.
Using HBase with a local filesystem does not guarantee durability. The HDFS local filesystem implementation would lose edits if files is not properly closed. This was very likely to happen if you were experimenting with new software, starting and stopping the daemons often and no T always cleanly. You need to run HBase in HDFS to ensure all writes is preserved. Running against the local filesystem is intended as a shortcut to get you familiar with how the general system works, as T He very first phase of evaluation. SEEHTTPS://ISSUES.APACHE.ORG/JIRA/BROWSE/HBASE-3696 and its associated issues for more details about the issues of running On the local filesystem.
Loopback ip-hbase 0.94.x and earlier
The below advice is for hbase-0.94.x and older versions only. This is a fixed in hbase-0.96.0 and beyond.
Prior to HBase 0.94.x, HBase expected the loopback IP address to be 127.0.0.1. Ubuntu and some other distributions default to 127.0.1.1 and this would cause problems for you. See why does HBase care about/etc/hosts? For detail.
Example 1.1. Example/etc/hosts File for Ubuntu

When setting the native address, is the use of localhost or 127.0.0.1, need to see vi/etc/hosts, is how to declare, if it is 127.0.0.1 localhost You should use 127.0.0.1, if you use Localhost,hbase, you will receive an error

The following/etc/hosts file works correctly for HBase 0.94.x and earlier, on Ubuntu. Use the as a template if you run into trouble.

127.0.0.1 localhost
127.0.0.1 ubuntu.ubuntu-domain ubuntu
1.2.1. JDK Version Requirements

HBase requires that a JDK is installed. See Table 2.1, "Java" For information about supported JDK versions. 1.2.2. Get Started with HBase

Procedure 1.1. Download, Configure, and Start HBase
Choose a Download site from this list of Apache Download mirrors. Click on the suggested top link. This would take a mirror of HBase releases. Click on the folder named stable and then download the binary file, the ends in. tar.gz to your local filesystem. Be sure to choose the version, that corresponds and the version of Hadoop you is likely to use later. In most cases, should choose the file for Hadoop 2, which would be called something like HBASE-0.98.3-HADOOP2-BIN.TAR.G Z. Download the file ending in src.tar.gz for now.
Extract The downloaded file, and change to the newly-created directory.
Tarxzvfhbase−<?eval tar xzvf hbase-{project.version}?>-hadoop2-bin.tar.gz
Cdhbase−<?eval cd hbase-{ project.version}?>-hadoop2/

For HBase 0.98.5 and later, you is required to set the JAVA_HOME environment variable before starting HBase. Prior to 0.98.5, HBase attempted to detect the location of Java if the variables is not set. You can set the variable via your operating system ' s usual mechanism, but HBase provides a central mechanism, CONF/HBASE-E nv.sh. Edit This file, uncomment the line starting Withjava_home, and set it to the appropriate location for your operatin G System. The java_home variable should is set to a directory which contains the executable file Bin/java. Most modern Linux operating systems provide a mechanism, such as/usr/bin/alternatives on RHEL or CentOS, for Transparentl Y switching between versions of executables such as Java. In this case, you can setjava_home to the directory containing the symbolic link to Bin/java, and which is usually/usr.
Java_home=/usr
Note
These instructions assume that each node of your cluster uses the same configuration. If This isn't the case, you could need to set java_home separately for each node.
Edit Conf/hbase-site.xml, which is the main hbase configuration file. At this time, you have need to specify the directory on the local filesystem where HBase and Zookeeper write data. By default, a new directory is created Under/tmp. Many servers is configured to delete the contents of/tmp upon reboot, so you should store the data elsewhere. The following configuration would store HBase ' s data in the HBase directory, in the home directory of the user called Testu Ser. Paste the tags beneath the tags, which should is empty in a new HBase install.

Edit the main configuration file Conf/hbase-site.xml for HBase. At this point, you need to indicate the folder where HBase and zookeeper write data. By default, a new file is created to/tmp. Because many services are configured to delete content under TMP, it's a good idea to put the data somewhere else.

Example 1.2. Example Hbase-site.xml for Standalone hbase

<configuration>
  <property>
    <name>hbase.rootdir</name>
    <value>file:// /home/testuser/hbase</value>
  </property>
  <property>
    <name> hbase.zookeeper.property.datadir</name>
    <value>/home/testuser/zookeeper</value>
  < /property>
</configuration>              

You don't need to create the HBase data directory. HBase would do the for you. If you create the directory, HBase would attempt to does a migration, which is isn't what you want.
The bin/start-hbase.sh script is provided as a convenient-to-start hbase. Issue the command, and if all goes well, a message was logged to standard output showing that HBase started successfully. You can use the JPS command to verify so you have one running process called Hmaster. In standalone mode HBase runs all daemons within this single JVM, i.e. the Hmaster, a single hregionserver, and the Zookee Per daemon.
Note
Java needs to is installed and available. If you get an error indicating the Java is isn't installed, but it's on your system, perhaps in a non-standard location, E DIT theconf/hbase-env.sh file and modify the Java_home setting to the directory, that contains Bin/java your syste M.
Procedure 1.2. Use HBase for the first time
Connect to HBase.
Connect to your running instance of HBase using the HBase shell command, located in the bin/directory of your HBase Insta ll. In this example, some usage and version information which is printed when you start HBase Shell have been omitted. The HBase Shell prompt ends with a > character.
Enter into the HBase shell and use the HBase script to manipulate the table

$./bin/hbase Shell

Display HBase Shell help Text.
Type Help and press Enter, to display some basic usage information for HBase Shell, as well as several example commands. Notice that table names, rows, columns all must is enclosed in quote characters.
Create a table.
Use the Create command to create a new table. You must specify the table name and the columnfamily name.

Create a table with a database named TEST,CF as the name of the column

hbase> create ' test ', ' CF '    
0 row (s) in 1.2200 seconds

List information about your Table
Use the list command to

Display a table with the name test

hbase> list ' test '
TABLE
test
1 row (s) in 0.0350 seconds

= ["Test"]

Put data into your table.
Put data into your table with the put command.

hbase> put ' test ', ' row1 ', ' cf:a ', ' value1 '
0 row (s) in 0.1770 seconds

hbase> put ' test ', ' row2 ', ' cf:b ', ' V Alue2 '
0 row (s) in 0.0160 seconds

hbase> put ' test ', ' row3 ', ' cf:c ', ' Value3 '
0 row (s) in 0.0260 seconds          

Here, we insert three values, one at a time. The first insert is at Row1, column cf:a, with a value of value1. Columns in HBase is comprised of a column family prefix, cf in this example, followed by a colon and then a column Qualif Ier suffix, a in the case.
Scan the table for all data at once.
One of the ways to get data from HBase are to scan. Use the Scan command to scan the table for data. You can limit your scan, but for now, all data is fetched.

hbase> Scan ' test '
ROW                   column+cell
 row1                 column=cf:a, timestamp=1403759475114, value=value1
 Row2                 column=cf:b, timestamp=1403759492807, value=value2
 row3                 column=cf:c, timestamp=1403759503155, Value=value3
3 Row (s) in 0.0440 seconds

Get a single row of data.
To get a single row of data at a time with the Get command.

hbase> get ' test ', ' row1 '
COLUMN                CELL
 cf:a                 timestamp=1403759475114, value=value1
1 row (s) in 0.0230 seconds            

Disable a table.
If you want to delete a table or change it settings, as well as on some other situations, you need to disable the table F Irst, using the Disable command. You can re-enable it using the Enablecommand.
hbase> Disable ' test '
0 row (s) in 1.6270 seconds

hbase> Enable ' test '
0 row (s) in 0.4500 seconds

Disable The table again if you tested the Enable command above:

hbase> disable ' test '
0 row (s) in 1.6270 seconds            

Drop the table.
To drop (delete) a table, use the drop command.
Delete a table

hbase> drop ' test '
0 row (s) in 0.2900 seconds            

Exit the HBase Shell.
To exit the HBase Shell and disconnect from your cluster, use the QUIT command. HBase is still running in the background.
Procedure 1.3. Stop HBase
In the same-the-bin/start-hbase.sh script is provided to conveniently start all HBase daemons, the Bin/stop-hbase . sh script stops them.
..../bin/stop−hbase.shstoppinghbase ..... ......... ./bin/stop-hbase.sh stopping HBase ......... .....

After issuing the command, it can take several minutes for the processes to shut down. Use the JPS to is sure that the hmaster and hregionserver processes is shut down. 1.2.3. intermediate-pseudo-distributed Local Install

After working your-through section 1.2, "Quick start-standalone hbase", you can re-configure hbase to run in pseudo- Distributed mode. pseudo-distributed mode means that HBase still runs completely on a single host, but each HBase daemon (hmaster, Hregionse RVer, and Zookeeper) runs as a separate process. By default, unless your configure the Hbase.rootdir property as described Insection 1.2, "Quick start-standalone hbase", Your data is still stored in/tmp/. In this walk-through, we store your the data in HDFS instead, assuming you have HDFS available. You can skip the HDFS configuration to continue storing your data in the local filesystem.
Hadoop Configuration
This procedure assumes the configured Hadoop and HDFS on your The local system and or a remote system, and that they is running and available. It also assumes you is using Hadoop 2. Currently, the documentation on the "Hadoop website does not include a" quick Start for Hadoop 2, but the "guide" at HTTP://WW W.alexjf.net/blog/distributed-systems/hadoop-yarn-installation-definitive-guide is a good starting point.
Stop HBase if it is running.
If you have the just finished section 1.2, "Quick start-standalone HBase" and HBase are still running, stop it. This procedure would create a totally new directory where HBase would store its data so any databases you created before WI ll be lost.
Configure HBase.
Edit the Hbase-site.xml configuration. First, add the following property. which directs HBase to run in distributed mode, with one JVM instance per daemon.

hbase.cluster.distributed
True

Next, change the hbase.rootdir from the local filesystem to the address of your HDFS instance, using the hdfs:////URI syn Tax. In this example, HDFS are running on the localhost at Port 8020.

Hbase.rootdir
Hdfs://localhost:8020/hbase

You don't need to create the directory in HDFS. HBase would do the for you. If you create the directory, HBase would attempt to does a migration, which is isn't what you want.
Start HBase.
Use the bin/start-hbase.sh command to start HBase. If your system is configured correctly, the JPS command should show the Hmaster and hregionserver processes running.
Check The HBase directory in HDFS.
If everything worked correctly, HBase created its directory in HDFS. In the configuration above, it is stored in/hbase/on HDFS. You can use the Hadoop FS command in Hadoop's bin/directory to list of this directory.

$./bin/hadoop fs-ls/hbase
Found 7 items
drwxr-xr-x   -hbase users          0 2014-06-25 18:58/hbase/.tmp
Dr Wxr-xr-x   -HBase users          0 2014-06-25 21:49/hbase/wals
drwxr-xr-x   -hbase users          0 2014-06-25 18:48/ Hbase/corrupt
drwxr-xr-x   -hbase users          0 2014-06-25 18:58/hbase/data
-rw-r--r--   3 hbase Users         2014-06-25 18:41/hbase/hbase.id
-rw-r--r--   3 hbase users          7 2014-06-25 18:41/hbase/ Hbase.version
drwxr-xr-x   -hbase users          0 2014-06-25 21:49/hbase/oldwals

Create a table and populate it with data.
You can use the HBase Shell to create a table, populate it with data, scan and get values from it, using the same Procedur e As in Procedure 1.2, "use HBase for the first time".
Start and stop a backup HBase Master (hmaster) server.
Note
Running multiple Hmaster instances on the same hardware does do sense in a production environment, in the same t Hat running a pseudo-distributed cluster does not make sense for production. This step was offered for testing and learning purposes only.
The Hmaster server controls the HBase cluster. You can start with 9 backup Hmaster servers, which makes total hmasters, counting the primary. To start a backup hmaster, use the local-master-backup.sh. For each backup master you want to start, add a parameter representing the port offset for that master. Each hmaster uses three ports (16010, 16020, and 16030 by default). The port offset is added to these ports, so using a offset of 2, the backup hmaster would use ports 16012, 16022, and 160 The following command starts 3 backup servers using ports 16012/16022/16032, 16013/16023/16033, and 16015/16025/16035.
$./bin/local-master-backup.sh 2 3 5

To kill a backup master without killing the entire cluster and you need to find its process ID (PID). The PID is stored in a file with a name Like/tmp/hbase-user-x-master.pid. The only contents of the file is the PID. You can use the kill-9 command to kill this PID. The following command would kill the master with Port offset 1, but leave the cluster running:
$ cat/tmp/hbase-testuser-1-master.pid |xargs kill-9

Start and stop additional regionservers
The Hregionserver manages the data in its storefiles as directed by the Hmaster. Generall

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.