Environment: CentOS 5.2 (two units)
Rsync Server ip:192.168.1.114
Client ip:192.168.1.115
1. Install rsync and manage rsync via xinetd
Yum Install rsync xinetd
2. Modify the/etc/xinetd.d/rsync file so that it starts with xinetd
Vim/etc/xinetd.d/rsync
Modify Disable = Yes to disable = no
3. Firewall settings (rsync default port 837)
-A rh-firewall-1-input-p tcp-m state--state new-m TCP--dport 873-j ACCEPT
Service iptables Restart
4. Create the files required by rsync
Mkdir/etc/rsyncd
touch/etc/rsyncd/rsyncd.conf (master configuration file)
Touch/etc/rsyncd/secrets (verify user and password storage location)
TOUCH/ETC/RSYNCD/RSYNCD.MOTD (server description information)
ln/etc/rsyncd/rsyncd.conf/etc/rsyncd.conf (link creation)
chmod 600/etc/rsyncd.secrets (set permissions for this file) is required
Chown Root:root/etc/rsyncd.secrets (set the owning user and group to the file)
5. Modify the master configuration file
Vi/etc/rsyncd/rsyncd.conf
# Required by THE/ETC/INIT.D/RSYNCD script
PID file =/var/run/rsyncd.pid (tells the process to write to the file)
Port = 873 (Specify service port)
Address = 192.168.1.114 (set server IP address)
UID = root (server transfers files with root permission)
GID = root
Use chroot = yes
Read Only = yes (read-only, do not allow the client to upload files to the server)
#limit access to private LANs
Hosts allow=192.168.1.0/255.255.255.0 (restricts access to the service's network segment)
Hosts deny=*
Max connections = 5 (maximum number of connections)
MOTD file =/ETC/RSYNCD/RSYNCD.MOTD (server information definition points to the file, the file can write server information)
This would give you a separate log file
#log file =/var/log/rsync.log
#This would log every file transferred-up to 85,000+ per user, per sync
#transfer logging = yes
Log format =%t%a%m%f%b (log file format)
Syslog facility = Local3
Timeout = 300 (time-out)
[Backup] (link name)
Path =/Home (the path to which the link name points)
List=yes (the directory on the server where the data is synchronized is listed on the server module)
Ignore errors (ignoring IO errors)
Auth users = CS (authenticated user, my user is CS)
Secrets file =/etc/rsyncd/rsyncd.secrets (point to verify user holds files)
6. Modifying rsyncd.secrets and RSYNCD.MOTD files
Vi/etc/rsyncd/rsyncd.secrets
cs:123456 (CS exists for the system user, but the password is best set to be different from the system password)
Vi/etc/rsyncd/rsyncd.motd
++++++++++++++++++++++++++++++++
Welcome
++++++++++++++++++++++++++++++++
7. Restart the service
Service xinetd Restart
Client synchronization test (client to install rsync)
Rsync–avzp cs@192.168.1.114::backup/var/local
It means to log on to the server with CS user and save the directory data specified by backup to my local/var/local
Testing is not smooth sailing, encountered some problems, you can see the reference link.
Client fully synchronizes server touch Rsync.password (creates a file that holds the password) chmod rsync.password echo "123456" > Rsync.password (write password) Rsyn C-avzp --delete --password-file=rsync.password cs@192.168.1.114::backup/var/local