I try to connect with HBase in a remote server using java. Below is my java code
String zookeeperHost = "myserverIP";
String tableName = "User";
Configuration hconfig = HBaseConfiguration.create();
hconfig.setInt("timeout", 1200);
hconfig.set("hbase.zookeeper.quorum",zookeeperHost);
hconfig.set("hbase.zookeeper.property.clientPort", "2181");
TableName tname = TableName.valueOf(tableName);
try {
HBaseAdmin.checkHBaseAvailable(hconfig);
} catch (ServiceException e) {
e.printStackTrace();
}
HTableDescriptor htable = new HTableDescriptor(tname);
htable.addFamily( new HColumnDescriptor("Id"));
htable.addFamily( new HColumnDescriptor("Name"));
System.out.println( "Connecting..." );
Connection connection = ConnectionFactory.createConnection(hconfig);
HBaseAdmin hbase_admin = (HBaseAdmin)connection.getAdmin();
System.out.println( "Creating Table..." );
hbase_admin.createTable( htable );
System.out.println("Done!");
but I keep getting this exception
org.apache.hadoop.hbase.MasterNotRunningException:
com.google.protobuf.ServiceException: java.net.ConnectException: Connection >refused: no further information
How can I resolve this issue?
Add below in 'hconfig'
hconfig.set("hbase.master", hbaseConnectionIpAddr);
hconfig.set("hbase.master.port", hbaseConnectionPortNum);
There could be two reasons for below exception
org.apache.hadoop.hbase.MasterNotRunningException
Remote VM hostname/IP is not accessible by client machine. In order to fix that, you need to update the inbound rules to allow port access. If in case of a VM host name, make sure you have added an entry in /etc/hosts
to resolve the host name with IP address.
Second issue could be the HBase master is running. Make sure if HMaster service is running from your remote server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.