Set up rsync remote file synchronization service under Centos6.5
I. Server Installation
1. System Environment
Server: centos6.5 Factory environment (set by default during system installation), IP: 192.168.10.185
Client: Remote logon terminal xshell5 or securecrt (please check the installation and usage ),
IP: 192.168.10.186
2. Install Rsync
Log on to the system 192.168.10.185 through the terminal (xshell here)
Rpm-qa | grep rsync * // check whether the service is currently installed. if the version is low, run
Rpm-e rsync * // uninstall the software
Installation Method 1:
Run yum-y install rsync
Rpm-qa | grep rsync * // run this statement to view information about the installed software.
Rsync. x86_64. 0.6-12. el6
Installation Method 2:
Download the source code package from the rsync Website:Http://rsync.samba.org/Pack name: rsync-3.1.1.tar.gz
Yum-y install lrzsz // enter rz in the command line: Upload the downloaded source code package to the server.
Tar zxf rsync-3.1.1.tar.gz
Cd rsync-3.1.1
./Configure -- prefix =/app
Make
Make install
Start File Location:/app/bin/rsync
3. Create an rsync configuration file (not available by default)
Create rsyncd. conf under/etc/respectively (service configuration file)
Rsync. passwd (stores the account and password used by the client to log on to the rsync Service)
Rsyncd. motd)
######################################## ######################################## ##########
Vim/etc/rsyncd. conf // create a service configuration file
Uid = root
Gid = root
Port = 873 // specify the access port. The default value is 873.
Hosts allow = Client IP address // the client to be accessed
# Hosts deny =
# User chroot =
# Max connections =
# Timeout =
[Backup]
Path =/bak // Note: If this directory does not exist, do not forget to create it!
Comment = rsync files
Ignore erros
Read only = no
List = yes
Auth usres = rsync // The account used for synchronization verification. If not, it is anonymous synchronization. If the client does not have a user name, it can also be synchronized.
Secrets file =/etc/rsync. passwd // The place where the authentication file is stored
######################################## ######################################## #########
Vim/etc/rsync. passwd // create an authentication File
Syj: syj2015 // This format is required. The rsync account is the auth users in the service configuration file. The two are consistent and the password is customized.
Chmod 600/etc/rsync. passwd // change the File Permission to read-only by the owner
4. Firewall settings
Iptables-a input-p tcp -- dport 873-j ACCEPT // the server can be accessed locally and can be tested first.
Iptables-I INPUT-p tcp -- dport 873-j ACCEPT // The client can access
5. Start the rsync Service
/Usr/bin/rsync -- daemon
6. Check whether the service is started.
[Root @ localhost ~] # Lsof-I: 873
Command pid user fd type device size/OFF NODE NAME
Rsync 28055 root 3u IPv4 81353 0t0 TCP *: rsync (LISTEN)
Rsync 28055 root 5u IPv6 81354 0t0 TCP *: rsync (LISTEN)
In this case, the service is enabled.
Ii. Client installation
1. Execute yum-y install rsync like the Server installation.
2. Start rsync and run/usr/bin/rsync -- daemon.
3. After step 3 is completed, "Failed to parse config file:/etc/rsyncd. conf" appears ",
Solution: Create an empty configuration file vim/etc/rsyncd. conf and execute Step 1 again.
Iii. instance (Server IP: 192.168.10.185, Client IP: 192.168.10.186)
1. log on to the client and back up the content in the/bak folder on the server to the/imagefile on the client:
/App/bin/rsync-vzrtopg -- delete-- Progress rsync@192.168.10.185: bak/imagefile
2. log on to the client and back up the content in the client/imagefile folder to the server/bak:
/App/bin/rsync-vzrtopg -- delete -- progress/imagefile rsync@192.168.10.185: backup-- Password-file =/etc/secret. pas (password verification is automatically provided)