您好,登錄后才能下訂單哦!
遇到的坑:
1、 Hive的任務會從臨時目錄移動數據到數據倉庫目錄,默認hive使用/tmp作為臨時目錄,用戶通常使用/user/hive/warehouse/作為數據倉庫目錄。在Federated HDFS情況下,/tmp 和 /user視為兩個不同的ViewFS mount table,所以hive任務在這兩個目錄之間移動數據。Federated HDFS不支持這樣做,所以任務會失敗。
報錯信息:
ERROR : Failed with exception Unable to move sourceviewfs://cluster9/tmp/.hive-staging_hive_2015-07-29_12-34-11_306_6082682065011532871-5/-ext-10002to destinationviewfs://cluster9/user/hive/warehouse/tandem.db/cust_loss_alarm_unit
org.apache.hadoop.hive.ql.metadata.HiveException: Unable to movesourceviewfs://cluster9/tmp/warehouse/.hive-staging_hive_2015-07-29_12-34-11_306_6082682065011532871-5/-ext-10002to destinationviewfs://cluster9/user/hive/warehouse/tandem.db/cust_loss_alarm_unit
atorg.apache.hadoop.hive.ql.metadata.Hive.moveFile(Hive.java:2521)
atorg.apache.hadoop.hive.ql.exec.MoveTask.moveFile(MoveTask.java:105)
atorg.apache.hadoop.hive.ql.exec.MoveTask.execute(MoveTask.java:222)
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)
atorg.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:88)
atorg.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1640)
atorg.apache.hadoop.hive.ql.Driver.execute(Driver.java:1399)
atorg.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1183)
atorg.apache.hadoop.hive.ql.Driver.run(Driver.java:1049)
atorg.apache.hadoop.hive.ql.Driver.run(Driver.java:1044)
at org.apache.hive.service.cli.operation.SQLOperation.runQuery(SQLOperation.java:144)
atorg.apache.hive.service.cli.operation.SQLOperation.access$100(SQLOperation.java:69)
atorg.apache.hive.service.cli.operation.SQLOperation$1$1.run(SQLOperation.java:196)
atjava.security.AccessController.doPrivileged(Native Method)
atjavax.security.auth.Subject.doAs(Subject.java:415)
atorg.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1671)
at org.apache.hive.service.cli.operation.SQLOperation$1.run(SQLOperation.java:208)
atjava.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
atjava.util.concurrent.FutureTask.run(FutureTask.java:262)
atjava.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
atjava.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
atjava.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Renames across Mount points notsupported
atorg.apache.hadoop.fs.viewfs.ViewFileSystem.rename(ViewFileSystem.java:444)
atorg.apache.hadoop.hive.ql.metadata.Hive.moveFile(Hive.java:2509)
... 21 more
相關代碼:
org.apache.hadoop.fs.viewfs.ViewFileSystem
/**
// Alternate 1: renames within same file system -valid but we disallow
// Alternate 2: (as described in next para - valid butwe have disallowed it
//
// Note we compare the URIs. the URIs include the linktargets.
// hence we allow renames across mount links as longas the mount links
// point to the same target.
if (!re***c.targetFileSystem.getUri().equals(
resDst.targetFileSystem.getUri())) {
throw new IOException("Renames acrossMount points not supported");
}
*/
//
// Alternate 3 : renames ONLY within the the samemount links.
//
if (re***c.targetFileSystem!=resDst.targetFileSystem) {
throw new IOException("Renames acrossMount points not supported");
}
Workaround:
a、在hdfs中 創建 /user/hive/warehouse/staging 目錄,賦予777權限
然后添加配置:
<property>
<name>hive.exec.stagingdir</name>
<value>/user/hive/warehouse/staging/.hive-staging</value>
</property>
b、 只創建一個加載點如 /cluser 然后在此加載點下創建/tmp /user等目錄,最后修改hive相關目錄的默認值。
2、 當查詢返回結果集很大的時候,beeline客戶端會卡住或out-of-memory
報錯信息:
org.apache.thrift.TException: Error in calling method FetchResults
atorg.apache.hive.jdbc.HiveConnection$SynchronizedHandler.invoke(HiveConnection.java:1271)
atcom.sun.proxy.$Proxy0.FetchResults(Unknown Source)
atorg.apache.hive.jdbc.HiveQueryResultSet.next(HiveQueryResultSet.java:363)
at org.apache.hive.beeline.BufferedRows.<init>(BufferedRows.java:42)
atorg.apache.hive.beeline.BeeLine.print(BeeLine.java:1756)
atorg.apache.hive.beeline.Commands.execute(Commands.java:806)
atorg.apache.hive.beeline.Commands.sql(Commands.java:665)
atorg.apache.hive.beeline.BeeLine.dispatch(BeeLine.java:974)
atorg.apache.hive.beeline.BeeLine.execute(BeeLine.java:810)
atorg.apache.hive.beeline.BeeLine.begin(BeeLine.java:767)
at org.apache.hive.beeline.BeeLine.mainWithInputRedirection(BeeLine.java:480)
atorg.apache.hive.beeline.BeeLine.main(BeeLine.java:463)
atsun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:606)
atorg.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.lang.OutOfMemoryError: Java heap space
atjava.lang.Double.valueOf(Double.java:521)
Workaround:
查看源碼發現:beeline獲取結果集有兩種模式一種增量模式,一種buffer模式
org.apache.hive.beeline.BeeLine
int print(ResultSet rs) throws SQLException {
String format = getOpts().getOutputFormat();
OutputFormat f = (OutputFormat)formats.get(format);
if (f == null) {
error(loc("unknown-format", new Object[] {
format,formats.keySet()}));
f = new TableOutputFormat(this);
}
Rows rows;
if (getOpts().getIncremental()) {
rows = new IncrementalRows(this,rs); // 增量模式
} else {
rows = new BufferedRows(this, rs);buffer模式
}
return f.print(rows);
}
org.apache.hive.beeline.BeeLineOpts
private boolean incremental = false; //默認為buffer模式
但是通過beeline –help沒有發現相關設置
beeline --help
Usage: java org.apache.hive.cli.beeline.BeeLine
-u <databaseurl> the JDBC URL to connect to
-n <username> the username to connect as
-p<password> the password to connect as
-d <driverclass> the driver class to use
-i <initfile> script file for initialization
-e<query> query that should be executed
-f <execfile> script file that should be executed
-w (or) --password-file <password file> the password file to read password from
--hiveconfproperty=value Use value for given property
--hivevarname=value hive variable name and value
This is Hive specific settings in which variables
can be set at session level and referenced in Hive
commands or queries.
--color=[true/false] control whether color is used for display
--showHeader=[true/false] show column namesin query results
--headerInterval=ROWS; the interval between which heades are displayed
--fastConnect=[true/false] skip buildingtable/column list for tab-completion
--autoCommit=[true/false] enable/disableautomatic transaction commit
--verbose=[true/false] show verbose error messages and debug info
--showWarnings=[true/false] display connection warnings
--showNestedErrs=[true/false] displaynested errors
--numberFormat=[pattern] formatnumbers using DecimalFormat pattern
--force=[true/false] continue running script even after errors
--maxWidth=MAXWIDTH the maximum width of the terminal
--maxColumnWidth=MAXCOLWIDTH themaximum width to use when displaying columns
--silent=[true/false] be more silent
--autosave=[true/false] automatically save preferences
--outputformat=[table/vertical/csv2/tsv2/dsv/csv/tsv] format mode forresult display
Note that csv, and tsv are deprecated - use csv2, tsv2 instead
--truncateTable=[true/false] truncatetable column when it exceeds length
--delimiterForDSV=DELIMITER specify the delimiter for delimiter-separated values output format (default: |)
--isolation=LEVEL set the transaction isolation level
--nullemptystring=[true/false] set to true toget historic behavior of printing null as empty string
--help display this message
Beeline version 1.1.0-cdh6.4.3 by Apache Hive
但是沒關系通過
beeline -u jdbc:hive2://10.17.28.173:10000 –n xxxx -pxxxx --incremental=true 還是能進入增量模式
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。