import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.MasterNotRunningException;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;
import org.apache.hadoop.hbase.client.HBaseAdmin;
public class ListTables {
public static void main(String args[])throws MasterNotRunningException, IOException {
ConnectionFactory.createConnection();
System.out.println("stage 1. . . . ");
Configuration conf = HBaseConfiguration.create();
conf.set("hbase.zookeeper.quorum", "192.168.*.***");
conf.set("hbase.master", "192.168.*.***:60000");
conf.set("hbase.zookeeper.property.clientPort","2181");
conf.set("zookeeper.znode.parent","/hbase-unsecure");
Connection connection = ConnectionFactory.createConnection(conf);
try {
HBaseAdmin admin1 = (HBaseAdmin)connection.getAdmin();
System.out.println("stage 3. . . . ");
HTableDescriptor tableDescriptor[] = admin1.listTables();
for (int i=0; i<tableDescriptor.length; i++) {
System.out.println(tableDescriptor[i].getNameAsString());
}
} catch (Exception e) {
System.out.println(e);
}
}
}
输出
log4j:WARN No appenders could be found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
stage 1. . . .
stage 3. . . .
这就是错误
排队之后,我等了很长时间,但没有回应。
1条答案
按热度按时间myzjeezk1#
我也有同样的错误,我必须创建log4j.properties,这是因为hadoop使用log4j来编写日志:
java项目:resources/log4j.properties
我希望这对你有帮助。