Rsync实操

一.rsync命令

 #类似于cp[root@user2 ~]# rsync info.sh root@192.168.168.130:/rootroot@192.168.168.130's password: [root@user1 ~]# lsanaconda-ks.cfg  ceph-release-1-1.el7.noarch.rpm  info.sh

二、使用rsync备份push方式

  • 服务器:server 192.168.168.130(需要进行数据备份的主机)

  • 客户端:client 192.168.168.131 (备份存储的主机)

 # 在客户端上编写rsync配置文件,创建一个存放备份的同步目录[root@targetpc ~]# vim /etc/rsyncd.conf[root@targetpc ~]# cat /etc/rsyncd.confport=873address = 192.168.168.131 #客户端地址uid = rootgid = rootuse chroot = yesmax connections = 4pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/rsyncd.logmotd file = /etc/rsyncd.motd #可弄可不弄hosts allow = 192.168.168.0/24 #允许哪个网段传输数据[data] #网络名path = /data/backup #数据存储目录 真实名 需要创建comment = bakcup dataread only = falselist = yes#独立验证auth users = rsyncusersecrets file = /etc/rsync.passwd #自己创建​#设置独立账户密码[root@targetpc ~]# vim /etc/rsync.passwd#添加权限[root@targetpc ~]# chmod 600 /etc/rsync.passwd[root@targetpc ~]# vim /etc/rsync.passwd[root@targetpc ~]# cat /etc/rsync.passwdrsyncuser:123#设置标语[root@targetpc ~]# echo "来送数据了" > /etc/rsyncd.motd[root@targetpc ~]# systemctl restart rsyncd​#测试 服务器测试[root@sourcepc data]# ls1.txt  2.txt  3.txt  aaa[root@sourcepc data]# rsync -avz /data/* rsyncuser@192.168.168.131::data来送数据了​Password: sending incremental file list3.txt​sent 155 bytes  received 36 bytes  20.11 bytes/sectotal size is 0  speedup is 0.00#客户主机结果[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa
 ​

三、测试--delete命令push

 #--delete实验 不能与*同时用[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa  del.txt[root@sourcepc data]# ls1.txt  2.txt  3.txt  aaa​[root@sourcepc data]# rsync -avz --delete /data/* rsyncuser@192.168.168.131::data来送数据了​Password: sending incremental file list​sent 119 bytes  received 13 bytes  13.89 bytes/sectotal size is 0  speedup is 0.00[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa  del.txt#使用--delete时 去掉*[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data来送数据了​Password: sending incremental file listdeleting del.txt./​sent 149 bytes  received 31 bytes  18.95 bytes/sectotal size is 0  speedup is 0.00[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa

四、免密同步

 
#免密[root@sourcepc data]# echo "123" > /etc/rsync.passwd[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd #注意时--password 全称来送数据了​ERROR: password file must not be other-accessiblersync error: syntax or usage error (code 1) at authenticate.c(196) [sender=3.1.2]#设置权限[root@sourcepc data]# chmod 600 /etc/rsync.passwd[root@sourcepc data]# rsync -avz --delete /data/ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd来送数据了​sending incremental file list​sent 142 bytes  received 13 bytes  23.85 bytes/sectotal size is 0  speedup is 0.00

五、pull模式

以上的同步过程都是服务端主动推送数据给目标主机,这里演示下目标主机主动拉取数据进行同步

 
# 服务端上配置/etc/rsyncd.conf文件port=873address = 192.168.168.130uid = rootgid = rootuse chroot = yesmax connections = 4pid file = /var/run/rsyncd.pidlock file = /var/run/rsync.locklog file = /var/log/rsyncd.log#motd file = /etc/rsyncd.motdhosts allow = 192.168.168.0/24[data]path = /datacomment =  dataread only = falselist = yesauth users = rsyncusersecrets file = /etc/rsync.passwd# 认证文件[root@sourcepc log]# cat  /etc/rsync.passwdrsyncuser:123# 服务端上启动rsync[root@sourcepc log]# systemctl start rsyncd[root@sourcepc log]# systemctl status rsyncd● rsyncd.service - fast remote file copy program daemonLoaded: loaded (/usr/lib/systemd/system/rsyncd.service; disabled; vendor preset: disabled)Active: active (running) since 四 2025-06-19 20:35:23 CST; 2s agoMain PID: 2097 (rsync)CGroup: /system.slice/rsyncd.service└─2097 /usr/bin/rsync --daemon --no-detach​6月 19 20:35:23 sourcepc systemd[1]: Started fast remote file copy program daemon.# 目标主机上拉取数据[root@client data]# rsync -avz rsyncuser@192.168.168.130::data /dataPassword: receiving incremental file list./1.txt2.txt3.txtaaa12/bbb/ccc/​sent 100 bytes  received 305 bytes  162.00 bytes/sectotal size is 0  speedup is 0.00[root@client data]# ls1.txt  2.txt  3.txt  aaa12  backup  bbb  ccc

