天天看點

kylin使用出現的坑(三)——java.sql.SQLException:No suitable driver found for jdbc:mysql://localhost:3306/hive?

異常資訊描述:

kylin的cube在build時,#2 Step Name: Extract Fact Table Distinct Columns出現java.sql.SQLException的錯誤。如下所示:

java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false具體錯誤如下文所示:

Caused by: MetaException(message:Unable to open a test connection to the given database. JDBC url = jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false, username = hadoop. Terminating connection pool (set lazyInit to true if you expect to start your database after your app). Original Exception: ------
java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true&useSSL=false
	at java.sql.DriverManager.getConnection(DriverManager.java:689)
	at java.sql.DriverManager.getConnection(DriverManager.java:208)
	at com.jolbox.bonecp.BoneCP.obtainRawInternalConnection(BoneCP.java:361)
	at com.jolbox.bonecp.BoneCP.<init>(BoneCP.java:416)
	at com.jolbox.bonecp.BoneCPDataSource.getConnection(BoneCPDataSource.java:120)
	at org.datanucleus.store.rdbms.ConnectionFactoryImpl$ManagedConnectionImpl.getConnection(ConnectionFactoryImpl.java:483)
	at org.datanucleus.store.rdbms.RDBMSStoreManager.<init>(RDBMSStoreManager.java:296)
	at sun.reflect.GeneratedConstructorAccessor94.newInstance(Unknown Source)
	at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
	
result code:2
           

小廚查了很多資料,大部分都說jdbc的版本不對或者是hive-site.xml的配置檔案<value></value>處寫的不在一行,都一一試了,但是結果依然是報這個錯。後來開始剖析問題的本質,我的hive可以正常操作,說明并不是配置檔案或者jdbc版本的原因,原因應該在于:kylin在抽取事實表時不能跟hive的中繼資料庫連接配接,是以發現應該是kylin的問題。

解決方法:

這是由于kylin送出的任務交給mr後,hadoop叢集将任務分發給從節點時,需要hive的依賴資訊。平時我們隻将hive安裝在某一台節點上,進而導緻在slave節點上找不到hive的依賴資訊,是以出現上述錯誤,在此我們将master節點上的hive目錄發送到兩個slave節點,并且更改添加相關的/etc/profile環境變量内容.

#在master節點執行以下語句,将hive的檔案目錄拷貝到slave節點上
scp -r /usr/hive [email protected]:/usr
scp -r /usr/hive [email protected]:/usr