Flink之運行模式

Apache Flink 初識

Apache Flink作為Apache的頂級項目勇哗,固然集眾多優(yōu)點于一身。Flink具有分布式MR一類平臺的高效性辜伟,靈活性和擴展性菊霜。同時坚冀,F(xiàn)link 還支持批量和局域流的數(shù)據(jù)分析,而且提供基于Java和Scala的API鉴逞〖悄常總的來說,F(xiàn)link是一個分布式构捡,高性能液南,高可用,準確的勾徽,基于Java實現(xiàn)的通用大數(shù)據(jù)分析引擎滑凉。引用官網(wǎng)的一句話介紹Flink:基于數(shù)據(jù)流的有狀態(tài)計算-Stateful Computations over Data Streams。

flink.png

Flink運行模式

1:Flink和Spark一樣有三種部署模式喘帚,分別是Local,Standalone Cluster和Yarn Cluster畅姊。本文主要是介紹在Yarn Cluster模式下,F(xiàn)link任務(wù)的執(zhí)行和資源分配是如何的吹由!
flink 運行方式.png
2:啟動yarn-session時需要指定的參數(shù):
 Usage:
   Required
     -n,--container <arg>   Number of YARN container to allocate (=Number of Task Managers)
   Optional
     -D <property=value>             use value for given property
     -d,--detached                   If present, runs the job in detached mode
     -h,--help                       Help for the Yarn session CLI.
     -id,--applicationId <arg>       Attach to running YARN session
     -j,--jar <arg>                  Path to Flink jar file
     -jm,--jobManagerMemory <arg>    Memory for JobManager Container with optional unit (default: MB)
     -m,--jobmanager <arg>           Address of the JobManager (master) to which to connect. Use this flag to connect to a different JobManager than the one specified in the configuration.
     -n,--container <arg>            Number of YARN container to allocate (=Number of Task Managers)
     -nl,--nodeLabel <arg>           Specify YARN node label for the YARN application
     -nm,--name <arg>                Set a custom name for the application on YARN
     -q,--query                      Display available YARN resources (memory, cores)
     -qu,--queue <arg>               Specify YARN queue.
     -s,--slots <arg>                Number of slots per TaskManager
     -sae,--shutdownOnAttachedExit   If the job is submitted in attached mode, perform a best-effort cluster shutdown when the CLI is terminated abruptly, e.g., in response to a user interrupt, such
                                 as typing Ctrl + C.
     -st,--streaming                 Start Flink in streaming mode
     -t,--ship <arg>                 Ship files in the specified directory (t for transfer)
     -tm,--taskManagerMemory <arg>   Memory per TaskManager Container with optional unit (default: MB)
     -yd,--yarndetached              If present, runs the job in detached mode (deprecated; use non-YARN specific option instead)
     -z,--zookeeperNamespace <arg>   Namespace to create the Zookeeper sub-paths for high availability mode

第一種方式提交flink程序:

首先我們啟動yarn-session
./bin/yarn-session.sh -n 2 -s 2 -jm 2048 -tm 4096 -nm flink_session_cluster_20190320
yarn-session-方式1.png
然后我們在這個flink集群中提交任務(wù)若未,在我們提交任務(wù)的時候需要指定yid,yid就是我們上面開啟集群所屬的ID:application_1546585584446_0144倾鲫,這個時候提交的任務(wù)就會到我們開啟的集群中粗合。
flink run \
-yid application_1546585584446_0144 \
-c com.hfjy.bigdata.ls.nginx.parsenginx.AliyunOnlineParseNginx /opt/jars  /online_aliyun_ls_parse_nginx_test.jar \
--output ${elasticsearch} \
--ipDbPath /opt/lib/ \
--windowSize 10
yarn-session-job.png

第二種方式提交flink程序