六、rsync+sersync 实现数据实时同步push

 #在需要备份主机处 安装sersync 使用的外部安装包#使用rz 调入安装包[root@sourcepc ~]# rz[root@sourcepc ~]# lsanaconda-ks.cfg                  info.shceph-release-1-1.el7.noarch.rpm  sersync2.5.4_64bit_binary_stable_final.tar.gz#解压[root@sourcepc ~]# tar -xf sersync2.5.4_64bit_binary_stable_final.tar.gz[root@sourcepc ~]# lsanaconda-ks.cfg                  GNU-Linux-x86  sersync2.5.4_64bit_binary_stable_final.tar.gzceph-release-1-1.el7.noarch.rpm  info.sh#进行配置[root@sourcepc ~]# cd GNU-Linux-x86/[root@sourcepc GNU-Linux-x86]# lsconfxml.xml  sersync2[root@sourcepc GNU-Linux-x86]# vim confxml.xml #修改的部分</filter><inotify><delete start="true"/><createFolder start="true"/><createFile start="true"/><closeWrite start="true"/><moveFrom start="true"/><moveTo start="true"/><attrib start="true"/><modify start="true"/></inotify>​<sersync><localpath watch="/data"><remote ip="192.168.168.131" name="data"/><!--<remote ip="192.168.8.39" name="tongbu"/>--><!--<remote ip="192.168.8.40" name="tongbu"/>--></localpath><rsync><commonParams params="-artuz"/><auth start="true" users="rsyncuser" passwordfile="/etc/rsync.passwd"/><userDefinedPort start="false" port="874"/><!-- port=874 --><timeout start="false" time="100"/><!-- timeout=100 --><ssh start="false"/></rsync>​#执行文件[root@sourcepc GNU-Linux-x86]# ./sersync2 -d -r -o ./confxml.xml set the system paramexecute:echo 50000000 > /proc/sys/fs/inotify/max_user_watchesexecute:echo 327679 > /proc/sys/fs/inotify/max_queued_eventsparse the command paramoption: -d      run as a daemonoption: -r      rsync all the local files to the remote servers before the sersync workoption: -o      config xml name:  ./confxml.xmldaemon thread num: 10parse xml config filehost ip : localhost     host port: 8008will ignore the inotify createFile event daemon start,sersync run behind the console use rsync password-file :user is rsyncuserpasswordfile is         /etc/rsync.passwdconfig xml parse successplease set /etc/rsyncd.conf max connections=0 Manuallysersync working thread 12  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)please according your cpu ,use -n param to adjust the cpu rate------------------------------------------rsync the directory recursivly to the remote servers onceworking please wait...execute command: cd /data && rsync -artuz -R --delete ./ rsyncuser@192.168.168.131::data --password-file=/etc/rsync.passwd >/dev/null 2>&1 [root@sourcepc GNU-Linux-x86]# run the sersync: watch path is: /data​#测试[root@sourcepc data]# ls1.txt  2.txt  3.txt  aaa[root@sourcepc data]# mkdir bbb​[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa  bbb​​[root@sourcepc data]# ls1.txt  2.txt  3.txt  aaa  bbb  ccc[root@sourcepc data]# mv aaa aaa12[root@targetpc backup]# ls1.txt  2.txt  3.txt  aaa12  bbb  ccc

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.pswp.cn/news/910028.shtml
繁体地址,请注明出处:http://hk.pswp.cn/news/910028.shtml
英文地址,请注明出处:http://en.pswp.cn/news/910028.shtml

如若内容造成侵权/违法违规/事实不符,请联系英文站点网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Java常见八股-(6.算法+实施篇)

