Hbase API create table error record for Docker container deployment cluster

Keywords: Big Data 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");
            tableDescriptor.addFamily(cf1);
            tableDescriptor.addFamily(cf2);
            tableDescriptor.addFamily(cf3);
            System.out.println("Createing table. ");
            //Do create
            admin.createTable(tableDescriptor);
            System.out.println("Done.");
        }
    }

}

Run compile error:

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

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

vim /etc/hosts
172.20.0.2 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
172.20.0.3 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
172.20.0.4 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 fusionxn1 on Thu, 30 Apr 2020 02:57:56 -0700