./bin/flink 提交任務(wù)所需參數(shù):
"run" action options:
 -c,--class <classname>               Class with the program entry point
                                      ("main" method or "getPlan()" method.
                                      Only needed if the JAR file does not
                                      specify the class in its manifest.
 -C,--classpath <url>                 Adds a URL to each user code
                                      classloader  on all nodes in the
                                      cluster. The paths must specify a
                                      protocol (e.g. file://) and be
                                      accessible on all nodes (e.g. by means
                                      of a NFS share). You can use this
                                      option multiple times for specifying
                                      more than one URL. The protocol must
                                      be supported by the {@link
                                      java.net.URLClassLoader}.
 -d,--detached                        If present, runs the job in detached
                                      mode
 -n,--allowNonRestoredState           Allow to skip savepoint state that
                                      cannot be restored. You need to allow
                                      this if you removed an operator from
                                      your program that was part of the
                                      program when the savepoint was
                                      triggered.
 -p,--parallelism <parallelism>       The parallelism with which to run the
                                      program. Optional flag to override the
                                      default value specified in the
                                      configuration.
 -q,--sysoutLogging                   If present, suppress logging output to
                                      standard out.
 -s,--fromSavepoint <savepointPath>   Path to a savepoint to restore the job
                                      from (for example
                                      hdfs:///flink/savepoint-1537).
 -sae,--shutdownOnAttachedExit        If the job is submitted in attached
                                      mode, perform a best-effort cluster
                                      shutdown when the CLI is terminated
                                      abruptly, e.g., in response to a user
                                      interrupt, such as typing Ctrl + C.
Options for yarn-cluster mode:
 -d,--detached                        If present, runs the job in detached
                                      mode
 -m,--jobmanager <arg>                Address of the JobManager (master) to
                                      which to connect. Use this flag to
                                      connect to a different JobManager than
                                      the one specified in the
                                      configuration.
 -sae,--shutdownOnAttachedExit        If the job is submitted in attached
                                      mode, perform a best-effort cluster
                                      shutdown when the CLI is terminated
                                      abruptly, e.g., in response to a user
                                      interrupt, such as typing Ctrl + C.
 -yD <property=value>                 use value for given property
 -yd,--yarndetached                   If present, runs the job in detached
                                      mode (deprecated; use non-YARN
                                      specific option instead)
 -yh,--yarnhelp                       Help for the Yarn session CLI.
 -yid,--yarnapplicationId <arg>       Attach to running YARN session
 -yj,--yarnjar <arg>                  Path to Flink jar file
 -yjm,--yarnjobManagerMemory <arg>    Memory for JobManager Container with
                                      optional unit (default: MB)
 -yn,--yarncontainer <arg>            Number of YARN container to allocate
                                      (=Number of Task Managers)
 -ynl,--yarnnodeLabel <arg>           Specify YARN node label for the YARN
                                      application
 -ynm,--yarnname <arg>                Set a custom name for the application
                                      on YARN
 -yq,--yarnquery                      Display available YARN resources
                                      (memory, cores)
 -yqu,--yarnqueue <arg>               Specify YARN queue.
 -ys,--yarnslots <arg>                Number of slots per TaskManager
 -yst,--yarnstreaming                 Start Flink in streaming mode
 -yt,--yarnship <arg>                 Ship files in the specified directory
                                      (t for transfer)
 -ytm,--yarntaskManagerMemory <arg>   Memory per TaskManager Container with
                                      optional unit (default: MB)
 -yz,--yarnzookeeperNamespace <arg>   Namespace to create the Zookeeper
                                      sub-paths for high availability mode
 -z,--zookeeperNamespace <arg>        Namespace to create the Zookeeper
                                      sub-paths for high availability mode

Options for default mode:
 -m,--jobmanager <arg>           Address of the JobManager (master) to which
                                 to connect. Use this flag to connect to a
                                 different JobManager than the one specified
                                 in the configuration.
 -z,--zookeeperNamespace <arg>   Namespace to create the Zookeeper sub-paths
                                 for high availability mode
提交flink任務(wù)
flink run \
-m yarn-cluster \
-ynm AliyunNginxStudy2 \
-yn 1 \
-ys 3 \
-p 3 \
-yjm 2048m \
-ytm 8192m \
-c com.hfjy.bigdata.ls.nginx.parsenginx.AliyunOnlineParseNginx /opt/jars/online_aliyun_ls_parse_nginx_test.jar \
--output ${elasticsearch} \
--ipDbPath /opt/lib/ \
--windowSize 10
yarn-session-方式2.png

>>記錄學習過程萍嬉,文章中如有錯誤或不妥之處,請留言舌劳!<<
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末帚湘,一起剝皮案震驚了整個濱河市玫荣,隨后出現(xiàn)的幾起案子甚淡,更是在濱河造成了極大的恐慌,老刑警劉巖捅厂,帶你破解...
    沈念sama閱讀 218,607評論 6 507
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件贯卦,死亡現(xiàn)場離奇詭異,居然都是意外死亡焙贷,警方通過查閱死者的電腦和手機撵割,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,239評論 3 395
  • 文/潘曉璐 我一進店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來辙芍,“玉大人啡彬,你說我怎么就攤上這事」使瑁” “怎么了庶灿?”我有些...
    開封第一講書人閱讀 164,960評論 0 355
  • 文/不壞的土叔 我叫張陵,是天一觀的道長吃衅。 經(jīng)常有香客問我往踢,道長,這世上最難降的妖魔是什么徘层? 我笑而不...
    開封第一講書人閱讀 58,750評論 1 294
  • 正文 為了忘掉前任峻呕,我火速辦了婚禮,結(jié)果婚禮上趣效,老公的妹妹穿的比我還像新娘瘦癌。我一直安慰自己,他們只是感情好跷敬,可當我...
    茶點故事閱讀 67,764評論 6 392
  • 文/花漫 我一把揭開白布讯私。 她就那樣靜靜地躺著,像睡著了一般干花。 火紅的嫁衣襯著肌膚如雪妄帘。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,604評論 1 305
  • 那天池凄,我揣著相機與錄音抡驼,去河邊找鬼。 笑死肿仑,一個胖子當著我的面吹牛致盟,可吹牛的內(nèi)容都是我干的碎税。 我是一名探鬼主播,決...
    沈念sama閱讀 40,347評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼馏锡,長吁一口氣:“原來是場噩夢啊……” “哼雷蹂!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起杯道,我...
    開封第一講書人閱讀 39,253評論 0 276
  • 序言:老撾萬榮一對情侶失蹤匪煌,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后党巾,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體萎庭,經(jīng)...
    沈念sama閱讀 45,702評論 1 315
  • 正文 獨居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,893評論 3 336
  • 正文 我和宋清朗相戀三年齿拂,在試婚紗的時候發(fā)現(xiàn)自己被綠了驳规。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點故事閱讀 40,015評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡署海,死狀恐怖吗购,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情砸狞,我是刑警寧澤捻勉,帶...
    沈念sama閱讀 35,734評論 5 346
  • 正文 年R本政府宣布,位于F島的核電站趾代,受9級特大地震影響贯底,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜撒强,卻給世界環(huán)境...
    茶點故事閱讀 41,352評論 3 330
  • 文/蒙蒙 一禽捆、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧飘哨,春花似錦胚想、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,934評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至胚吁,卻和暖如春牙躺,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背腕扶。 一陣腳步聲響...
    開封第一講書人閱讀 33,052評論 1 270
  • 我被黑心中介騙來泰國打工孽拷, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人半抱。 一個月前我還...
    沈念sama閱讀 48,216評論 3 371
  • 正文 我出身青樓脓恕,卻偏偏與公主長得像膜宋,于是被迫代替她去往敵國和親。 傳聞我的和親對象是個殘疾皇子炼幔,可洞房花燭夜當晚...
    茶點故事閱讀 44,969評論 2 355

推薦閱讀更多精彩內(nèi)容