Goals:
The/opt/web directory on server a is synchronized with the/opt/web directory on server B. That is, B actively synchronizes with.
OS: centos6.5
A server 192.168.189.152/opt/APP
B server 192.168.189.153/opt/APP
Use Yum to install the xinetd service (both nodes must be installed)
Yum install-y xinetd
I. A server config
1. The Rsync system comes with the -- deamon method to start. The service port is TCP 873.
2. Change disable = yes to disable = No in VI/etc/xinetd. d/rsync. The modified file is as follows:
# Default: Off
# Description: the rsync server is a good addition to an FTP server, as it \
# Allows CRC checksumming etc.
Service rsync
{
Disable = No
Socket_type = stream
Wait = No
User = root
Server =/usr/bin/rsync
Server_args = -- daemon
Log_on_failure + = userid
}
3. Service xinetd restart, restart the xinted Service
4. Edit the main configuration file/etc/rsyncd. conf, which needs to be created by yourself.
VI/etc/rsyncd. conf
Uid = nobody
Gid = nobody
Use chroot = No
Max connections = 4
PID file =/var/run/rsyncd. PID
Lock file =/var/run/rsyncd. Lock
Log File =/var/log/rsyncd. Log
[App]
Path =/opt/APP
Ignore errors
Read Only = true
List = false
Hosts allow = 192.168.189.0 # allowed IP addresses
Hosts deny = 0.0.0.0/32 # IP address prohibited
Auth users = backup # authentication username, in this example, backup
Secrets file =/etc/backup. pass # authenticate the user's password file
5. Edit the server password file/etc/backup. Pass.
VI/etc/backup. Pass
Backup: 123456
6. chmod 400/etc/backup. Pass
II. B server config. This is the synchronization machine.
1. Edit the password file/etc/rsync_client.pass during rsync connection.
VI/etc/rsync_client.pass
123456 # You only need to configure the password used for connection. It must be the same as the password defined on server.
2. chmod 600/etc/rsync_client.pass
3. Use the rsync command to connect to the server for file synchronization
# Rsync-vzrtopg -- Progress -- delete -- password-file =/etc/rsync_client.pass [email protected]: APP/opt/APP
4. Use -- execlude = to exclude file suffixes that do not need to be synchronized
Rsync-vzrtopg -- Progress -- delete -- password-file =/etc/rsync_client.pass -- exclude = "*. tmp" [email protected]: APP/opt/APP
5. Use -- execlude-from = to Exclude directories that do not need to be synchronized.
[[Email protected] Opt] # rsync-vzrtopg -- Progress -- delete -- password-file =/etc/rsync_client.pass -- exclude-from =/opt/pcdir [email protected]: APP/opt/APP
Rsync directory synchronization