Java常见八股-&#xff08;1.Java基础篇&#xff09; Java常见八股-&#xff08;2.Java高级篇&#xff09; Java常见八股-&#xff08;3.MySQL篇&#xff09; Java常见八股-&#xff08;4.前端篇&#xff09; Java常见八股-&#xff08;5.框架篇&#xff09; 目录 一、算…

阿里云部署的SMTP服务器安全攻防实录:深度解析攻击、防护与加固

阿里云部署的SMTP服务器安全攻防实录&#xff1a;深度解析攻击、防护与加固 一次针对云上SMTP服务的持续攻击事件&#xff0c;揭示了邮件中继服务面临的多重安全挑战。本文将深入剖析攻击手法、防护策略与系统性加固方案。 某企业在阿里云上部署的Postfix SMTP服务器近期遭遇…

HTTP与HTTPS深度解析:从明文传输到安全通信的演进之路

引言 在互联网的早期&#xff0c;HTTP&#xff08;超文本传输协议&#xff09;作为Web通信的基石&#xff0c;凭借简单高效的特性推动了万维网的爆发式增长。但随着互联网从“信息共享”向“价值交互”演进&#xff0c;HTTP的明文传输特性逐渐暴露致命缺陷——用户的每一次点击…

渗透实战:绕过沙箱机制的反射型XSS

Lab 24&#xff1a;利用 xss 绕过 csrf 防御 依然是留言板的问题可以执行<h1>标签 进入修改邮箱的界面&#xff0c;修改抓包 这里构造修改邮箱的代码 <script> var req new XMLHttpRequest(); req.onload handleResponse; req.open(get,/my-account,true); req…

K8S篇之利用deployment实现滚动平滑升级

一、更新策略 在 Kubernetes (K8s) 中,滚动平滑升级(Rolling Update)是一种无缝更新部署的方式,允许你在不中断服务的情况下逐步更新应用程序。这是 Kubernetes 默认的 Deployment 更新策略,它会按照指定的步幅逐步替换 Pods,确保在新版本的应用程序没有完全替换旧版本的…

【Dify 案例】【MCP实战】【一】【前置配置】

MCP(Model Context Protocol,模型上下文协议) ,2024年11月底,由Anthropic 推出的一种开放标准。旨在为大语言模型(LLM)提供统一的、标准化方式与外部数据源和工具之间进行通信。 MCP 作为一种标准化协议,极大地简化了大语言模型与外部世界的交互方式,使开发者能够以统…

2025高考志愿填报张雪峰资料合集

2025高考志愿填报课程&#xff0c;张雪峰专业指导&#xff01;包含61节课&#xff0c;93个专业详解&#xff0c;总计1500分钟视频。 独家各省资料包&#xff01;新旧高考政策全覆盖&#xff0c;适合高三家长和考生。内容整理自互联网&#xff0c;无偿分享&#xff0c;如有侵权&…

Nginx+Tomcat负载均衡群集

一.案例:部署Tomcat 1.案例分析 1.1案例概述 京北点指科技有限公司发布V3版移联建站管理系统&#xff0c;该项目为Java 语言开发的Web 站点。目前&#xff0c;IBM 的 WebSphere 及 0racle 的 WebLogic 占据了市面上 Java 语言 Web 站点的大部分份额。这两种软件以其无与伦比…

华为云Flexus+DeepSeek征文|基于华为云一键部署dify平台构建合同审核助手应用实践

目录 前言 1 华为云一键部署Dify平台 1.1 华为云Dify平台介绍 1.2 部署过程介绍 1.3 登录Dify平台 2 接入华为云 ModelArts Studio 的 DeepSeek 大模型 2.1 获取调用模型服务信息 2.2 在 Dify 中配置模型 3 构建合同审核助手应用 3.1 简要介绍合同审核助手 3.2 开始…

三种经典算法无人机三维路径规划对比(SMA、HHO、GWO三种算法),Matlab代码实现

代码功能 该MATLAB代码用于对比三种元启发式优化算法&#xff08;SMA、HHO、GWO三种算法&#xff0c; SMA黏菌算法、HHO哈里斯鹰优化算法、GWO灰狼优化算法&#xff09; 在特定优化问题上的性能&#xff0c;运行环境MATLABR2020b或更高 &#xff1a; 初始化问题模型&#xff…

