Flink1.8 集群搭建完全指南(5):Flink on Yarn

在准备好Hadoop的环境后,可以开始搭建Flink了。

这里我们参考的是这篇教程,其中包括很全面的安装步骤:https://files.alicdn.com/tpsservice/4824447b829149c86bedd19424d05915.pdf

这里我们的服务器列表和之前Hadoop是相同的:
我们现在有3台服务器,服务器列表如下:

hostname ip 作用
master 10.16.. JobManager, NodeManager
slave1 10.16.. NodeManager
slave2 10.16.. NodeManager

1. 下载并配置Flink

1.1 下载Flink

在Flink的官网下载Binary的安装包到master的/data目录下,并解压,下载Hadoop的扩展库:

$ wget http://mirrors.tuna.tsinghua.edu.cn/apache/flink/flink-1.8.0/flink-1.8.0-bin-scala_2.12.tgz
$ tar -xvf flink-1.8.0-bin-scala_2.12.tgz
$ cd flink-1.8.0/lib
$ wget https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/2.8.3-7.0/flink-shaded-hadoop-2-uber-2.8.3-7.0.jar
1.2 修改Flink的配置文件

Flink的配置文件在目录:/data/flink-1.8.0/conf

  • 修改masters:
master
  • 修改slaves:
master
slave1
slave2
  • 修改flink-conf.yaml:
jobmanager.rpc.address: master
1.3 拷贝Flink到其他机器

将master的flink目录拷贝到其他机器的相同目录:

scp -r /data/flink-1.8.0 root@slave1:/data
scp -r /data/flink-1.8.0 root@slave2:/data

2. 启动Flink

如果想通过Yarn实现资源管理,需要先在Yarn启动Flink,然后再执行Flink的程序。

2.1 启动Flink Yarn Session
$ ./bin/yarn-session.sh -n 4 -jm 1024m -tm 4096m
2019-07-01 22:43:04,154 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: jobmanager.rpc.address, ads-data-web-online012-bjdxt9p
2019-07-01 22:43:04,155 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: jobmanager.rpc.port, 6123
2019-07-01 22:43:04,155 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: jobmanager.heap.size, 1024m
2019-07-01 22:43:04,155 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: taskmanager.heap.size, 1024m
2019-07-01 22:43:04,156 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: taskmanager.numberOfTaskSlots, 1
2019-07-01 22:43:04,156 INFO  org.apache.flink.configuration.GlobalConfiguration            - Loading configuration property: parallelism.default, 1
2019-07-01 22:43:04,607 WARN  org.apache.hadoop.util.NativeCodeLoader                       - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2019-07-01 22:43:04,719 INFO  org.apache.flink.runtime.security.modules.HadoopModule        - Hadoop user set to hdfs/master@HADOOP.COM (auth:KERBEROS)
2019-07-01 22:43:04,775 INFO  org.apache.hadoop.yarn.client.RMProxy                         - Connecting to ResourceManager at /master:8032
2019-07-01 22:43:04,913 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - The argument n is deprecated in will be ignored.
2019-07-01 22:43:05,099 WARN  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Neither the HADOOP_CONF_DIR nor the YARN_CONF_DIR environment variable is set. The Flink YARN Client needs one of these to be set to properly load the Hadoop configuration for accessing YARN.
2019-07-01 22:43:05,152 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Cluster specification: ClusterSpecification{masterMemoryMB=1024, taskManagerMemoryMB=4096, numberTaskManagers=4, slotsPerTaskManager=1}
2019-07-01 22:43:05,595 WARN  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - The configuration directory ('/data/flink-1.8.0/conf') contains both LOG4J and Logback configuration files. Please delete or rename one of them.
2019-07-01 22:43:07,827 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Adding delegation token to the AM container..
2019-07-01 22:43:07,836 INFO  org.apache.hadoop.hdfs.DFSClient                              - Created HDFS_DELEGATION_TOKEN token 3 for hdfs on 10.16.195.254:9000
2019-07-01 22:43:07,848 INFO  org.apache.hadoop.mapreduce.security.TokenCache               - Got dt for hdfs://10.16.195.254:9000; Kind: HDFS_DELEGATION_TOKEN, Service: 10.16.195.254:9000, Ident: (HDFS_DELEGATION_TOKEN token 3 for hdfs)
2019-07-01 22:43:07,848 INFO  org.apache.flink.yarn.Utils                                   - Attempting to obtain Kerberos security token for HBase
2019-07-01 22:43:07,848 INFO  org.apache.flink.yarn.Utils                                   - HBase is not available (not packaged with this application): ClassNotFoundException : "org.apache.hadoop.hbase.HBaseConfiguration".
2019-07-01 22:43:07,857 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Submitting application master application_1562035367237_0001
2019-07-01 22:43:08,384 INFO  org.apache.hadoop.yarn.client.api.impl.YarnClientImpl         - Submitted application application_1562035367237_0001
2019-07-01 22:43:08,384 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Waiting for the cluster to be allocated
2019-07-01 22:43:08,386 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Deploying cluster, current state ACCEPTED
2019-07-01 22:43:14,953 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - YARN application has been deployed successfully.
2019-07-01 22:43:15,564 INFO  org.apache.flink.runtime.rest.RestClient                      - Rest client endpoint started.
Flink JobManager is now running on master:1315 with leader id 00000000-0000-0000-0000-000000000000.
JobManager Web Interface: http://master:1315

