负载均衡文件同步

负载均衡文件同步

2023年7月19日发(作者:)

负载均衡⽂件同步rsync是linux系统下的数据镜像备份⼯具。使⽤快速增量备份⼯具Remote Sync可以远程同步,⽀持本地复制,或者与其他SSH、rsync主机同步。第⼀次同步时 rsync 会复制全部内容,但在下⼀次只传输修改过的⽂件。sersync是基于Inotify开发的,类似于Inotify-tools的⼯具,sersync可以记录下被监听⽬录中发⽣变化的(包括增加、删除、修改)具体某⼀个⽂件或某⼀个⽬录的名字;查看是否安装rsync,Centos7系统⼀般都装了ll /proc/sys/fs/inotify如下三项,则已安装-rw-r--r-- 1 root root 0 Nov 28 11:07 max_queued_events-rw-r--r-- 1 root root 0 Nov 28 11:07 max_user_instances-rw-r--r-- 1 root root 0 Nov 28 11:07 max_user_watchesA-- 作为rsync服务器 需要配置⽂件B-- 作为rsync客户端 不需要配置,⽂件可为空服务端1.#关闭selinuxvi /etc/sysconfig/selinux#SELINUX=enforcing #注释掉SELINUX=disabled #增加#重启系统开启防⽕墙tcp 873端⼝(Rsync默认端⼝),如果是阿⾥云设置安全组2.修改/etc/ (配置⽂件⽤⽂末的)uid = root #运⾏ rsync 守护进程的⽤户gid = root #运⾏ rsync 守护进程的组use chroot = no #若为yes, 则需要root权限,并且在同步符号连接资料时只会同步名称不会同步内容max connections = 5 #设置并发连接数,0表⽰⽆限制strict modes = yes #是否检查⼝令⽂件的权限port = 873 #端⼝,873为 rsync 默认端⼝pid file = /var/run/ #PID⽂件路径lock file = /var/run/ #锁⽂件路径log file = /var/log/ #⽇志⽂件路径#⾃定义模块名。模块是定义服务器哪个⽬录要被同步[backup]path = /data/test #同步⽬录的路径通过path指定comment = This is a backup #定义注释说明的内容ignore errors #忽略⼀些IO错误read only = yes #是否允许客户端上传数据(双向同步),yes表⽰不允许list = no #客户端请求显⽰模块列表时,本模块名称是否显⽰,默认为yes(true)hosts allow = 39.99.164.52 #设置哪些主机可以同步数据,多ip和⽹段之间使⽤空格分隔或者,分隔,没实践过auth users = test #设置允许连接服务器的账户(⾃定义命名)secrets file = /etc/s #密码验证⽂件名

3. 设置⽤户密码:vim /etc/stest:123456设置600权限:chmod 600 /etc/s给同步提⽰信息:echo "welcecho "welcome to Backup Server" > /etc/e to Backup Server" > /etc/启动服务:rsync --daemon --config=/etc/#关闭服务:pkill rsync开机启动:echo "rsync --daemon --config=/etc/" >> /etc/(这是6的)7的cat /usr/lib/systemd/system/e(看到service已经创建好了)systemctl enable rsyncd查看端⼝:ps -ef |grep 873

客户端1.创建测试⽬录及数据2.写虚拟⽤户密码设置密码⽂件:touch /etc/secho "123456" > /etc/schmod 600 /etc/s测试:rsync -avzP --delete --progress test@39.100.136.141::backup --password-file=/etc/s /data/test⽤test⽤户登陆到114.22.168.67的rsync服务器上,把backup模块中指定的数据同步到本地的/data/test⽬录下Sersync安装查看服务器内核是否⽀持inotify列出⽂件⽬录ll /proc/sys/fs/inotify出现下⾯的内容、说明服务器内核⽀持inotify-rw-r--r-- 1 root root 0 Dec 25 12:03 max_queued_events-rw-r--r-- 1 root root 0 Dec 25 15:05 max_user_instances-rw-r--r-- 1 root root 0 Dec 25 12:03 max_user_watches修改inotify默认参数(inotify默认内核参数值太⼩):修改inotify默认参数(inotify默认内核参数值太⼩)sysctl -a | grep max_queued_eventssysctl -a | grep max_user_watchessysctl -a | grep max_user_instances修改参数sysctl -w _queued_events="99999999"sysctl -w _user_watches="99999999"sysctl -w _user_instances="65535"⽣效sysctl -p参数说明:max_queued_events:inotify队列最⼤长度,如果值太⼩,会出现” Event Queue Overflow “错误,导致监控⽂件不准确max_user_watches:要同步的⽂件包含多少⽬录,可以⽤:find /var/www/synctest -type d | wc -l 统计,必须保证max_user_watches值⼤于统计结果(这⾥/var/www/synctest为同步⽂件⽬录)max_user_instances:每个⽤户创建inotify实例最⼤值tar xzf sersync2.5.4_64bit_binary_stable_ -bak

下⾯的不⽤看安装inotify-toolsinotify-tools是为linux下inotify⽂件监控⼯具提供的⼀套c的开发接⼝库函数,同时还提供了⼀系列的命令⾏⼯具,这些⼯具可以⽤来监控⽂件系统的事件。 inotify-tools是⽤c编写的,除了要求内核⽀持inotify外,不依赖于其他。inotify-tools提供两种⼯具,⼀是inotifywait,它是⽤来监控⽂件或⽬录的变化,⼆是inotifywatch,它是⽤来统计⽂件系统访问的次数。现在介绍⼀下它的使⽤⽅法。

tar xzf ;cd inotify-tools-3.14./configure --prefix=/data/inotifymake && make install加⼊环境变量echo "PATH=$PATH:/data/inotify/bin/" >>/etc/profile && source /etc/profileinotifywatch -h 查看⽤法服务端rsync的配置⽂件:uid = rootgid = rootuse chroot = nomax connections = 5strict modes = yesport = 873pid file = /var/run/k file = /var/run/g file = /var/log/

[backup]path = /data/testcomment = This is a backupignore errorsread only = yeslist = nohosts allow = 39.99.164.52auth users = testsecrets file = /etc/s

发布者:admin,转转请注明出处:http://www.yc00.com/xiaochengxu/1689741243a282602.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信