Flink1.11.2 On Yarn安装部署笔记

环境

  • jdk:jdk-8u144-linux-x64.tar.gz
  • zookeeper:zookeeper-3.4.10.tar.gz
  • hadoop:hadoop-2.8.5.tar.gz
  • flink:flink-1.11.2-bin-scala_2.11.tgz

部署jdk

安装jdk1.8

 tar -zxvf jdk-8u144-linux-x64.tar.gz -C /opt/module/

修改文件名

mv jdk1.8.0_144 jdk1.8

配置环境变量
vim /etc/profile

#jdk
export JAVA_HOME=/opt/module/jdk1.8
export CLASSPATH=$JAVA_HOME/lib/
export PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH

执行 source /etc/profile

部署zookeeper

已经安装好了,这里不再重复记录。

部署Hadoop

配置环境变量

export HADOOP_HOME=/opt/module/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export PATH=$PATH:$HADOOP_HOME/sbin
export HADOOP_CONF_DIR=/opt/module/hadoop/etc/hadoop
export YARN_CONF_DIR=/opt/module/hadoop/etc/hadoop

需要修改的配置文件

hadoop-env.sh
core-site.xml
hdfs-site.xml
mapred-site.xml
yarn-site.xml
masters
slaves

vim hadoop-env.sh

export JAVA_HOME=/opt/module/jdk1.8

vim core-site.xml

<configuration>
<!-- 指定HDFS中NameNode的地址 -->
 <property>
    <name>fs.defaultFS</name>
    <value>hdfs://ns/</value>
 </property>
<!-- 指定Hadoop运行时产生文件的存储目录 -->
 <property>
    <name>hadoop.tmp.dir</name>
    <value>/opt/module/hadoop/data/tmp</value>
 </property>
<property>
    <name>ha.zookeeper.quorum</name>
    <value>hadoop-01:2181,hadoop-02:2181,hadoop-03:2181</value>
</property>
<property>
    <name>hadoop.proxyuser.root.groups</name>
    <value>*</value>
</property>
<property>
    <name>hadoop.proxyuser.root.hosts</name>
    <value>*</value>
</property>
</configuration>

vim hdfs-site.xml

<configuration>
<property>
    <name>dfs.replication</name>
    <value>2</value>
 </property>
<!--指定hdfs的nameservice为ns,需要和core-site.xml中的保持一致 -->
 <property>
    <name>dfs.nameservices</name>
    <value>ns</value>
 </property>
<!-- ns下面有两个NameNode,分别是nn1,nn2 -->
 <property>
    <name>dfs.ha.namenodes.ns</name>
    <value>nn1,nn2</value>
 </property>
<!-- nn1的RPC通信地址 -->
 <property>
    <name>dfs.namenode.rpc-address.ns.nn1</name>
    <value>hadoop-01:9000</value>
 </property>
<!-- nn1的http通信地址 -->
 <property>
    <name>dfs.namenode.http-address.ns.nn1</name>
    <value>hadoop-01:50070</value>
 </property>
<!-- nn2的RPC通信地址 -->
 <property>
    <name>dfs.namenode.rpc-address.ns.nn2</name>
    <value>hadoop-02:9000</value>
 </property>
<!-- nn2的http通信地址 -->
 <property>
    <name>dfs.namenode.http-address.ns1.nn2</name>
    <value>hadoop-02:50070</value>
 </property>
<!-- 指定NameNode的元数据在JournalNode上的存放位置 -->
 <property>
    <name>dfs.namenode.shared.edits.dir</name>
    <value>qjournal://hadoop-01:8485;hadoop-02:8485;hadoop-03:8485/ns</value>
 </property>
<!-- 指定JournalNode在本地磁盘存放数据的位置 -->
 <property>
    <name>dfs.journalnode.edits.dir</name>
    <value>/opt/module/hadoop/journaldata</value>
 </property>
<!-- 开启NameNode失败自动切换 -->
 <property>
    <name>dfs.ha.automatic-failover.enabled</name>
    <value>true</value>
 </property>
<!-- 配置失败自动切换实现方式 -->
 <property>
    <name>dfs.client.failover.proxy.provider.ns</name>
    <value>org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider</value>
 </property>
<!-- 配置隔离机制方法,多个机制用换行分割,即每个机制暂用一行-->
 <property>
    <name>dfs.ha.fencing.methods</name>
    <value>sshfence</value>
 </property>
<!-- 使用sshfence隔离机制时需要ssh免登陆 -->
 <property>
    <name>dfs.ha.fencing.ssh.private-key-files</name>
    <value>/root/.ssh/id_rsa</value>
 </property>