启动后,可以打开JobManager的管理页面,地址在日志中。在yarn的管理页面中也可以看到一个运行中的应用:


yarn
2.2 执行示例程序

执行Flink的examples程序:

$ /bin/flink run examples/streaming/WordCount.jar --input hdfs:///user/hdfs/input_dir --output hdfs:///user/hdfs/output_dir
2019-07-01 22:46:45,084 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - Found Yarn properties file under /tmp/.yarn-properties-root.
2019-07-01 22:46:45,084 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - Found Yarn properties file under /tmp/.yarn-properties-root.
2019-07-01 22:46:45,603 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - YARN properties set default parallelism to 4
2019-07-01 22:46:45,603 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - YARN properties set default parallelism to 4
YARN properties set default parallelism to 4
2019-07-01 22:46:45,636 INFO  org.apache.hadoop.yarn.client.RMProxy                         - Connecting to ResourceManager at /10.16.195.254:8032
2019-07-01 22:46:45,774 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - No path for the flink jar passed. Using the location of class org.apache.flink.yarn.YarnClusterDescriptor to locate the jar
2019-07-01 22:46:45,774 INFO  org.apache.flink.yarn.cli.FlinkYarnSessionCli                 - No path for the flink jar passed. Using the location of class org.apache.flink.yarn.YarnClusterDescriptor to locate the jar
2019-07-01 22:46:45,778 WARN  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Neither the HADOOP_CONF_DIR nor the YARN_CONF_DIR environment variable is set.The Flink YARN Client needs one of these to be set to properly load the Hadoop configuration for accessing YARN.
2019-07-01 22:46:45,960 INFO  org.apache.flink.yarn.AbstractYarnClusterDescriptor           - Found application JobManager host name 'host name' and port '1315' from supplied application id 'application_1562035367237_0001'
Starting execution of program
Program execution finished
Job with JobID f1a63f47e44521d457773c3e0acab80b has finished.
Job Runtime: 256 ms

以上,便完成了Flink在Yarn上的安装和部署,更多关于Flink安装的细节,可以参考文章开始的文档,其中的内容讲解很详细。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 219,490评论 6 508
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 93,581评论 3 395
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 165,830评论 0 356
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,957评论 1 295
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,974评论 6 393
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,754评论 1 307
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,464评论 3 420
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,357评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,847评论 1 317
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,995评论 3 338
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 40,137评论 1 351
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,819评论 5 346
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,482评论 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 32,023评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 33,149评论 1 272
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,409评论 3 373
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 45,086评论 2 355