sersync+rsync做实时同步详解程序员
2023-06-13 09:20:04 时间
1)下载sersync
wegt https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz
或者Windows下载再上传源主机youxi1。
2)解压
[[email protected] ~]# ls anaconda-ks.cfg sersync2.5.4_64bit_binary_stable_final.tar.gz [[email protected] ~]# tar xvf sersync2.5.4_64bit_binary_stable_final.tar.gz //解压 GNU-Linux-x86/ GNU-Linux-x86/sersync2 GNU-Linux-x86/confxml.xml [[email protected] ~]# ls anaconda-ks.cfg GNU-Linux-x86 sersync2.5.4_64bit_binary_stable_final.tar.gz [[email protected] ~]# mv GNU-Linux-x86 sersync 改名 [[email protected] ~]# ls anaconda-ks.cfg sersync sersync2.5.4_64bit_binary_stable_final.tar.gz
3)在目标主机youxi2上修改/etc/rsyncd.conf配置文件,以及密码文件
[[email protected] ~]# cat /etc/rsyncd.conf uid = root gid = root address = 192.168.5.102 port = 873 hosts allow = 192.168.5.101/24 use chroot = yes max connections = 5 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log motd file = /etc/rsyncd.motd [backupwwwhtml] path = /backup/www/html comment = backup /www/html/ read only = false list = yes auth users = rsync2 secrets file = /etc/rsync.passwd [[email protected] ~]# cat /etc/rsync.passwd rsync2:102102 [[email protected] ~]# chmod 600 /etc/rsync.passwd
启动指定配置文件的rsync的守护进程
[[email protected] ~]# rsync --daemon --config=/etc/rsyncd.conf [[email protected] ~]# ps aux | grep rsync root 1478 0.0 0.0 114740 564 ? Ss 11:10 0:00 rsync --daemon --config=/etc/rsyncd.conf root 1485 0.0 0.0 112720 980 pts/0 R+ 11:12 0:00 grep --color=auto rsync
4)源主机youxi1上修改sersync的配置文件
[[email protected] sersync]# vim confxml.xml ?xml version="1.0" encoding="ISO-8859-1"? head version="2.5" host hostip="localhost" port="8008" /host debug start="false"/ fileSystem xfs="false"/ filter start="false" exclude expression="(.*)/.svn" /exclude exclude expression="(.*)/.gz" /exclude exclude expression="^info/*" /exclude exclude expression="^static/*" /exclude /filter inotify createFile start="false"/ closeWrite start="true"/ moveFrom start="true"/ moveTo start="true"/ attrib start="false"/ modify start="false"/ /inotify sersync localpath watch="/www/html" remote ip="192.168.5.102" name="backupwwwhtml"/ //修改为目标主机IP地址和模块名 /localpath rsync commonParams params="-artuz"/ auth start="true" users="rsync2" passwordfile="/etc/rsync.passwd"/ //开启,修改用户名和密码文件地址 userDefinedPort start="false" port="874"/ !-- port=874 -- timeout start="false" time="100"/ !-- timeout=100 -- ssh start="false"/ /rsync failLog path="/tmp/rsync_fail_log.sh" timeToExecute="60"/ !--default e very 60mins execute once-- crontab start="false" schedule="600" !--600mins-- crontabfilter start="false" exclude expression="*.php" /exclude exclude expression="info/*" /exclude /crontabfilter /crontab plugin start="false" name="command"/ /sersync
添加密码文件
[[email protected] sersync]# vim /etc/rsync.passwd 102102 [[email protected] html]# chmod 600 /etc/rsync.passwd
5)开启源主机youxi1的sersync的守护进程
[[email protected] sersync]# /root/sersync/sersync2 -dro /root/sersync/confxml.xml set the system param execute:echo 50000000 /proc/sys/fs/inotify/max_user_watches execute:echo 327679 /proc/sys/fs/inotify/max_queued_events parse the command param option: -d run as a daemon option: -r rsync all the local files to the remote servers before the sersync work option: -o config xml name: /root/sersync/confxml.xml daemon thread num: 10 parse xml config file host ip : localhost host port: 8008 daemon start,sersync run behind the console use rsync password-file : user is rsync2 passwordfile is /etc/rsync.passwd config xml parse success please set /etc/rsyncd.conf max connections=0 Manually sersync 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 once working please wait... execute command: cd /www/html rsync -artuz -R --delete ./ [email protected]::backupwwwhtml --password-file=/etc/rsync.passwd /dev/null 2 1 run the sersync: watch path is: /www/html
6)测试
现在的目的主机youxi2情况如下
[[email protected] ~]# ls /backup/www/html/ adm crash empty gopher lib lock mail opt run tmp cache db games kerberos local log nis preserve spool yp
对源主机youxi1的/www/html/目录下文件进行操作
[[email protected] sersync]# cd /www/html/ [[email protected] html]# ls adm crash empty gopher lib lock mail opt run tmp cache db games kerberos local log nis preserve spool yp [[email protected] html]# rm -rf adm/ [[email protected] html]# touch 1.txt [[email protected] html]# ls 1.txt crash empty gopher lib lock mail opt run tmp cache db games kerberos local log nis preserve spool yp
回到目的主机查看情况
[[email protected] ~]# ls /backup/www/html/ 1.txt crash empty gopher lib lock mail opt run tmp cache db games kerberos local log nis preserve spool yp
2781.html
服务器部署程序员系统优化网站设置运维相关文章
- 实时系统动态内存算法分析dsa(二)——TLSF代码分析
- 大数据NiFi(二十):实时同步MySQL数据到Hive
- 实战 | 基于OpenCV的停车场空余车位实时监测系统(详细步骤 + 源码)
- phpstorm 实现SFTP开发,线上线下同步(实时更新代码)
- 开发一个微信小程序(4):查询天气-获取某个城市的实时天气
- OGG用于PG数据库之间双主实时同步
- SQL Server实时同步更新远程数据库遇到的问题小结
- Linux实时查看内存与CPU使用情况(linux查内存cpu)
- 下流量抓包DPDK在Linux下实现实时流量抓包(dpdklinux)
- 监控Linux系统下CPU状态的实时监控(linuxcpu状态)
- Linux实现目录实时同步(linux目录实时同步)
- 实现Oracle数据实时同步的简单方法(oracle数据实时同步)
- MySQL实时同步: 原理及应用(mysql实时同步原理)
- MySQL实时同步:实现原理及其应用(mysql实时同步原理)
- MySQL实时数据同步:提升实时性能(mysql实时数据同步)
- Oracle RFS——实时文件同步技术简介(oraclerfs)
- MySQL发布订阅:实时高性能数据流同步(mysql发布订阅)
- 借助Oracle实时同步工具让你的数据保持高速同步(oracle实时同步工具)
- MSSQL实现数据库实时同步(mssql实时同步)
- MySQL实时同步工具:数据传输更简单高效(mysql实时同步工具)
- 监控Linux Top进程监控实时了解系统性能(linux top 进程)
- 构建基于Redis与MySQL的实时数据同步(redis与mysql数据同步)
- 实时同步Oracle全库高效安全的解决之道(oracle全库实时同步)
- 深入Redis查看连接数的实时监控(查看redis连接数数量)
- 重塑数据库 从Redis缓存到实时访问(数据库与redis缓存)
- Vue抢跑Redis速度感受实时重磅数据(vue获取redis)
- 实现Redis与数据库之间的实时同步(从redis到数据库同步)
- Oracle智能查询实时明细账报表(oracle中查询明细账)
- 同步Redis集群架构容灾数据实时同步(redis集群容灾数据)
- 实时重置 Redis 计数器(redis 计数器清零)
- 实时离线融合在唯品会的进展:在实时技术、数据、业务中寻找平衡
- 比较简洁的JavaScript实时显示时间的脚本修正版
- 你真的了解触发器么数据实时同步更新问题剖析