Linux文件分发脚本 只要一条命令将你的文件分发到各个服务器上
发布时间:2021-12-02 04:45:18 所属栏目:Linux 来源:互联网
导读:在运维或在日常工作生活中,我们经常会把一个文件拷贝到其它服务器上,或同时分发到多个服务器上,甚至要求目标机将文件放在相同的路径下,方便程序进一步调用。 Linux文件分发脚本,只需一条命令将你的文件分发到各个服务器上 遇到这种问题,我们通常的做法
|
在运维或在日常工作生活中,我们经常会把一个文件拷贝到其它服务器上,或同时分发到多个服务器上,甚至要求目标机将文件放在相同的路径下,方便程序进一步调用。 Linux文件分发脚本,只需一条命令将你的文件分发到各个服务器上 遇到这种问题,我们通常的做法是使用scp或rsync命令把文件拷贝一个一个地拷贝到多台服务器上,这样做费事费力;大神的做法是使用ansible的playbook一下把事情干完,前提是你得会ansible;快捷的做法就是使用今天的脚本了。 效果演示 目前拥有4台机器,分别为client、node1、node2和node3,client与其它3台机器能够建立ssh链接。在client的/root/test目录下有a.txt和b.txt两个文件。 Linux文件分发脚本,只需一条命令将你的文件分发到各个服务器上 [root@client test]# ls /root/test/ a.txt b.txt [root@client test]# 我把文件分发到node1、node2和node3的/root/test下,执行以下命令: # 在/root/test目录下执行, xrsync是我的脚本 [root@client test]# xrsync a.txt b.txt 执行分发过程: [root@client test]# xrsync a.txt b.txt ============ node1 ============ sending incremental file list a.txt sent 93 bytes received 35 bytes 256.00 bytes/sec total size is 2 speedup is 0.02 sending incremental file list b.txt sent 93 bytes received 35 bytes 85.33 bytes/sec total size is 2 speedup is 0.02 ============ node2 ============ sending incremental file list a.txt sent 93 bytes received 35 bytes 256.00 bytes/sec total size is 2 speedup is 0.02 sending incremental file list b.txt sent 93 bytes received 35 bytes 256.00 bytes/sec total size is 2 speedup is 0.02 ============ node3 ============ sending incremental file list a.txt sent 93 bytes received 35 bytes 85.33 bytes/sec total size is 2 speedup is 0.02 sending incremental file list b.txt sent 93 bytes received 35 bytes 256.00 bytes/sec total size is 2 spee (编辑:百科站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Kubernetes 云原生存储 OpenEBS 中文使用技巧
- linux-kernel – IO-APIC级别与PCI-MSI-X之间的差异
- Device eth0 does not seem to be present, delaying initi
- 编译安装ibus错误make: *** 没有指明目标并且找不到 makefi
- Linux上的编译器是否支持Objective-C块?
- Linux QoS:空闲时的批量数据传输
- Linux 中断子系统 中断处理知识点分析
- linux下Komodo安装日志
- SELinux安全上下文的修改和操作chcon和restorecon命令
- xmlstarlet – 删除换行符
站长推荐

