部署sersync实时同步服务器
2018-02-23 14:10
351 查看
部署sersync实时同步服务器
一、部署rsync
服务端的部署#安装rsync yum install rsync -y #编辑配置文件,我这里使用的是root用户 vim /etc/rsyncd.conf #rsync_config #created by HQ at 2017 ##rsyncd.conf start## uid = root #rsync用户 gid = root use chroot = no max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsync.lock log file = /var/log/rsyncd.log ignore errors read only = false list = false hosts allow = 192.168.1.0/24 #允许网段 hosts deny = 0.0.0.0/32 auth users = rsync_backup #认证用户 secrets file = /etc/rsync.password [back] #这里关系到sersync配置 comment = "nfs_backup" path = /back #创建密码验证文件 touch /etc/rsync.password echo "认证用户:密码" >> /etc/rsync.password chmod 600 /etc/rsync.password #启动rsync rsync --daemon
客户端部署
#安装rsync yum install rsync -y #创建密码验证文件 touch /etc/rsync.password echo "密码" chmod 600 /etc/rsync.password
二、安全策略
为了使服务器更加安全,这里采用了ipset做安全策略,简单方便,客户端和服务端都安装#安装 yum install ipset #使用 ipset 创建列表,我这里起名为server ipset create server hash:ip #添加 ip ipset add server <ip1> ipset add server <ip2> #导出 ipset,以后如果再添加ip直接去/etc/sysconfig/ipset修改,修改后执行service ipset reload ipset save > /etc/sysconfig/ipset #iptable添加ipset策略 -A INPUT -m set --match-set server src -j ACCEPT
三、安装seresync软件
#直接下载二进制包 wget https://sersync.googlecode.com/files/sersync2.5.4_64bit_binary_stable_final.tar.gz #解压后放到usr/local/sersync/下,然后修改配置文件 vim /usr/local/sersync/config/ <?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> <delete start="false"/> <createFolder start="true"/> <createFile start="true"/> <closeWrite start="true"/> <moveFrom start="true"/> <moveTo start="true"/> <attrib start="false"/> <modify start="false"/> </inotify> <sersync> <localpath watch="/www/linlaoban/pigcms/upload"> #监控目录 <remote ip="192.168.1.216" name="back"/> <!--<remote ip="192.168.8.39" name="tongbu"/>--> <!--<remote ip="192.168.8.40" name="tongbu"/>--> </localpath> <rsync> #rsync相关 <commonParams params="-azP"/> <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/> <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 every 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> <plugin name="command"> <param prefix="/bin/sh" suffix="" ignoreError="true"/> <!--prefix /opt/tongbu/mmm.sh suffix--> <filter start="false"> <include expression="(.*)\.php"/> <include expression="(.*)\.sh"/> </filter> </plugin> <plugin name="socket"> <localpath watch="/opt/tongbu"> <deshost ip="192.168.138.20" port="8009"/> </localpath> </plugin> <plugin name="refreshCDN"> <localpath watch="/data0/htdocs/cms.xoyo.com/site/"> <cdninfo domainname="ccms.chinacache.com" port="80" username="xxxx" passwd="xxxx"/> <sendurl base="http://pic.xoyo.com/cms"/> <regexurl regex="false" match="cms.xoyo.com/site([/a-zA-Z0-9]*).xoyo.com/images"/> </localpath> </plugin> </head>
四、测试
#先测试一下rsync是否可用 rsync -avz /etc/hosts rsync_backup@192.168.1.216::back --password-file=/etc/rsync.password #没问题后启动sersync /usr/local/sersync/bin/sersync2 -dro /usr/local/sersync/conf/confxml.xml 参数-d:启用守护进程模式 参数-r:在监控前,将监控目录与远程主机用rsync命令推送一遍 参数-o:指定配置文件,默认使用confxml.xml文件
相关文章推荐
- Sersync+Rsync实现服务器数据实时同步及xml高级配置!
- 使用sersync实现多台服务器实时同步文件 推荐
- sersync 开源服务器文件实时同步工具
- sersync代替inotify实现服务器之间实时同步(CentOS 6.7)
- 使用Rsync+sersync架构(多实例),保持web服务器网页发布目录实时同步
- 金山逍遥网 sersync 服务器实时镜像、自动同步程序开源
- Sersync+Rsync实现服务器数据实时同步及xml高级配置!
- 关于SVN+sersync实时同步到远程服务器的思路
- sersync实现多台服务器实时同步文件
- 部署rsync+sersync实现多机数据实时同步
- 服务器上安装sersync工具,实时触发rsync进行同步
- sersync+rsync实现服务器文件实时同步
- 关于SVN+sersync实时同步到远程服务器的思路
- rsync+sersync实现向多服务器实时同步数据
- Ubuntu服务器之间进行Sersync+Rsync同步
- 企业Linux服务器数据实时同步备份的解决方案
- 20170711L07-09-03老男孩Linux运维实战培训-Sersync实时同步软件实战应用指南09
- 利用nginx集群式部署服务器中,数据同步问题
- rsync+inotify实现服务器之间文件实时同步
- 安装sersync实现服务器同步和镜像