【问题标题】:RJDBC - Could not open client transport with JDBC UriRJDBC - 无法使用 JDBC Uri 打开客户端传输
【发布时间】:2017-08-02 05:12:47
【问题描述】:

我正在尝试从 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 打开客户端传输

【问题讨论】:

    标签: ibm-cloud rjdbc biginsights


    【解决方案1】:

    这对我有用:

    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
    

    【讨论】:

      猜你喜欢
      • 2019-06-08
      • 2018-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多