I. Server operations (master server)
Check method:
1. rpm-qa rsync
The rsync package is installed.
2. rsync + press enter
The help information indicates that the tool has been installed.
Configuration starts
Vim/etc/xinetd. d/rsync
1 configure rsync servervi/etc/xinetd. d/rsync
The code is as follows: |
Copy code |
Change disable = yes to no Service rsync { Disable = no Socket_type = stream Wait = no User = root Server =/usr/bin/rsync Server_args = -- daemon Log_on_failure + = USERID }
|
2 configure rsync to start automatically
The code is as follows: |
Copy code |
[Root @ test etc] # chkconfig rsync on [Root @ test etc] # chkconfig rsync -- list Rsync on
|
3. Configure rsyncd. conf
Rsync mainly includes the following three configuration files: rsyncd. conf (main configuration file), rsyncd. secrets (password file), rsyncd. motd (rysnc server information)
Server configuration file (/etc/rsyncd. conf). This file does not exist by default. Please create it.
The procedure is as follows:
The code is as follows: |
Copy code |
# Touch/etc/rsyncd. conf # create rsyncd. conf, which is the configuration file of the rsync server. # Touch/etc/rsyncd. secrets # create rsyncd. secrets, which is the user password file. # Chmod 600/etc/rsyncd. secrets # set the file attribute of the rsyncd. secrets password file to root and set the permission to 600. Otherwise, the backup will fail! # Touch/etc/rsyncd. motd Rsyncd. conf is as follows: Log file =/var/log/rsyncd. log # log file location. This file is automatically generated after rsync is started. You do not need to create it in advance. Pidfile =/var/run/rsyncd. pid # storage location of the pid file Lock file =/var/run/rsync. lock # lock files supporting the max connections parameter Secrets file =/etc/rsyncd. secrets # The user authentication configuration file, which stores the user name and password. This file will be created later. Motd file =/etc/rsyncd. Motd # Welcome to the file location on the page when rsync is started (custom file content) [Home_www] # Custom name Path =/home/DemoRoot/Uploads/# rsync server data directory path Comment = home_www # The module name is the same as the custom name of [home_www] Uid = root # set rsync operation permission to root Gid = root # set rsync operation permission to root Port = 873 # default port Use chroot = no # The default value is true. Change it to no to add a backup for the soft connection to the directory file. Read only = no # Set The rsync server file to read and write permissions List = no # The rsync server resource list is not displayed. Max connections = 200 # maximum number of connections Timeout = 600 # set the timeout value Auth users = root # User name for data synchronization. Multiple user names can be set and separated by commas (,). Hosts allow = 219.234.5.167 # client IP addresses that allow data synchronization. You can set multiple IP addresses separated by commas (,). Hosts deny = 192.168.21.254 # IP address of the client that prohibits data synchronization. You can set multiple IP addresses, which are separated by commas (,). Rsyncd. secrets: Root: mypassword Rsyncd. motd is as follows: ++ ++ Welcome to use the mike.org.cn rsync services! 2002------2009 ++ ++ Start rsyncd:/usr/bin/rsync -- daemon -- config =/etc/rsyncd. conf |
2. Client operations (backup server)
Create the/etc/passwd.txt file, whose content is the password mypassword set by rsyncd. secrets on the server.
The code is as follows: |
Copy code |
Rsync-avzP -- delete -- password-file =/etc/passwd.txt root@219.234.5.167: home_www/home/DemoRoot/Uploads/ |
Local synchronization address
The data has been synchronized from the server to the client.