问题描述
在idea中是可以连接Ambari管理的Hbase的,pom中的依赖为
<dependency>
<groupId>org.apache.hbase</groupId>
<artifactId>hbase-client</artifactId>
<version>2.0.3</version>
</dependency>
<dependency>
<groupId>org.apache.phoenix</groupId>
<artifactId>phoenix-core</artifactId>
<version>5.0.0-HBase-2.0</version>
</dependency>
但是有Dbeaver连接失败,各种报错:
Unexpected driver error occurred while connecting to the database
java.lang.RuntimeException:class org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback not org.apache.hadoop.security.GroupMappingServiceProvider
ERROR 103 (08004): Unable to establish connection.
java.lang.reflect.InvocationTargetException
'void sun.misc.Unsafe.putLong(java.lang.Object, int, long)'
Unexpected driver error occurred while connecting to the database
Inconsistent constant pool data in classfile for class org/apache/hadoop/hbase/client/Row. Method 'int lambda$static$28(org.apache.hadoop.hbase.client.Row, org.apache.hadoop.hbase.client.Row)' at index 57 is CONSTANT_MethodRef and should be CONSTANT_InterfaceMethodRef
ERROR 726 (43M10): Inconsistent namespace mapping properties. Ensure that config phoenix.schema.isNamespaceMappingEnabled is consistent on client and server.
换了各种版本的驱动、添加了驱动属性都不行
phoenix.schema.isNamespaceMappingEnabled true
phoenix.schema.mapSystemTablesToNamespace true
最终解决方法
- 将pom中对应的jar全部复制到一个目录中(比如libs)
antlr-runtime-3.5.2.jar
aopalliance-1.0.jar
aopalliance-repackaged-2.5.0-b32.jar
apacheds-i18n-2.0.0-M15.jar
apacheds-kerberos-codec-2.0.0-M15.jar
api-asn1-api-1.0.0-M20.jar
api-util-1.0.0-M20.jar
asm-3.1.jar
asm-all-5.0.2.jar
audience-annotations-0.5.0.jar
avro-1.7.4.jar
commons-beanutils-1.7.0.jar
commons-beanutils-core-1.8.0.jar
commons-cli-1.4.jar
commons-codec-1.10.jar
commons-collections-3.2.2.jar
commons-compress-1.4.1.jar
commons-configuration-1.6.jar
commons-crypto-1.0.0.jar
commons-csv-1.0.jar
commons-daemon-1.0.13.jar
commons-digester-1.8.jar
commons-httpclient-3.1.jar
commons-io-2.5.jar
commons-lang-2.6.jar
commons-lang3-3.6.jar
commons-logging-1.1.3.jar
commons-math3-3.1.1.jar
commons-net-3.1.jar
curator-client-2.7.1.jar
curator-framework-2.7.1.jar
curator-recipes-2.7.1.jar
disruptor-3.3.6.jar
fastutil-6.5.6.jar
findbugs-annotations-1.3.9-1.jar
gson-2.2.4.jar
guava-13.0.1.jar
guice-3.0.jar
guice-assistedinject-3.0.jar
guice-servlet-4.0.jar
hadoop-annotations-3.0.0.jar
hadoop-auth-2.7.7.jar
hadoop-client-2.7.4.jar
hadoop-common-2.7.7.jar
hadoop-distcp-2.7.4.jar
hadoop-hdfs-2.7.4.jar
hadoop-hdfs-client-3.0.0.jar
hadoop-mapreduce-client-app-2.7.4.jar
hadoop-mapreduce-client-common-2.7.4.jar
hadoop-mapreduce-client-core-3.0.0.jar
hadoop-mapreduce-client-jobclient-2.7.4.jar
hadoop-mapreduce-client-shuffle-2.7.4.jar
hadoop-yarn-api-2.7.4.jar
hadoop-yarn-client-3.0.0.jar
hadoop-yarn-common-3.0.0.jar
hadoop-yarn-server-common-2.7.4.jar
hbase-annotations-2.0.0.jar
hbase-client-2.0.3.jar
hbase-common-2.0.3.jar
hbase-hadoop-compat-2.0.3.jar
hbase-hadoop2-compat-2.0.3.jar
hbase-http-2.0.0.jar
hbase-mapreduce-2.0.0.jar
hbase-metrics-2.0.3.jar
hbase-metrics-api-2.0.3.jar
hbase-procedure-2.0.0.jar
hbase-protocol-2.0.3.jar
hbase-protocol-shaded-2.0.3.jar
hbase-replication-2.0.0.jar
hbase-server-2.0.0.jar
hbase-shaded-miscellaneous-2.1.0.jar
hbase-shaded-netty-2.1.0.jar
hbase-shaded-protobuf-2.1.0.jar
hbase-zookeeper-2.0.0.jar
hk2-api-2.5.0-b32.jar
hk2-locator-2.5.0-b32.jar
hk2-utils-2.5.0-b32.jar
htrace-core-3.1.0-incubating.jar
htrace-core4-4.2.0-incubating.jar
httpclient-4.0.1.jar
httpcore-4.0.1.jar
i18n-util-1.0.4.jar
icu4j-60.2.jar
icu4j-charset-60.2.jar
icu4j-localespi-60.2.jar
jackson-annotations-2.9.0.jar
jackson-core-2.9.2.jar
jackson-core-asl-1.9.2.jar
jackson-databind-2.9.2.jar
jackson-jaxrs-1.9.2.jar
jackson-jaxrs-base-2.7.8.jar
jackson-jaxrs-json-provider-2.7.8.jar
jackson-mapper-asl-1.9.2.jar
jackson-module-jaxb-annotations-2.7.8.jar
jackson-xc-1.9.2.jar
jamon-runtime-2.4.1.jar
javassist-3.20.0-GA.jar
javax.annotation-api-1.2.jar
javax.el-3.0.1-b12.jar
javax.inject-1.jar
javax.inject-2.5.0-b32.jar
javax.servlet-api-3.1.0.jar
javax.servlet.jsp-2.3.2.jar
javax.servlet.jsp-api-2.3.1.jar
javax.ws.rs-api-2.0.1.jar
jaxb-api-2.2.11.jar
jaxb-impl-2.2.3-1.jar
jcip-annotations-1.0-1.jar
jcodings-1.0.18.jar
jersey-client-1.19.jar
jersey-client-2.25.1.jar
jersey-common-2.25.1.jar
jersey-container-servlet-core-2.25.1.jar
jersey-core-1.9.jar
jersey-guava-2.25.1.jar
jersey-guice-1.19.jar
jersey-json-1.19.jar
jersey-media-jaxb-2.25.1.jar
jersey-server-1.9.jar
jersey-server-2.25.1.jar
jersey-servlet-1.19.jar
jettison-1.3.8.jar
jetty-6.1.26.jar
jetty-http-9.3.19.v20170502.jar
jetty-io-9.3.19.v20170502.jar
jetty-security-9.3.19.v20170502.jar
jetty-server-9.3.19.v20170502.jar
jetty-servlet-9.3.19.v20170502.jar
jetty-sslengine-6.1.26.jar
jetty-util-6.1.26.jar
jetty-util-9.3.19.v20170502.jar
jetty-util-ajax-9.3.19.v20170502.jar
jetty-webapp-9.3.19.v20170502.jar
jetty-xml-9.3.19.v20170502.jar
jline-2.11.jar
joda-time-1.6.jar
joni-2.1.11.jar
jsch-0.1.54.jar
jsr305-2.0.1.jar
leveldbjni-all-1.8.jar
libthrift-0.9.0.jar
log4j-1.2.17.jar
metrics-core-3.2.1.jar
netty-3.10.5.Final.jar
netty-all-4.0.23.Final.jar
okhttp-2.4.0.jar
okio-1.4.0.jar
osgi-resource-locator-1.0.1.jar
paranamer-2.3.jar
phoenix-core-5.0.0-HBase-2.0.jar
protobuf-java-2.5.0.jar
slf4j-api-1.7.25.jar
slf4j-log4j12-1.6.1.jar
snappy-0.3.jar
snappy-java-1.0.4.1.jar
sqlline-1.2.0.jar
stream-2.9.5.jar
tephra-api-0.14.0-incubating.jar
tephra-core-0.14.0-incubating.jar
tephra-hbase-compat-2.0-0.14.0-incubating.jar
twill-api-0.8.0.jar
twill-common-0.8.0.jar
twill-core-0.8.0.jar
twill-discovery-api-0.8.0.jar
twill-discovery-core-0.8.0.jar
twill-zookeeper-0.8.0.jar
validation-api-1.1.0.Final.jar
xmlenc-0.52.jar
xz-1.0.jar
zookeeper-3.4.10.jar
2、从Hbase集群中拷贝hbase-site.xml,将其添加到libs目录中的phoenix-core-5.0.0-HBase-2.0.jar里
3、打开Dbeaver,新建Phoenix连接,填写主机(hdp01,hdp02,hdp03)、端口(2181)、用户名、密码,点击“编辑驱动设置”
4、切换到“库”Tab,删除原来的驱动文件,点击“添加文件夹”,选择libs目录,然后点击“找到类”,选择org.apache.phoenix.jdbc.PhoenixDriver
5、确定后,双击配置好的Phoenix连接,如果还报错,重启Dbeaver后再次连接。