<!-- 配置sshfence隔离机制超时时间 -->
 <property>
    <name>dfs.ha.fencing.ssh.connect-timeout</name>
    <value>30000</value>
 </property>
 <property>
   <name>dfs.ha.automatic-failover.enabled.ns</name>
   <value>true</value>
 </property>
</configuration>

vim mapred-site.xml

<configuration>
<property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
</property>
<property>
        <name>mapreduce.reduce.memory.mb</name>
        <value>54</value>
</property>

<property>
        <name>mapreduce.map.memory.mb</name>
        <value>128</value>
</property>
</configuration>

vim yarn-site.xml

<configuration>
<!-- 开启RM高可用 -->
<property>
    <name>yarn.resourcemanager.ha.enabled</name>
    <value>true</value>
</property>
<property>
    <name>yarn.nodemanager.vmem-check-enabled</name>
    <value>false</value>
</property>
<!-- 指定RM的cluster id -->
<property>
    <name>yarn.resourcemanager.cluster-id</name>
    <value>yrc</value>
</property>
<!-- 指定RM的名字 -->
<property>
    <name>yarn.resourcemanager.ha.rm-ids</name>
    <value>rm1,rm2</value>
</property>
<!-- 分别指定RM的地址 -->
<property>
    <name>yarn.resourcemanager.hostname.rm1</name>
    <value>hadoop-02</value>
</property>
<property>
    <name>yarn.resourcemanager.hostname.rm2</name>
    <value>hadoop-03</value>
</property>
<property>
    <name>yarn.resourcemanager.webapp.address.rm1</name>
    <value>hadoop-02:8088</value>
</property>
<property>
    <name>yarn.resourcemanager.webapp.address.rm2</name>
    <value>hadoop-03:8088</value>
</property>
<!-- 指定zk集群地址 -->
<property>
    <name>yarn.resourcemanager.zk-address</name>
    <value>hadoop-01:2181,hadoop-02:2181,hadoop-03:2181</value>
</property>
<property>
    <name>yarn.nodemanager.aux-services</name>
    <value>mapreduce_shuffle</value>
</property>
<property>
    <name>yarn.resourcemanager.recovery.enabled</name>
    <value>true</value>
</property>
<property>
    <name>yarn.resourcemanager.store.class</name>
    <value>org.apache.hadoop.yarn.server.resourcemanager.recovery.ZKRMStateStore</value>
</property>

<property>
    <name>yarn.nodemanager.resource.memory-mb</name>
    <value>10240</value>
</property>

<property>
    <name>yarn.scheduler.minimum-allocation-mb</name>
    <value>1024</value>
</property>

<property>
    <name>yarn.scheduler.maximum-allocation-mb</name>
    <value>10240</value>
</property>

<property>
    <name>yarn.resourcemanager.am.max-attempts</name>
    <value>4</value>
<description>The maximum number of application master execution attempts.</description>
</property>
</configuration>

vim masters

hadoop-01
hadoop-02

vim slaves

hadoop-01
hadoop-02
hadoop-03

启动journalnode

hadoop-daemons.sh start journalnode

格式化HDFS

hadoop namenode -format

将格式化后生成的hadoop的数据文件都在hadoop-01节点上,需要将hadoop-01节点上的数据同步到hadoop-02节点上,因为hadoop-01节点和hadoop-02节点是ha,这里我直接复制

scp -r /opt/module/hadoop/ root@hadoop-02:/opt/module/

初始化zk

hdfs zkfc -formatZK

启动hdfs

start-dfs.sh

切换到hadoop-02启动yarn

start-yarn.sh

在这里插入图片描述
在这里插入图片描述

安装Flink

官方文档
https://ci.apache.org/projects/flink/flink-docs-release-1.11/ops/jobmanager_high_availability.html

配置环境变量(export HADOOP_CLASSPATH=hadoop classpath官网要求)

##FLINK_HOME
export FLINK_HOME=/opt/module/flink
export PATH=$PATH:$FLINK_HOME/bin
export HADOOP_CLASSPATH=`hadoop classpath`

相关配置文件

flink-conf.yaml
masters
slaves
zoo.cfg

vim flink-conf.yaml

################################################################################
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
# limitations under the License.
################################################################################


#==============================================================================
# Common
#==============================================================================

# The external address of the host on which the JobManager runs and can be
# reached by the TaskManagers and any clients which want to connect. This setting
# is only used in Standalone mode and may be overwritten on the JobManager side
# by specifying the --host <hostname> parameter of the bin/jobmanager.sh executable.
# In high availability mode, if you use the bin/start-cluster.sh script and setup
# the conf/masters file, this will be taken care of automatically. Yarn/Mesos
# automatically configure the host name based on the hostname of the node where the
# JobManager runs.

