Hbase API create table error record for Docker container deployment cluster

Keywords: Hadoop HBase Apache vim


Hbase API create table error record

Demo method:

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.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

public class CreateTableDemo {

    public static void main(String[] args) throws Exception{
        Configuration config = HBaseConfiguration.create();// Get connection information

        //Create connection
        try(Connection connection = ConnectionFactory.createConnection(config)) {
            Admin admin = connection.getAdmin();

            HTableDescriptor tableDescriptor = new HTableDescriptor(TableName.valueOf("weGamer"));
            HColumnDescriptor cf1 = new HColumnDescriptor("personalinfo");
            HColumnDescriptor cf2 = new HColumnDescriptor("recordinfo");
            HColumnDescriptor cf3 = new HColumnDescriptor("assetsinfo");
            System.out.println("Createing table. ");
            //Do create


Run compile error:

The port that HBase Master should bind to. Default: 16000

The host name in the container is not appended at the end of the client binding /ect/hosts

vim /etc/hosts hadoop-master 55c923f2c306

Recompile execution error:

Port bound by HBase RegionServer. Default: 16020

The host name in the container is not bound in the client / ect/hosts is appended at the end

vim /etc/hosts hadoop-slave1 hadoop-slave1.day2_beimei6-net

Operation error:

This runtime exception. Because our previous table has been created repeatedly, let's go to the UI to check it.

The table exists. Let's change the name

Let's compile and run again:

Finally, we see the success. Then we are three Docker containers. In order to avoid this error again, we put the HRegionServer machine hostname of hbase of salve2 node

The host name in the container is not bound in the client / ect/hosts is appended at the end

vim /etc/hosts hadoop-slave2 hadoop-slave2.day2_beimei6-net

The data read and write operations of the application are completed through the communication with the HRegion. Port 16020 is the port bound by the RegionServer.

Reference documents

ยทHBase official website API

Posted by spartan7 on Tue, 05 May 2020 16:37:36 -0700