下載頁面:https://archive.apache.org/dist/flink/flink-1.7.2/
我這裡安裝的 flink-1.7.2-bin-hadoop27-scala_2.11.tgz 版本。
修改如下兩個引數:
#填你機器的host名
jobmanager.rpc.address: linux2
taskmanager.numberOfTaskSlots: 2
linux2
linux3
linux4
scp -r flink-1.7.2 linux3:/opt/lagou/servers/
scp -r flink-1.7.2 linux4:/opt/lagou/servers/
vim /etc/profile
export FLINK_HOME=/opt/lagou/servers/flink-1.7.2
export PATH=$PATH:$FLINK_HOME/bin
設定完成後使組態檔生效
source /etc/profile
./start-cluster.sh
啟動完後我們可以輸入網址http://linux2:8081/,驗證
至此,安裝完畢。
然後我們將程式放入叢集環境測試。首先需要先打 jar 包,需要注意將依賴也打進去,打包外掛如下:
<build>
<plugins>
<!-- 打jar外掛 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
打包完成後,將 jar 包上傳
選中上傳的 jar 包,填入我們 main 方法的全類名,引數等等。然後點選 submit 提交任務。
我們可以先使用 nc 工具向程式輸入資料 nc -lk 7000
檢視紀錄檔的輸出
<property>
<name>yarn.nodemanager.pmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.nodemanager.vmem-check-enabled</name>
<value>false</value>
</property>
<property>
<name>yarn.resourcemanager.address</name>
<value>linux2:8032</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>linux2:8030</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>linux2:8031</value>
</property>
start-dfs.sh
start-yarn.sh
# -n 2代表2個task manager,tm 800代表記憶體800m,-s 1代表一個slots,-d代表後臺執行
yarn-session.sh -n 2 -tm 800 -s 1 -d
方式一:
./flink run -c com.mmc.flink.WordCountStream /export/servers/flink/examples/batch/WordCount.jar
方式二:
# -m jobmanager的地址
# -yn 表示TaskManager的個數
./flink run -m yarn-cluster -yn 2 -yjm 1024 -ytm 1024 /export/servers/flink/examples/batch/WordCount.jar
# 找到yarn任務的id,通過命令殺掉
yarn application -kill application_1527077715040_0003