设计模式精讲 Day 8:组合模式(Composite Pattern)

【设计模式精讲 Day 8】组合模式&#xff08;Composite Pattern&#xff09; 开篇 在“设计模式精讲”系列的第8天&#xff0c;我们将深入讲解组合模式&#xff08;Composite Pattern&#xff09;。组合模式是一种结构型设计模式&#xff0c;它允许将对象组合成树形结构以表示…

【Dify学习笔记】:RagFlow接入Dify基础教程

RagFlow接入Dify基础教程 如果RagFlow还没部署&#xff0c;可参考我另一篇本地部署文章&#xff1a;【Dify学习笔记】&#xff1a;本地部署RagFlow适配Dify 一、RagFlow 1. 配置模型 点击&#xff1a;头像 > Model providers 添加模型供应商、设置默认模型Set default …

Apache ECharts-02.入门案例

一.入门案例 官网下载&#xff1a;下载 - Apache ECharts&#xff0c;下载echarts.js文件&#xff0c;下载好后在其同一个文件夹下创建html文件即可。 <!DOCTYPE html> <html><head><meta charset"utf-8" /><title>ECharts</title…

社群经济视阈下开源AI智能名片链动2+1模式与S2B2C商城小程序在私域电商中的融合应用研究

摘要&#xff1a;在数字经济与社交网络深度融合的背景下&#xff0c;付费社群凭借精准用户筛选、高价值成员聚合及强信任关系链等优势&#xff0c;成为私域电商发展的核心载体。本文基于社群经济理论&#xff0c;结合“开源AI智能名片链动21模式S2B2C商城小程序”的技术与商业逻…

【Tools】Mac brew工具

Homebrew&#xff08;简称 brew&#xff09;是 macOS&#xff08;也支持 Linux&#xff09;上的一款 包管理工具&#xff0c;它的作用类似于&#xff1a; Ubuntu 下的 aptCentOS 下的 yumArch Linux 下的 pacman 一句话概括&#xff1a; brew 是用来在 macOS 上安装、管理软件…

IEEE RAL 双臂机器人三连抓估计物体状态 无需特制夹爪或视觉相机 - 大阪大学万伟伟老师团队

IEEE RA-L | 万伟伟老师团队提出双臂机器人规划控制方法有效降低被抓物姿态不确定性 日本大阪大学万伟伟老师团队针对双臂机器人开发了一种重复抓取规划和阻抗控制的方法&#xff0c;该方法通过两个机械臂依次寻找抓取位置和物体姿态&#xff0c;并通过三个正交抓取动作&#x…

AtomicInteger 和 volatile Integer对比

AtomicInteger 和 volatile Integer 虽然都与线程安全有关&#xff0c;但本质完全不同。它们的主要区别体现在原子性保证和功能上&#xff1a; &#x1f50d; 核心区别对比表 特性volatile IntegerAtomicInteger原子性❌ 不保证复合操作原子性✅ 保证所有操作的原子性自增操作…

一生一芯 PA2 RTFSC

从src/isa/riscv32/inst.c出发。 向上搜索&#xff0c;理解宏定义的含义。 R(i) #define R(i) gpr(i) R(i)&#xff1a;访问第i号通用寄存器 会被替换为&#xff1a; #define gpr(idx) (cpu.gpr[check_reg_idx(idx)]) 分为两个部分&#xff1a; cpu.gprcheck_reg_idx c…

深度学习——手写数字识别

深度学习——手写数字识别 学习深度学习的朋友应该对MNIST数据集不陌生吧&#xff0c;相信很多人在刚开始学习深度学习的时候都会用到MNIST数据集进行书写数字识别。本篇文章参考鱼书创建一个深度网络来进行书写数字识别的任务。 如上图所示&#xff0c;这里使用的卷积层全都是…

HashMap算法高级应用实战:频率类子数组问题的5种破解模式

本文将深入剖析5种基于HashMap的高级模式&#xff0c;通过原理详解、多语言实现、性能对比和工业级应用&#xff0c;助您彻底掌握频率类子数组问题。 1. 深入解析&#xff1a;频率类子数组问题 1.1 问题定义与分类 频率类子数组问题是指需要统计或查找满足特定元素频率条件的…