下載
清華鏡像 ,下載需要的版本
config/fink-conf.yaml
# The number of task slots that each TaskManager offers. Each slot runs one parallel pipeline.
# 有幾個 slots 能執(zhí)行幾個線程,最大的并行的線程的數(shù)量,推薦給cpu核心數(shù)
taskmanager.numberOfTaskSlots: 1
# The parallelism used for programs that did not specify and other parallelism.
## task任務(wù)并行的線程數(shù)量
parallelism.default: 1
standalone 模式啟動
# 啟動
./bin/start-cluster.sh
# 停止
./bin/stop-cluster.sh
# 檢查
jps
#jobManager 進(jìn)程
#78464 StandaloneSessionClusterEntrypoint
#78739 Jps
#taskManager 進(jìn)程
#78731 TaskManagerRunner
# 鏈接 web 界面
localhost:8081
Parallelism 并行度的設(shè)置優(yōu)先級
1.代碼中設(shè)置的最高,每一步操作都可以設(shè)置并行度,如
//基于數(shù)據(jù)流進(jìn)行轉(zhuǎn)換計算 // keyBey按照key的hash ,進(jìn)行重分區(qū)
SingleOutputStreamOperator<Tuple2<String, Integer>> resultStream = inputDataStream.flatMap(new WordCount.MyFlatMapper())
.keyBy(0)
.sum(1).setParallelism(2);
//打印輸出
resultStream.print().setParallelism(1);
2.其次 ,全局環(huán)境的配置
env.setParallelism(4);
3.其次 ,提交 job 的時候的 并行度設(shè)置參數(shù)
4.其次,啟動的配置文件 默認(rèn)是1
命令提交job
./bin/flink run -c 入口類 -p 并行度 jar包位置
# 如
./bin/flink run -c com.test.wc.StreamWordCount -p 3 /path/to/xxx.jar
## 查看 jobID
./bin/flink list
## 取消job
./bin/flink cancel $jobID
## 查看所有的 job ,包括取消的
./bin/flink list -a
yarn 模式
todo
kubernetes 部署
todo