First, server-side configuration:
# yum-y Install xinetd
The following code
Disable = yes
Socket_type = Stream
wait = no
user = root
Log_on_failure + + USERID
Disable = yes change to disable = no
and start xinetd.
#/etc/init.d/xinetd Start or service xinetd restart
Note: If the server is equipped with a firewall, remember to open the port, the default port is 873
# telnet 127.0.0.1 873
Trying 127.0.0.1 ...
Telnet:connect to address 127.0.0.1:connection refused
# iptables-a input-s 192.168.0.0/255.255.255.0-p tcp-m tcp--dport 873-j ACCEPT
# iptables-a input-p tcp-m tcp--dport 873-j DROP
# vi/etc/rsyncd.conf (this file is created if it does not exist)
UID = root #以什么身份运行rsync
GID = root
Use chroot = no #不使用chroot
Max connections = #最大连接数
Secrets file =/etc/rsyncd.secrets #密码文件位置, authentication files settings, setting user name and password
Log file =/var/log/rsyncd.log #指定rsync的日志文件, not sending logs to syslog
PID file =/var/run/rsyncd.pid #指定rsync的pid文件
Lock file =/var/run/rsync.lock #指定支持max connections parameter, the default value is/var/run/rsyncd.lock
Comment = Hello World
#motd file =/etc/rsyncd.motd #欢迎信息文件名称和存放位置 (this file is not available and can be added by itself)
[Backup] # Here is the Certified module name, which needs to be specified on the client side
Path =/titan24/www/repos # A directory that needs to be mirrored
Auth users = rsync # Authorized account number. Authenticated username, if this line is not available, it indicates anonymity, multiple users, separated
Read Only = no # Yes reading value is no meaning is readable and writable mode, data recovery with no
Hosts allow = 192.168.3.128 #允许访问的服务器IP
Hosts deny = * #黑名单
List = true # allows column files
#ignore errors # can ignore some irrelevant IO errors
#exclude = cache/111/cache/222/#忽略的目录
# Vi/etc/rsyncd.secrets (set access (authenticated) Username password)
rsync:111111 #用户名: Password
Correct permissions to the file
# chown Root:root/etc/rsyncd.secrets
# chmod 600/etc/rsyncd.secrets # (must be 600)
Second, the client side of the synchronization
The client defaults as if it had been installed in rsync, without the words installed:
# yum-y Install rsync
To perform an asynchronous synchronization operation:
# crontab-e # (You can sync files every three minutes at timed time)
*/3 * * * * RSYNC-AVZ--progress email@example.com::backup/www
The following command is complete:
Note that the client's password file requires only a password and does not require a username!
To change file permissions:
#rsync-vzrtopgu--progress--delete--password-file=/etc/rsyncd.pas firstname.lastname@example.org::rsync_module_name1/www /
The V in-VZRTOPG in this command line is verbose,
Z is a compressed transmission,
R is recursive,
TOPG are the parameters that keep the original attributes of the file, such as the owner and the time.
You are only synchronizing the files that have been updated, so that files that are not updated are updated once, but be aware of the synchronization of both machines ' clocks.
–progress means showing detailed progress,
–delete means that if the server side deletes this file, then the client also deletes the file accordingly, maintaining true consistency.
Later in the email@example.com::rsync_module_name1, the rsync_module_name1 is the module name, which is the custom name in/etc/rsyncd.conf, rsync_ User is the username specified in the specified module that can be synchronized.
The final/www is the backup to the local directory name.
In this case, you can also use the e-ssh parameter to establish an encrypted connection.
You can use –password-file=/password/path/file to specify a password file, so that it can be used in the script without having to enter the authentication password interactively, it should be noted that this password file permission attribute must be set to only the owner-readable.
Or you can make password files.
Because of the need for system crontab execution, here is the way to read the password file,
This is the time to succeed.
Please continue to browse the next page: Sync command description
---------------------------------sync command Description:---------------------------------
1 Displaying directory Contents
c) rsync firstname.lastname@example.org::
d) rsync email@example.com:
A) Display directory contents (first level)
b) recursive display of directory content
c) Displaying the contents of the remote host directory
* NOTE 1: Port mode, authentication based on rsync user
* Note the directory on the 2:rsync server must have XX7 permissions.
d) View the contents of the remote host directory
* Note 1:remote shell mode, authentication based on system local user via SSH connection
* NOTE 2: This only uses a colon (:), while the user name is the remote host SSH user, the password is the SSH user's corresponding password.
* Note 3: Use "" To list information about the folder itself. To list the contents of a folder, you should use "/".
-R recursive operation of the directory
2 Sync between local directories
a) rsync-av–progress/* * * ATTENTION (/) * * *
A) Synchronize all files in the Src-dir directory to the Dst-dir directory
b Synchronize all files in the Src-dir directory to the Dst-dir/src-dir directory
c) The content of the Src-dir directory to the Dst-dir directory for differential updates, there are additions/updates to add replacement, there is a reduction in the deletion
D) More than a –temp-dir=/tmp, that is, specify/tmp as a temporary swap area, so as to avoid errors due to insufficient target directory space caused by the inability to sync files.
-A is equivalent to the-rlptgod set
-U is equivalent to –update and is not updated when the target file is newer than the source file
-V Display synchronized files
–progress percentage progress, transfer rate when file synchronization is displayed
–delete Delete files in the destination directory more than the source directory
3 Synchronization between remote hosts
A) rsync-avz–progress firstname.lastname@example.org::/
b) Rsync-avz–progress Jack@192.168.0.1::/–password-file=/home/jack/rsync.jack
c) Rsync-avuz–progress–delete Jack@192.168.0.1::/–password-file=/home/jack/rsync.jack
d) rsync-avz–progress email@example.com::/
A to synchronize the contents of the local directory to the remote host 192.168.0.1 directory, Jack is an rsync database user (see 3/etc/rsync.secrets)
(b) Synchronization of non-interactive logon files by automatically reading user passwords
c) more than B-U and –delete
d Synchronize remote host content to local directory