XML File Description
The Sersync optional feature is implemented through an XML configuration file, with the following basic configuration files:
Copy Code code as follows:
<?xml version= "1.0" encoding= "Iso-8859-1"?>
<filter start= "false" >
<exclude expression= "(. *) \.gz" ></exclude>
<exclude expression= "^info/*" ></exclude>
</filter>
<inotify>
<delete start= "true"/>
<createfolder start= "true"/>
<createfile start= "true"/>
</inotify>
<debug start= "false"/>
<sersync>
<localpath watch= "/opt/tongbu" >
<remote ip= "192.168.0.104" name= "tongbu1"/>
<!--<remote ip= "192.168.8.39" name= "Tongbu"/>-->
<!--<remote ip= "192.168.8.40" name= "Tongbu"/>-->
</localpath>
<rsync>
<commonparams params= "-artuz"/>
<auth start= "false" users= "root" passwordfile= "/etc/rsync.pas"/>
<userdefinedport start= "false" port= "874"/><!--port=874-->
<timeout start= "false" Time= "/><!--timeout=100-->
<ssh start= "false"/>
</rsync>
<faillog path= "/tmp/rsync_fail_log.sh" timetoexecute= "/><"!--default every 60min execute once-->
<crontab start= "false" schedule= "600mins-->" ><!--
<crontabfilter start= "false" >
<exclude expression= "*.gz" ></exclude>
<exclude expression= "info/*" ></exclude>
</crontabfilter>
</crontab>
<plugin start= "false" name= "command"/>
</sersync>
Here's how to do this step-by-step explanation:
Copy Code code as follows:
HostIP and Port are reserved fields for plug-ins and have no effect on the synchronization function, leaving the default.
Filter file Filtering function
For sersync-Monitored files, the system's temporary files are filtered by default ("."). At the beginning, ending with "~", you can customize other files that you want to filter in addition to these files.
Copy Code code as follows:
<filter start= "true" >
<exclude expression= "(. *) \.gz" ></exclude>
<exclude expression= "^info/*" ></exclude>
</filter>
Set start to true, in the exclude tag, fill in the regular expression, the default given two examples are filtered to ". Gz" End of the file and filter the info path under the Monitoring directory (monitoring path/info/*), can be added as needed, but on the open, their own test, The console is prompted if an error occurs in the regular expression. Compared with the exclude function of rsync, the filtered path does not add to the monitoring, greatly reducing the traffic in rsync.
INotify Monitoring parameter setting (optimization)
For inotify monitoring parameters can be set up, according to the characteristics of your project to optimize Srsync.
Copy Code code as follows:
<inotify>
<delete start= "true"/>
<createfolder start= "true"/>
<createfile start= "true"/>
</inotify>
For most applications, you can try to set the CreateFile (monitor file event option) to false to improve performance and reduce rsync traffic. Because copy files to the monitoring directory will generate create events and Close_write events, so if you turn off the Create event, only monitor the file copy at the end of the event Close_write, you can also achieve a complete file synchronization.
Note: The forced CreateFolder remains true, and if the CreateFolder is set to False, the resulting directory will not be monitored, and the subdirectories and subdirectories under that directory will not be monitored. So unless you have special needs, please open it. By default, both the Create file (directory) event and the delete file (directory) event are monitored, and if you do not need to delete the file (directory) of the remote target server in your project, you can set the delete parameter to False, and the delete event is not monitored.
Debug Open
Copy Code code as follows:
Set to True to turn on debug mode and print the INotify event and rsync sync commands on the Sersync running console.
XFS File System
<filesystem xfs= "false"/>
For users of XFS file systems, this option needs to be turned on to make sersync work.
File monitoring and Remote synchronization settings
Copy Code code as follows:
<localpath watch= "/opt/tongbu" >
<remote ip= "192.168.0.104" name= "tongbu1"/>
<!--<remote ip= "192.168.8.39" name= "Tongbu"/>-->
<!--<remote ip= "192.168.8.40" name= "Tongbu"/>-->
</localpath>
See SERSYNC2 Full installation configuration instructions (i)--basic skills can be used
Rsync parameter Configuration
Copy Code code as follows:
<rsync>
<commonparams params= "-artuz"/>
<auth start= "false" users= "root" passwordfile= "/etc/rsync.pas"/>
<userdefinedport start= "false" port= "874"/><!--port=874-->
<timeout start= "false" Time= "/><!--timeout=100-->
<ssh start= "false"/>
</rsync>
Commonparams can customize the rsync parameter by default-artuz
When Auth start= "false" is set to true, use the authentication mode of rsync and configure user and Passwrodfile (–password-file=/etc/rsync.pas) to use. Userdefinedport use (–port=874) when the rsync port for the remote synchronization destination server is not the default port. Timeout Sets the timeout time (–timeout=100) for rsync. SSH uses rsync-e ssh for transmission.
Failure Log footstep Configuration
Copy Code code as follows:
<faillog path= "/tmp/rsync_fail_log.sh" timetoexecute= "/>"
For a failed transfer, a retransmission is performed, the Rsync_fail_log is written again, and then the script is retransmitted again at intervals (Timetoexecute settings), and then the script is emptied. You can set the log path by path.
crontab Periodic overall sync function
Copy Code code as follows:
<crontab start= "false" schedule= "600mins-->" ><!--
<crontabfilter start= "false" >
<exclude expression= "*.gz" ></exclude>
<exclude expression= "info/*" ></exclude>
</crontabfilter>
</crontab>
Crontab can be the monitoring path and remote target host at a time of the overall synchronization, possibly for some reason two failed retransmission failed, this time if the crontab function, you can further ensure that each server file consistent, if the file volume is larger, The crontab time interval should be larger, otherwise the communication overhead may increase. Schedule This parameter is to set the crontab time interval, the default is 600 minutes
If you turn on filter file filtering function, then crontab overall synchronization also need to set filter, otherwise, although the real-time synchronization of the file is filtered, but crontab overall synchronization if not separate set Crontabfilter, will need to filter the file synchronization to the remote, The crontab filter is different from filter filtering, and two examples are given to filter files and directories respectively. In short, if both filter and crontab are turned on, the crontabfilter of Crontab is turned on and the sample settings correspond to filter one by one of the filter.
Plug-in settings
Copy Code code as follows:
<plugin start= "false" name= "command"/>
When set to True, the plug-in specified by the name parameter is invoked when the file is synchronized to the remote server. See the plugin settings for details.