??????????????????????????????????



------------------ ???????? ------------------
??????:                                                                         
                                               "MuChen"                         
                                                           <[email protected]&gt;;
????????:&nbsp;2020??9??7??(??????) ????11:01
??????:&nbsp;"user-zh"<[email protected]&gt;;

????:&nbsp;?????? ????StreamingFileSink??hive metadata??????????????????



hi,jingsong:


??????????????????????????
https://s1.ax1x.com/2020/09/07/wn1CFg.png


checkpoint??????????
2020-09-04 17:17:59
org.apache.flink.util.FlinkRuntimeException: Exceeded checkpoint tolerable 
failure threshold.
&nbsp;&nbsp;&nbsp; at 
org.apache.flink.runtime.checkpoint.CheckpointFailureManager.handleJobLevelCheckpointException(CheckpointFailureManager.java:66)
&nbsp;&nbsp;&nbsp; at 
org.apache.flink.runtime.checkpoint.CheckpointCoordinator.abortPendingCheckpoint(CheckpointCoordinator.java:1626)
&nbsp;&nbsp;&nbsp; at 
org.apache.flink.runtime.checkpoint.CheckpointCoordinator.abortPendingCheckpoint(CheckpointCoordinator.java:1603)
&nbsp;&nbsp;&nbsp; at 
org.apache.flink.runtime.checkpoint.CheckpointCoordinator.access$600(CheckpointCoordinator.java:90)
&nbsp;&nbsp;&nbsp; at 
org.apache.flink.runtime.checkpoint.CheckpointCoordinator$CheckpointCanceller.run(CheckpointCoordinator.java:1736)
&nbsp;&nbsp;&nbsp; at 
java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
&nbsp;&nbsp;&nbsp; at java.util.concurrent.FutureTask.run(FutureTask.java:266)
&nbsp;&nbsp;&nbsp; at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
&nbsp;&nbsp;&nbsp; at 
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
&nbsp;&nbsp;&nbsp; at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
&nbsp;&nbsp;&nbsp; at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
&nbsp;&nbsp;&nbsp; at java.lang.Thread.run(Thread.java:748)





------------------ ???????? ------------------
??????:                                                                         
                                               "user-zh"                        
                                                            
<[email protected]&gt;;
????????:&nbsp;2020??9??7??(??????) ????10:55
??????:&nbsp;"user-zh"<[email protected]&gt;;

????:&nbsp;Re: ????StreamingFileSink??hive metadata??????????????????



????????????????????????????????

On Mon, Sep 7, 2020 at 10:23 AM MuChen <[email protected]&gt; wrote:

&gt; hi, all??
&gt; ????????????????????????????
&gt;
&gt; ????????????
&gt; 1. ????DataStream API????kafka??????????????DataStream ds1??
&gt; 2. ????????tableEnv????????hive catalog??
&gt;&nbsp;&nbsp; &nbsp; tableEnv.registerCatalog(catalogName, catalog);
&gt;&nbsp;&nbsp; &nbsp; tableEnv.useCatalog(catalogName);
&gt; 3. ??????ds1??????????table
&gt;&nbsp;&nbsp; &nbsp; Table sourcetable = tableEnv.fromDataStream(ds1);
&gt;&nbsp;&nbsp; &nbsp; String souceTableName = "music_source";
&gt;&nbsp;&nbsp; &nbsp; tableEnv.createTemporaryView(souceTableName, 
sourcetable);
&gt; 4. ????????hive????
&gt;
&gt; CREATE TABLE `dwd_music_copyright_test`(
&gt; &nbsp; `url` string COMMENT 'url',
&gt; &nbsp; `md5` string COMMENT 'md5',
&gt; &nbsp; `utime` bigint COMMENT '????',
&gt; &nbsp; `title` string COMMENT '??????',
&gt; &nbsp; `singer` string COMMENT '??????',
&gt; &nbsp; `company` string COMMENT '????',
&gt; &nbsp; `level` int COMMENT 
'??????.0??????????,1??acrcloud??????????,3??????????')
&gt; PARTITIONED BY (
&gt; &nbsp; `dt` string,
&gt; &nbsp; `hour` string)ROW FORMAT SERDE
&gt; &nbsp; 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'STORED 
AS INPUTFORMAT
&gt; &nbsp; 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
&gt; OUTPUTFORMAT
&gt; &nbsp; 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
&gt; LOCATION
&gt; &nbsp; 
'hdfs://Ucluster/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test'
&gt; TBLPROPERTIES (
&gt; &nbsp; 'connector'='HiveCatalog',
&gt; &nbsp; 'partition.time-extractor.timestamp-pattern'='$dt $hour:00:00',
&gt; &nbsp; 'sink.partition-commit.delay'='1 min',
&gt; &nbsp; 'sink.partition-commit.policy.kind'='metastore,success-file',
&gt; &nbsp; 'sink.partition-commit.trigger'='partition-time',
&gt; &nbsp; 'sink.rolling-policy.check-interval'='30s',
&gt; &nbsp; 'sink.rolling-policy.rollover-interval'='1min',
&gt; &nbsp; 'sink.rolling-policy.file-size'='1MB');
&gt;
&gt;
&gt; 5. ??step3??????????????dwd_music_copyright_test
&gt;
&gt; ????
&gt;
&gt; flink:1.11
&gt; kafka:1.1.1
&gt; hadoop:2.6.0
&gt; hive:1.2.0
&gt;
&gt; ????
&gt;&nbsp;&nbsp; &nbsp; ????????????????hive 
catalog??????????????????????????????????hour=02??hour=03??????
&gt;
&gt; show partitions rt_dwd.dwd_music_copyright_test;
&gt;
&gt; | dt=2020-08-29/hour=00&nbsp; |
&gt; | dt=2020-08-29/hour=01&nbsp; |
&gt; | dt=2020-08-29/hour=04&nbsp; |
&gt; | dt=2020-08-29/hour=05&nbsp; |
&gt;
&gt;&nbsp; ????hdfs??????????????????
&gt;
&gt; $ hadoop fs -du -h 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/4.5 K 
&nbsp; 13.4 K&nbsp; 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/hour=002.0
 K &nbsp; 6.1 K &nbsp; 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/hour=011.7
 K &nbsp; 5.1 K &nbsp; 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/hour=021.3
 K &nbsp; 3.8 K &nbsp; 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/hour=033.1
 K &nbsp; 9.2 K &nbsp; 
/user/hive/warehouse/rt_dwd.db/dwd_music_copyright_test/dt=2020-08-29/hour=04
&gt;
&gt;
&gt; ??????add partition????????????????????
&gt;
&gt; ????flink 
WebUI??????????????????checkpoint??StreamingFileCommitter??????????????????
&gt;
&gt;
&gt;
&gt;
&gt;
&gt; ??????
&gt;
&gt; 1. exactly-once??????????sink??????????????????catalog????
&gt; 2. ????????????????????????????????
&gt; 3.
&gt; 
EXACTLY_ONCE??????????????kafka????isolation.level=read_committed??enable.auto.commit=false??????????????????????????????EXACTLY_ONCE??
&gt;
&gt; 
streamEnv.getCheckpointConfig().setCheckpointingMode(CheckpointingMode.EXACTLY_ONCE);tableEnv.getConfig().getConfiguration().set(ExecutionCheckpointingOptions.CHECKPOINTING_MODE,
 CheckpointingMode.EXACTLY_ONCE);
&gt;
&gt;

-- 
Best, Jingsong Lee

回复