Server A (Server 1) IP Address: 192.168.0.108
Server B (Server 2) IP Address: 192.168.0.109
Server 1 Configuration
1) edit the/etc/rsyncd. conf file. The main configuration file of rsync:
# [Globale]
Strict modes = Yes
# Check passwd file
Port = 873
# Default port used by rsync
# Default port
Logfile =/var/log/rsyncd. log # log file storage path
Pidfile =/var/run/rsyncd. pid # record the process ID when Rsync is running
Max connections = 4 # maximum number of synchronization links
# [Modules] # synchronization module configuration
[Appname] uid = root # This option specifies the UID that the daemon should have when the module transfers files
Gid = root # This option specifies the GID that the daemon should have when the module transfers files
Ignore errors # ignore irrelevant error messages
# Directory to be backed up
Path =/turbomail/accounts # directory to be synchronized
Read Only = No # whether to set to run in read-only mode
Host allow = 192.168.0.109 # If the IP address of the client for data synchronization has multiple clients, separate them with commas (,).
Auth users = root # synchronization Username
Secrets file =/etc/rsyncd. scrt # synchronized Password Authentication File
2) edit the/etc/rsyncd. scrt file and password authentication file.
Root: 123456
Change the permission to 600: chmod 600/etc/rsyncd. scrt
3) Run rsync -- daemon and add this statement to/etc/rc. d/rc. Local to automatically start the instance upon startup.
Note: The default rsync port is 873. If iptables is installed, open this port in iptables If You Want To enable rsync-port 873 during startup. The statement is as follows:
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 873-J accept
If Port 873 is not open, an exception is reported:
Rsync: failed to connect to x. x: No route to host (113)
Rsync error: Error in socket io (Code 10) at client server. C (107) [Sender = 2.6.8]
4) edit/etc/xinetd. d/rsync
The Rsync Service Listening is distributed by xinet in a unified manner:
Service rsync {
Disable = No # change this item to no
Socket_type = stream
Wait = No
User = root
Server =/usr/bin/rsync
Server_args = -- daemon
Log_on_failure + = userid
}
Restart xinetd to start the rsync Service
Service xinetd restart
5) check whether the rsync accident runs normally. Run the following command: netstat-ant | grep: 873. If the following statement is displayed, the rsync service has started properly.
TCP 0 0 0.0.0.0: 873 0.0.0.0: * listen
Server 2 Configuration:
1) edit the/etc/rsyncd. scrt file and password authentication file.
Root: 123456
Change the permission to 600: chmod 600/etc/rsyncd. scrt
2) edit the script VI/root/scrpit/rsync. SH and add it to boot automatically.
#! /Bin/sh
/Usr/bin/rsync-vazu -- Progress root@192.168.0.108: appname/Oracle/app_backup/appname-password-file =/etc/rsyncd. scrt
Modify permission: chmod U + x/root/scrpit/rsync. Sh
(Root@192.168.7.108: appname is a server configuration module name)
3) data synchronization is performed every morning.
Add crontab-e
0 0 *** root/scrpit/rsync. Sh start
You can configure the client here, and the server and client data will be executed once every morning.
Exception:
@ Error: chdir failedrsync error: Error starting client-server protocol (Code 5) at main. C (1296) [Sender = 2.6.8] causes and solutions: 1. If the backup path is not correctly established, the synchronization is successful. 2. setsebool-P rsync_disable_trans on
@ Error: AUTH failed on module appnamersync error: Error starting client-server protocol (Code 5) at main. C (1296) [Sender = 2.6.8] cause: When passwd is configured in rsyncd in the format of username: Password, this format cannot be used by the client. The file contains only password solutions: 1. file Content modification 2. rsync-Av -- password-file <(echo password) SRC dest
@ Error: chroot failed
Rsync error: Error starting client-server protocol (Code 5) at main. C (1522) [runner ER = 3.0.3]
Cause:
The directory in Server 1 does not exist or has insufficient permissions. If the root is used for backup, the directory does not exist.
English version (the use of rsyncd reference http:// OS .51cto.com/art/201009/225962.htm)