jobmanager.rpc.address: hadoop-01

# The RPC port where the JobManager is reachable.

jobmanager.rpc.port: 6123


# The total process memory size for the JobManager.
#
# Note this accounts for all memory usage within the JobManager process, including JVM metaspace and other overhead.

jobmanager.memory.process.size: 1600m


# The total process memory size for the TaskManager.
#
# Note this accounts for all memory usage within the TaskManager process, including JVM metaspace and other overhead.

taskmanager.memory.process.size: 1728m

# To exclude JVM metaspace and overhead, please, use total Flink memory size instead of 'taskmanager.memory.process.size'.
# It is not recommended to set both 'taskmanager.memory.process.size' and Flink memory.
#
# taskmanager.memory.flink.size: 1280m

# The number of task slots that each TaskManager offers. Each slot runs one parallel pipeline.

taskmanager.numberOfTaskSlots: 1

# The parallelism used for programs that did not specify and other parallelism.

parallelism.default: 1

# The default file system scheme and authority.
# 
# By default file paths without scheme are interpreted relative to the local
# root file system 'file:///'. Use this to override the default and interpret
# relative paths relative to a different file system,
# for example 'hdfs://mynamenode:12345'
#
# fs.default-scheme

#==============================================================================
# High Availability
#==============================================================================

# The high-availability mode. Possible options are 'NONE' or 'zookeeper'.
#
high-availability: zookeeper

# The path where metadata for master recovery is persisted. While ZooKeeper stores
# the small ground truth for checkpoint and leader election, this location stores
# the larger objects, like persisted dataflow graphs.
# 
# Must be a durable file system that is accessible from all nodes
# (like HDFS, S3, Ceph, nfs, ...) 
#
high-availability.storageDir: hdfs://ns/flink/ha/

# The list of ZooKeeper quorum peers that coordinate the high-availability
# setup. This must be a list of the form:
# "host1:clientPort,host2:clientPort,..." (default clientPort: 2181)
#
high-availability.zookeeper.quorum: hadoop-01:2181,hadoop-02:2181,hadoop-03:2181


# ACL options are based on https://zookeeper.apache.org/doc/r3.1.2/zookeeperProgrammers.html#sc_BuiltinACLSchemes
# It can be either "creator" (ZOO_CREATE_ALL_ACL) or "open" (ZOO_OPEN_ACL_UNSAFE)
# The default value is "open" and it can be changed to "creator" if ZK security is enabled
#
# high-availability.zookeeper.client.acl: open

high-availability.zookeeper.path.root: /flink


#==============================================================================
# Fault tolerance and checkpointing
#==============================================================================

# The backend that will be used to store operator state checkpoints if
# checkpointing is enabled.
#
# Supported backends are 'jobmanager', 'filesystem', 'rocksdb', or the
# <class-name-of-factory>.
#
state.backend: filesystem

# Directory for checkpoints filesystem, when using any of the default bundled
# state backends.
#
state.checkpoints.dir: hdfs://ns/flink/checkpoints

# Default target directory for savepoints, optional.
#
state.savepoints.dir: hdfs://ns/flink/savepoints

# Flag to enable/disable incremental checkpoints for backends that
# support incremental checkpoints (like the RocksDB state backend). 
#
# state.backend.incremental: false

# The failover strategy, i.e., how the job computation recovers from task failures.
# Only restart tasks that may have been affected by the task failure, which typically includes
# downstream tasks and potentially upstream tasks if their produced data is no longer available for consumption.

jobmanager.execution.failover-strategy: region

#==============================================================================
# Rest & web frontend
#==============================================================================

# The port to which the REST client connects to. If rest.bind-port has
# not been specified, then the server will bind to this port as well.
#
rest.port: 9081

# The address to which the REST client will connect to
#
#rest.address: 0.0.0.0

# Port range for the REST and web server to bind to.
#
rest.bind-port: 9100-9124

# The address that the REST & web server binds to
#
#rest.bind-address: 0.0.0.0

# Flag to specify whether job submission is enabled from the web-based
# runtime monitor. Uncomment to disable.

web.submit.enable: false

#==============================================================================
# Advanced
#==============================================================================

# Override the directories for temporary files. If not specified, the
# system-specific Java temporary directory (java.io.tmpdir property) is taken.
#
# For framework setups on Yarn or Mesos, Flink will automatically pick up the
# containers' temp directories without any need for configuration.
#
# Add a delimited list for multiple directories, using the system directory
# delimiter (colon ':' on unix) or a comma, e.g.:
#     /data1/tmp:/data2/tmp:/data3/tmp
#
# Note: Each directory entry is read from and written to by a different I/O
# thread. You can include the same directory multiple times in order to create
# multiple I/O threads against that directory. This is for example relevant for
# high-throughput RAIDs.
#
io.tmp.dirs: /data/flink/tmp
env.log.dir: /data/flink/logs

