Home>

Use background:

In May 2005, the business network was in the online stage.However, due to the general reasons, it has been unable to go online.The basic functions of the system have been implemented.But as a business network as a whole,File synchronization is not complete yet.I happen to be not busy this time.Also interested in this one,So I decided to feel it.

All beginnings are hard,I ’ve never seen anything like synchronization,How to start?Fortunately, when I was working on a mail system,Met eyou's little bear, consulted him,So I recommend rsync as a good tool for me.Thank you in particular for your help.

The advantage of rsync is that it is easy to deploy.Easy to use,It's efficient and it's open source.It has been bundled in some Linux server versions,It can be seen that its function has been highly recognized.

About the introduction of rsync, you can go to google search,I believe we can find more,Here, I will no longer waste everyone's time (Mr. Lu Xun said:Wasting other people's time is equal to killing money,Wasting your own time is equal to chronic suicide.Know the severity of the consequences,Ha ha). Let's take a look at my implementation steps.

operating system:

File server:red hat linux advanced server release 2.1as/i686 (pensacola)

Client:red hat linux release 7.2 (enigma)

Among them, server-side Linux has been bundled with rsync. I also implemented the client under AIX.

[Precautions]:

1. To determine whether rsync is bound (installed) on the system itself, you can go to/usr/bin,/usr/local/bin/or/usr/sbin/to find if rsync exists.Or use whereis rsync.

2. The rsync system is bound. In /etc/xinetd.d/rsync, it is disabled by default.You can open it,Then restart the service service xinted restart

3. If the system itself is already installed,Then no need to install again,If you need to upgrade the rsync version, just follow the normal installation steps.

4. rsync is bound to port 873 by default. If rsync has been started as a background process,Then through netstat -nap | grep 873 you can see that there are rsync processes.

1.Install rsync

Step 1:Download the rsync package from (This article uses rsync 2.6.5 released)

Step 2:Upload the rsync package to the machine as the server (for example:128.128.6.168)

Step 3:Log in as root,Extract the rsync-2.6.5pre2.tar.gz package, go to the specified directory (for example:/home/zuohao/rsync /), and assign the rsync directory to a user (for example:zuohao).

Step 4:Enter the rsync directory. Type:./configure.

rsync will detect system information,And generate related files.

Step 5:Type make to compile the c file. (Note:Before running this command, determine whether to install a c compiler, such as gcc, cc, etc.)

Step 6:Type make install and install rsync. (Note:Before running this command, determine whether to install a c compiler, such as gcc, cc, etc.)

Step 7:If there is no problem in the above compilation,rsync installation is complete.

2. Configure the rsync server

The main configuration file of the server is /etc/rsyncd.conf (This file may not exist.You can create a new one yourself.) Alas, through this file you can configure parameters for global access,Module parameters to be backed up.Take the following configuration as an example:

uid=root
gid=root
use chroot=no
max connections=4
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsync.lock
log file=/var/log/rsyncd.log
hosts allow=128.128.6.38
[inburst]
path =/usr/shr
comment=backup client is redhat advance server 3.0
read only=yes
list=no
auth users=root
secrets file=/etc/inburst.pass
[file0]
path =/home/zuohao/www
comment=my rsync site
exclude=configfile

rsyncd.conf can have more configuration,Such as password verification,Module settings, etc.

[Precautions]

The permissions of rsyncd.conf and the password file must be 600, that is, only root can read and write

Please refer to more rsyncd.conf properties. conf.html

3. Configure the rsync client

Step 1:Install rsync:To achieve synchronization on the client,You also need to install the rsync service (see the installation method above).

Step 2:Test whether the installation was successful.

Enter on the command line:

rsync -vzrtopg --progress --delete [email protected] ::file0/home/zuohao/backup /

Check whether the local directory/home/zuohao/backup/is synchronized with the backup directory file in the server.

More parameter descriptions,Refer to the rsync website documentation:

Step 3:Program the shell to run regularly, run the above command,Achieve timing synchronization of files.

By editing crontab, add the corresponding script,Achieve timing synchronization of files. This example script is as follows:

*/30 * * * * zuohao /usr/local/bin/rsync.sh

Run once every 30 minutes.

4. Installation is complete

After completing the above configuration,The configuration of rsync server and client has been completed.Simple file timing synchronization can basically be achieved. There are more examples and documentation on the official website of rsync. Hope everyone can pass this example,With a great understanding of rsync,To be able to see those documents,This enables more comprehensive use of rsync.

Precautions

1. In general, rsync is installed on the Linux server.

2. Before installing rsync, make sure that the C compiler is installed on the system. Otherwise the installation cannot continue.

3. The installation of rsync must be root.

4, rsyncd.conf file permissions must be only root can read and write, that is, chmod 600 rsyncd.conf

5. If a password file is used,The password file's permission attribute can only be 600

  • Previous Analysis of Service instance passing data to Activity in real time in Android
  • Next Introduction to operator overloading in C ++ programming