我尝试从RJDBC连接到我的Biginsights Enterprise群集:
hiveconnection <- dbConnect(drv,
"jdbc:hive2://xxxxx:10001/default",
"xxxxx",
"xxxxx",
ssl="true",
sslTrustStore="mytruststore.jks",
trustStorePassword="xxxxx",
hive.server2.transport.mode="http",
hive.server2.thrift.http.path="gateway/default/hive
)
但是,我遇到了这个问题:
无法使用JDBC Uri打开客户端传输
答案 0 :(得分:0)
这对我有用:
username = 'changeme'
password = 'changeme'
# change this to your hostname
url = 'jdbc:hive2://bi4c-xxxx-master-3.bi.services.bluemix.net:10000/default;ssl=true;sslTrustStore=/change/to/yourpath/to/truststore.jks;trustStorePassword=mypassword;'
library(rJava)
library(RJDBC)
hive.class.path = list.files(path=c('/change/to/yourpath/to/build/hivedrivers/'), pattern="jar", full.names=T);
.jinit(classpath=hive.class.path,parameters="")
drv <- JDBC("org.apache.hive.jdbc.HiveDriver","hive-jdbc-2.0.0.jar",identifier.quote="`")
conn <- dbConnect(drv,url,username,password)
show_databases <- dbGetQuery(conn, "show databases")
print(show_databases)
设置步骤
我使用gradle将所有hive jdbc依赖项下载到一个文件夹。我接下来创建了一个build.gradle
文件:
repositories {
mavenCentral()
}
configurations {
drivers
}
dependencies {
drivers "org.apache.hive:hive-jdbc:2.0.0"
}
task CopyDrivers(type: Copy) {
from configurations.drivers
into "$buildDir/hivedrivers"
}
然后在终端窗口中我改为build.gradle文件的目录,执行了:
$ gradle CopyDrivers
我用:
创建了信任库$ BI_HOST=bi4c-xxxxx-master-3.bi.services.bluemix.net
$ openssl s_client -showcerts -connect $BI_HOST:9443 < /dev/null | openssl x509 -outform PEM > certificate
$ rm -f truststore.jks
$ keytool -import -trustcacerts -alias biginsights -file certificate -keystore truststore.jks -storepass mypassword -noprompt