系统环境:CentOS-7-x86_64-DVD-2009.iso
flink版本:flink-1.13.1-bin-scala_2.12
jdk:1.8
相当于一个软件仓库
yum install -y epel-release
# net-tool:工具包集合,包含ifconfig等命令
yum install -y net-tools
# vim:编辑器
yum install -y vim
# 关闭防火墙
systemctl stop firewalld
# 关闭防火墙开机自启
systemctl disable firewalld.service
# 创建用户
useradd develop
# 设置develop用户的密码
passwd develop
...设置密码操作
# 系统用户权限配置文件
vim /etc/sudoers
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
## Allows people in group wheel to run all commands
%wheel ALL=(ALL) ALL
## 添加配置
develop ALL=(ALL) NOPASSWD:ALL
注意:develop 这一行不要直接放到root行下面,因为所有用户都属于wheel组,你先配置了develop 具有免密功能,但是程序执行到%wheel行时,该功能又被覆盖回需要密码。所以develop 要放到%wheel这行下面。
[root@flink1 opt]# mkdir module
[root@flink1 opt]# mkdir software
[root@flink1 opt]# ll
总用量 0
drwxr-xr-x. 2 root root 6 9月 8 00:33 module
drwxr-xr-x. 2 root root 6 9月 8 00:33 software
[root@flink1 opt]# chown develop:develop /opt/module
[root@flink1 opt]# chown develop:develop /opt/software/
[root@flink1 opt]# ll
总用量 0
drwxr-xr-x. 2 develop develop 6 9月 8 00:33 module
drwxr-xr-x. 2 develop develop 6 9月 8 00:33 software
rpm -qa | grep -i java | xargs -n1 rpm -e --nodeps
注意:每一台服务器均要安装jdk
安装步骤略
reboot
克隆三台flink,分别修改静态ip以及服务器名称,如下:
192.168.10.11 flink1
192.168.10.12 flink2
192.168.10.13 flink3
服务器 | flink1 | flink2 | flink3 |
---|---|---|---|
内存 | 1G | 1G | 1G |
CPU | 1 | 1 | 1 |
组件 | StandaloneSessionClusterEntrypoint | TaskManagerRunner | TaskManagerRunner |
https://archive.apache.org/dist/flink/flink-1.13.1/
[develop@flin1 software]$ tar -zxvf flink-1.10.0-bin-scala_2.11.tgz -C /opt/module/
[develop@flin1 module]$ ls
flink-1.10.0-bin-scala_2.11.tgz jdk-8u301-linux-x64.tar.gz
标识StandaloneSessionClusterEntrypoint的配置
[develop@flink1 conf]$ vim masters
flink1:8081
标识TaskManagerRunner的配置
flink2
flink3
# 修改jobmanager远程地址为flink1
jobmanager.rpc.address: flink1
# 修改jobmanager堆内存为1G
jobmanager.heap.size: 1024m
# 修改每个taskmanager设置两个插槽
taskmanager.numberOfTaskSlots: 2
https://blog.csdn.net/qq_27242695/article/details/120236642
#!/bin/bash
if [ $# -lt 1 ]; then
echo Not Enough Arguement!
exit;
fi
for host in flink1 flink2 flink3
do echo ==================== $host ====================
#3. 遍历所有目录,挨个发送
for file in $@
do
#4. 判断文件是否存在
if [ -e $file ]; then
#5. 获取父目录
pdir=$(cd -P $(dirname $file); pwd)
#6. 获取当前文件的名称
fname=$(basename $file)
ssh $host "mkdir -p $pdir"
rsync -av $pdir/$fname $host:$pdir
else
echo $file does not exists!
fi
done
done
#!/bin/bash
for host in flink1 flink2 flink3
do
echo =============== $host ===============
ssh $host jps
done
#!/bin/bash
if [ $# -lt 1 ]; then
echo "No Args Input..."
exit ;
fi
case $1 in
"start")
echo " =================== 启动 flink集群================="
ssh flink1 "/opt/module/flink-1.13.1/bin/start-cluster.sh"
;;
"stop")
echo " =================== 关闭 flink集群 ==================="
ssh flink1 "/opt/module/flink-1.13.1/bin/stop-cluster.sh"
;;
*)
echo "Input Args Error..."
;;
esac
# 1. 分发flink解压文件
[develop@flink1 bin]$ xsync /opt/module/flink-1.10.0/
# 2. 分发flink-cluster.sh, jpsall.sh, xsync
[develop@flink1 bin]$ xsync flink-cluster.sh jpsall.sh xsync
任意一台服务器执行
# 启动
flink-cluster.sh start
# 关闭
flink-cluster.sh stop
# 查看结果
jpsall.sh
# flink run -c 启动方法 -p 并行度 上传jar目录 参数,-d 标识后端运行
./bin/flink run -d -c class.main -p 3 xxx.jar args
# 1. 列出当前的job flink list -a 后缀添加-a表示查看状态
./bin/flink list
# 2. 取消job flink cancel jobId
./bin/flink cancel jobId