Flink1.17 cluster deployment problem - solve xsync distribution problem

Problem Description

Recently a little guy asked me a question, as follows

[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

 identify the problem

From the above code, the error message indicates that the rsync command is not found in the system. rsync is a tool that the xsync command relies on to realize file synchronization and transmission. My positioning idea:

check first

which rsync

install rsync

yum install rsync

Write script xsync.sh

The script is placed in the /usr/bin directory and renamed to xsync, and flink is deployed under /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

Configure environment variables

vi /etc/profile

#xsync environment variable
export PATH="/bin/xsync:$PATH"

Save and exit after configuration

source it

source /etc/profile

give permission

chmod +x /usr/bin/xsync

All three machines are configured like this

Then execute xsync flink in the directory where flink is located... that's it

 

Guess you like

Origin blog.csdn.net/qq_52128187/article/details/131621215