这里是我遇到的hbase、phoenix的所有错误,均已找到解决方法。
错误一:java.lang.NoSuchMethodError
报错信息如下:
(1)第一种错误
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.security.authentication.util.KerberosUtil.hasKerberosKeyTab(Ljavax/security/auth/Subject;)Z
at org.apache.hadoop.security.UserGroupInformation.<init>(UserGroupInformation.java:715)
at org.apache.hadoop.security.UserGroupInformation.loginUserFromSubject(UserGroupInformation.java:925)
at org.apache.hadoop.security.UserGroupInformation.getLoginUser(UserGroupInformation.java:873)
at org.apache.hadoop.security.UserGroupInformation.getCurrentUser(UserGroupInformation.java:740)
at org.apache.hadoop.hbase.security.User$SecureHadoopUser.<init>(User.java:266)
at org.apache.hadoop.hbase.security.User.getCurrent(User.java:164)
at org.apache.phoenix.jdbc.PhoenixEmbeddedDriver$ConnectionInfo.<init>(PhoenixEmbeddedDriver.java:504)
at org.apache.phoenix.jdbc.PhoenixEmbeddedDriver$ConnectionInfo.create(PhoenixEmbeddedDriver.java:312)
at org.apache.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:232)
at org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.createConnection(PhoenixEmbeddedDriver.java:150)
at org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:221)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.layne.phoenix.PhoenixTest.main(PhoenixTest.java:19)
Process finished with exit code 1
(2)第二种错误
Exception in thread "main" java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;Ljava/lang/Object;)V
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1357)
at org.apache.hadoop.conf.Configuration.set(Configuration.java:1338)
at org.apache.hadoop.conf.Configuration.setIfUnset(Configuration.java:1433)
at org.apache.phoenix.query.QueryServicesOptions.setIfUnset(QueryServicesOptions.java:467)
at org.apache.phoenix.query.QueryServicesOptions.withDefaults(QueryServicesOptions.java:381)
at org.apache.phoenix.query.QueryServicesImpl.<init>(QueryServicesImpl.java:36)
at org.apache.phoenix.jdbc.PhoenixDriver.getQueryServices(PhoenixDriver.java:197)
at org.apache.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:235)
at org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.createConnection(PhoenixEmbeddedDriver.java:150)
at org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:221)
at java.sql.DriverManager.getConnection(DriverManager.java:664)
at java.sql.DriverManager.getConnection(DriverManager.java:270)
at com.layne.phoenix.PhoenixTest.main(PhoenixTest.java:19)
解决方法:
使用如下maven依赖,缺一不可,注意jar包版本要和集群中使用的一致
<dependencies>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>5.0.0-HBase-2.0</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<version>3.1.3</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>27.0-jre</version>
</dependency>
</dependencies>
错误二:org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException
报错信息如下:
(1)第一个错误
Thu Oct 07 19:55:03 CST 2021, RpcRetryingCaller{globalStartTime=1633607574392, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
Thu Oct 07 19:55:33 CST 2021, RpcRetryingCaller{globalStartTime=1633607574392, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
Thu Oct 07 19:56:03 CST 2021, RpcRetryingCaller{globalStartTime=1633607574392, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
Thu Oct 07 19:56:33 CST 2021, RpcRetryingCaller{globalStartTime=1633607574392, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
Thu Oct 07 19:57:03 CST 2021, RpcRetryingCaller{globalStartTime=1633607574392, pause=100, maxAttempts=16}, org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
at org.apache.hadoop.hbase.client.RpcRetryingCallerImpl.callWithRetries(RpcRetryingCallerImpl.java:145)
at org.apache.hadoop.hbase.client.HBaseAdmin.executeCallable(HBaseAdmin.java:3055)
at org.apache.hadoop.hbase.client.HBaseAdmin.getTableDescriptor(HBaseAdmin.java:525)
at org.apache.hadoop.hbase.client.HBaseAdmin.getDescriptor(HBaseAdmin.java:332)
at org.apache.phoenix.query.ConnectionQueryServicesImpl.ensureTableCreated(ConnectionQueryServicesImpl.java:1118)
... 20 more
Caused by: org.apache.hadoop.hbase.MasterNotRunningException: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
at org.apache.hadoop.hbase.client.ConnectionImplementation$MasterServiceStubMaker.makeStub(ConnectionImplementation.java:1154)
at org.apache.hadoop.hbase.client.ConnectionImplementation.getKeepAliveMasterService(ConnectionImplementation.java:1213)
at org.apache.hadoop.hbase.client.ConnectionImplementation.getMaster(ConnectionImplementation.java:1202)
at org.apache.hadoop.hbase.client.MasterCallable.prepare(MasterCallable.java:57)
at org.apache.hadoop.hbase.client.RpcRetryingCallerImpl.callWithRetries(RpcRetryingCallerImpl.java:105)
... 24 more
Caused by: java.net.ConnectException: Call to hadoop102/xx.xx.xx.xxx:16000 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
at org.apache.hadoop.hbase.ipc.IPCUtil.wrapException(IPCUtil.java:165)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient.onCallFinished(AbstractRpcClient.java:390)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient.access$100(AbstractRpcClient.java:95)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:410)
at org.apache.hadoop.hbase.ipc.AbstractRpcClient$3.run(AbstractRpcClient.java:406)
at org.apache.hadoop.hbase.ipc.Call.callComplete(Call.java:103)
at org.apache.hadoop.hbase.ipc.Call.setException(Call.java:118)
at org.apache.hadoop.hbase.ipc.BufferCallBeforeInitHandler.userEventTriggered(BufferCallBeforeInitHandler.java:92)
at org.apache.hbase.thirdparty.io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329)
at org.apache.hbase.thirdparty.io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315)
at org.apache.hbase.thirdparty.io.netty.channel.AbstractChannelHandlerContext.fireUserEventTriggered(AbstractChannelHandlerContext.java:307)
at org.apache.hbase.thirdparty.io.netty.channel.DefaultChannelPipeline$HeadContext.userEventTriggered(DefaultChannelPipeline.java:1377)
at org.apache.hbase.thirdparty.io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:329)
at org.apache.hbase.thirdparty.io.netty.channel.AbstractChannelHandlerContext.invokeUserEventTriggered(AbstractChannelHandlerContext.java:315)
at org.apache.hbase.thirdparty.io.netty.channel.DefaultChannelPipeline.fireUserEventTriggered(DefaultChannelPipeline.java:929)
at org.apache.hadoop.hbase.ipc.NettyRpcConnection.failInit(NettyRpcConnection.java:179)
at org.apache.hadoop.hbase.ipc.NettyRpcConnection.access$500(NettyRpcConnection.java:71)
at org.apache.hadoop.hbase.ipc.NettyRpcConnection$3.operationComplete(NettyRpcConnection.java:267)
at org.apache.hadoop.hbase.ipc.NettyRpcConnection$3.operationComplete(NettyRpcConnection.java:261)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:500)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:479)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
at org.apache.hbase.thirdparty.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:269)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.PromiseTask$RunnableAdapter.call(PromiseTask.java:38)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.ScheduledFutureTask.run(ScheduledFutureTask.java:120)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:403)
at org.apache.hbase.thirdparty.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:858)
at org.apache.hbase.thirdparty.io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:138)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop102/xx.xx.xx.xxx:16000
at org.apache.hbase.thirdparty.io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe$1.run(AbstractNioChannel.java:267)
... 8 more
2021-10-07 19:57:03,827 INFO [org.apache.zookeeper.ZooKeeper] - Session: 0x300000194820023 closed
2021-10-07 19:57:03,834 INFO [org.apache.zookeeper.ClientCnxn] - EventThread shut down for session: 0x300000194820023
(2)第二个错误
2021-10-07 20:02:06,444 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=6, retries=6, started=35839 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
2021-10-07 20:02:20,509 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=7, retries=7, started=49904 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
2021-10-07 20:02:40,614 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=8, retries=8, started=70009 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
2021-10-07 20:03:00,695 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=9, retries=9, started=90090 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
2021-10-07 20:03:20,757 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=10, retries=10, started=110152 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
2021-10-07 20:03:40,865 INFO [org.apache.hadoop.hbase.client.RpcRetryingCallerImpl] - Call exception, tries=11, retries=11, started=130260 ms ago, cancelled=false, msg=Call to hadoop104/xx.xx.xx.xxx:16020 failed on connection exception: org.apache.hbase.thirdparty.io.netty.channel.ConnectTimeoutException: connection timed out: hadoop104/xx.xx.xx.xxx:16020, details=row 'SYSTEM:CATALOG' on table 'hbase:meta' at region=hbase:meta,,1.1588230740, hostname=hadoop104,16020,1633605395295, seqNum=-1
解决方法,远程服务器开启三个端口:
16000
16020
16010
错误三:org.apache.phoenix.util.LogUtil.getCallerStackTrace
错误信息如下:
2021-10-07 19:52:51,418 INFO [org.apache.phoenix.query.ConnectionQueryServicesImpl] - HConnection established. Stacktrace for informational purposes: hconnection-0x451001e5 java.lang.Thread.getStackTrace(Thread.java:1552)
org.apache.phoenix.util.LogUtil.getCallerStackTrace(LogUtil.java:55)
org.apache.phoenix.query.ConnectionQueryServicesImpl.openConnection(ConnectionQueryServicesImpl.java:432)
org.apache.phoenix.query.ConnectionQueryServicesImpl.access$400(ConnectionQueryServicesImpl.java:272)
org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:2556)
org.apache.phoenix.query.ConnectionQueryServicesImpl$12.call(ConnectionQueryServicesImpl.java:2532)
org.apache.phoenix.util.PhoenixContextExecutor.call(PhoenixContextExecutor.java:76)
org.apache.phoenix.query.ConnectionQueryServicesImpl.init(ConnectionQueryServicesImpl.java:2532)
org.apache.phoenix.jdbc.PhoenixDriver.getConnectionQueryServices(PhoenixDriver.java:255)
org.apache.phoenix.jdbc.PhoenixEmbeddedDriver.createConnection(PhoenixEmbeddedDriver.java:150)
org.apache.phoenix.jdbc.PhoenixDriver.connect(PhoenixDriver.java:221)
java.sql.DriverManager.getConnection(DriverManager.java:664)
java.sql.DriverManager.getConnection(DriverManager.java:270)
com.layne.phoenix.PhoenixTest.main(PhoenixTest.java:19)
这个只是log4j打印大的info信息,不算错误,可以忽略它,如果真的不想看见它,可以设置log4j.properties
附:JDBC连接phoenix代码
import java.sql.*;
public class PhoenixTest {
public static void main(String[] args) throws ClassNotFoundException, SQLException {
String driver = "org.apache.phoenix.jdbc.PhoenixDriver";
String url = "jdbc:phoenix:hadoop102,hadoop103,hadoop104:2181";
Class.forName(driver);
Connection connection = DriverManager.getConnection(url);
PreparedStatement preparedStatement = connection.prepareStatement("SELECT * FROM STUDENT");
ResultSet resultSet = preparedStatement.executeQuery();
while (resultSet.next()) {
System.out.println(resultSet.getString(1) + resultSet.getString(2));
}
resultSet.close();
preparedStatement.close();
connection.close();
}
}
|