iT邦幫忙

0

Hive-ODBC透過php連接到Hive的SSL問題

之前在處理PHP連接到ODBC問題,解決到一半的時候遇到了SSL的問題

(之前的發問)
https://ithelp.ithome.com.tw/questions/10196020

我將部份的設定改過之後跳出了這個錯誤訊息

(1110) unexpected response received from server. please ensure the server host and port specified for the connection are correct and confirm if ssl should be enabled for the connection

所以我開始想辦法解決SSL的問題

我參考了這個網站並按照底下的回覆自己嘗試簽了憑證出來

https://community.cloudera.com/t5/Support-Questions/Unable-to-connect-with-beeline-after-enabling-HiveServer2/td-p/213320

https://ithelp.ithome.com.tw/upload/images/20191127/20114173lz6F2RnOaQ.png

然後我改了設定檔(odbc.ini)

這是目前的設定

[ODBC]
#InstallDir=/opt/odbc/unixodbc/lib
# Specify any global ODBC configuration here such as ODBC tracing.
[ODBC Data Sources]
Hortonworks Hive 64-bit=Hortonworks Hive ODBC Driver 64-bit

[Hive_odbc_64]
Description=Hortonworks Hive ODBC Driver (64-bit) DSN
Driver=/usr/lib/hive/lib/native/Linux-amd64-64/libhortonworkshiveodbc64.so
HOST=hadoop.namenode:2181,hadoop.snamenode:2181,hadoop.datanode4:2181
PORT=10000
Schema=default
ServiceDiscoveryMode=1
ZKNamespace=hiveserver2
HiveServerType=2
AuthMech=0
ThriftTransport=1
UseNativeQuery=0
UID=hdfs
KrbHostFQDN=_HOST
KrbServiceName=hive
KrbRealm=
SSL=1
AllowSelfSignedServerCert=1
TwoWaySSL=0
ClientCert=/opt/ssl_jks/client.truststore.jks
ClientPrivateKey=
ClientPrivateKeyPassword='SuBaLaSiMas1'

然後得到這個錯誤

PHP Warning:  odbc_connect(): SQL error: [unixODBC][Hortonworks][DriverSupport] (1160) Cannot enable SSL for the connection when connecting to a server that has not enabled SSL. If the server has SSL enabled, please check if it has been configured to use a SSL protocol version that is lower than what is allowed for the connection. The minimum SSL protocol version allowed for the connection is: TLS 1.2., SQL state S1000 in SQLConnect in /var/www/html/hive_odbc_test/hive_odbc_test1.php on line 47

我看到許多人用beeline去測試ssl有沒有通,所以我也試了一下

https://ithelp.ithome.com.tw/upload/images/20191127/20114173ycFk41cy6m.png

結果是handshake_failure

有大神知道我是odbc.ini設定錯誤還是ssl憑證沒有設定好嗎?

圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 個回答

0
墨嗓
iT邦研究生 4 級 ‧ 2019-11-27 23:43:06

不確定你目前是否有用過如這份文件裡頭說的 isql 做連線測試?

https://cwiki.apache.org/confluence/display/Hive/HiveODBC#HiveODBC-unixODBCAPIWrapperBuild/Setup

按著文件看,如果 odbc.ini odbcinet.ini 都設定完畢,理論上 isql 的指令就可以連入資料庫了。待這一層確認,再透過 PHP 來連線,才能確認是不是 PHP 的問題。

P.S. 不好意思,我個人沒玩過 Hive Server 沒辦法提供給你很確切的答案。

看更多先前的回應...收起先前的回應...

感謝回覆,我有已經試過isql的測試了,因為這個測試的結果跟phpstorm回傳的錯誤訊息是一樣的
https://ithelp.ithome.com.tw/upload/images/20191129/201141730obR5jtk1F.png

墨嗓 iT邦研究生 4 級 ‧ 2019-12-01 22:44:53 檢舉

反過來思考,那有可能讓 server 端先不開 ssl 連線嗎?

墨嗓我前兩天發現了1110的那個錯誤訊息其實是在說我的設定有錯誤,要確認一下port跟設定,如果有開ssl的話要確保ssl有通,所以是我理解錯誤,然後我馬上改用kerberos,昨天使用phpstorm測試是可以直接查到hive裡面的資料庫的
https://ithelp.ithome.com.tw/upload/images/20191202/201141737fd12OUEHX.png

但是當我使用本地的伺服器開啟測試頁的時候我傻了
https://ithelp.ithome.com.tw/upload/images/20191202/20114173PpTnpVptU1.png
我不知道phpstrom為甚麼能夠抓到kerberos的設定但是伺服器沒辦法
抓到,如果您也不知道的話我大概還要再開一篇新的發問了XD

墨嗓 iT邦研究生 4 級 ‧ 2019-12-02 17:47:40 檢舉

看起來是本地與測試機上面裝的 driver 不太一樣。

墨嗓但是我用的都是同一台機器...

我要發表回答

立即登入回答