Flink1.17集群部署问题-解决xsync分发问题

问题描述

最近有一个小家伙问了我一个问题,如下

[root@hadoop102 module]# xsync flink-1.17./
==================== hado0p102 ====================
The authenticity of host hadoop102 (192.168.253.128)' can't be established.
ECDSA key fingerprint is SHA256:Z99gdMwKL/0Z5ZGNd4ZHg2laCWo10suZe0IuM8A76AM.
ECDSA key fingerprint is MD5:a7:c7:9c:b2:cb:44:cd:1d:a7:2b:3e:83:6e:ba:26:86.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added hadoop102,192.168.253.128' (ECDSA) to the list of known hosts.
root@hadoop102's password:
/usr/bin/xsync: line 27: rsync: command not found hadoop103====================2222222222222222222
ssh: connect to host hadoop103 port 22: No route to host
/usr/bin/xsync: line 27: rsync:command not found==================== hadoop104222222222222222222
ssh:connect to host hadoop104 port 22: No route to host
/usr/bin/xsync: line 27: rsync: command not found

 问题定位

从上述代码,错误提示表明系统中没有找到rsync命令,rsync是xsync命令所依赖的工具,用于实现文件的同步和传输,我的定位思路:

先查看有没有

which rsync

安装 rsync

yum install rsync

写脚本xsync.sh

脚本放到了/usr/bin目录下,并重命名为xsync,flink部署在/opt/module下了

#!/bin/bash
if [ $# -lt 1 ]; then
    echo "Not Enough Argument!"
    exit
fi
# 遍历集群所有机器
for host in hadoop102 hadoop103 hadoop104; do
    echo "======= $host ======"
    
    # 遍历所有目录,挨个发送
    for file in "$@"; do
        # 判断文件是否存在
        if [ -e "$file" ]; then
            # 获取父目录
            pdir=$(cd -P "$(dirname "$file")" && pwd)
            
            # 获取当前文件的名称
            fname=$(basename "$file")
            
            ssh "$host" "mkdir -p $pdir"
            rsync -av "$pdir/$fname" "$host:$pdir"
        else
            echo "$file does not exist!"
        fi
    done
done

配置环境变量

vi /etc/profile

#xsync环境变量
export PATH="/bin/xsync:$PATH"

配置完毕保存退出

source一下

source /etc/profile

给一下权限

chmod +x /usr/bin/xsync

三台机器都如此配置了

然后再flink所在目录下执行xsync flink......就可以了

猜你喜欢

转载自blog.csdn.net/qq_52128187/article/details/131621215
今日推荐