# The classloading resolve order. Possible values are 'child-first' (Flink's default)
# and 'parent-first' (Java's default).
#
# Child first classloading allows users to use different dependency/library
# versions in their application than those in the classpath. Switching back
# to 'parent-first' may help with debugging dependency issues.
#
# classloader.resolve-order: child-first

# The amount of memory going to the network stack. These numbers usually need 
# no tuning. Adjusting them may be necessary in case of an "Insufficient number
# of network buffers" error. The default min is 64MB, the default max is 1GB.
# 
# taskmanager.memory.network.fraction: 0.1
# taskmanager.memory.network.min: 64mb
# taskmanager.memory.network.max: 1gb

#taskmanager.memory.network.fraction: 0.1
#taskmanager.memory.network.min: 64mb
#taskmanager.memory.network.max: 1gb
#fs.hdfs.hadoopconf: /opt/module/hadoop/etc/hadoop/

#==============================================================================
# Flink Cluster Security Configuration
#==============================================================================

# Kerberos authentication for various components - Hadoop, ZooKeeper, and connectors -
# may be enabled in four steps:
# 1. configure the local krb5.conf file
# 2. provide Kerberos credentials (either a keytab or a ticket cache w/ kinit)
# 3. make the credentials available to various JAAS login contexts
# 4. configure the connector to use JAAS/SASL

# The below configure how Kerberos credentials are provided. A keytab will be used instead of
# a ticket cache if the keytab path and principal are set.

# security.kerberos.login.use-ticket-cache: true
# security.kerberos.login.keytab: /path/to/kerberos/keytab
# security.kerberos.login.principal: flink-user

# The configuration below defines which JAAS login contexts

# security.kerberos.login.contexts: Client,KafkaClient

#==============================================================================
# ZK Security Configuration
#==============================================================================

# Below configurations are applicable if ZK ensemble is configured for security

# Override below configuration to provide custom ZK service name if configured
# zookeeper.sasl.service-name: zookeeper

# The configuration below must match one of the values set in "security.kerberos.login.contexts"
# zookeeper.sasl.login-context-name: Client

#==============================================================================
# HistoryServer
#==============================================================================

# The HistoryServer is started and stopped via bin/historyserver.sh (start|stop)

# Directory to upload completed jobs to. Add this directory to the list of
# monitored directories of the HistoryServer as well (see below).
jobmanager.archive.fs.dir: hdfs://ns/flink/completed_jobs/

# The address under which the web-based HistoryServer listens.
historyserver.web.address: 0.0.0.0

# The port under which the web-based HistoryServer listens.
historyserver.web.port: 8082

# Comma separated list of directories to monitor for completed jobs.
historyserver.archive.fs.dir: hdfs://ns/flink/completed-jobs/

# Interval in milliseconds for refreshing the monitored directories.
historyserver.archive.fs.refresh-interval: 10000

vim masters

hadoop-01:8081
hadoop-02:8082

vim slaves

hadoop-01
hadoop-02
hadoop-03

vim zoo.cfg

################################################################################
#  Licensed to the Apache Software Foundation (ASF) under one
#  or more contributor license agreements.  See the NOTICE file
#  distributed with this work for additional information
#  regarding copyright ownership.  The ASF licenses this file
#  to you under the Apache License, Version 2.0 (the
#  "License"); you may not use this file except in compliance
#  with the License.  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
# limitations under the License.
################################################################################

# The number of milliseconds of each tick
tickTime=2000

# The number of ticks that the initial  synchronization phase can take
initLimit=10

# The number of ticks that can pass between  sending a request and getting an acknowledgement
syncLimit=5

# The directory where the snapshot is stored.
# dataDir=/tmp/zookeeper

# The port at which the clients will connect
clientPort=2181


# ZooKeeper quorum peers
server.1=hadoop-01:2888:3888
server.2=hadoop-02:2888:3888
server.3=hadoop-03:2888:3888
# server.2=host:peer-port:leader-port

启动集群

start-cluster.sh

启动后回jps回发现没有进程去下面的网站上找了相应的jar包

https://repo.maven.apache.org/maven2/org/apache/flink/flink-shaded-hadoop-2-uber/

在这里插入图片描述
重新执行./start-cluster.sh
查看进程
在这里插入图片描述

启动正常访问web
在这里插入图片描述

END

  • 3
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值