First, check whether there is rsync. If there is no rsync, an rsync will be installed.
1 configuration file
Then create rsyncd. CONF file, and add the following content (the file does not exist by default) [[email protected] backup] # Cat/etc/rsyncd. conf # rsync_config _____ start # Created by chensiqi 13:40 2017-3-6 # blog: http://www.cnblogs.com/chensiqiqi/##rsyncd.conf start ### user uid = rsync # group gid = rsync # program Security Settings use chroot = No # client connections Max connections = 200 # timeout = 300 # process number File Location PID file =/var/run/rsyncd. pid # process lock file =/var/run/rsync. lock # Log File Location log file =/var/log/rsyncd. log ####################################### ### [Backup] # use directory path =/backup/# ignore errors when an error occurs # readable and writable (true or false) read Only = false # block the remote list (do not let the remote view of what the server has) list = false # Allow iphosts allow = 192.168.197.0/24 # disable iphosts deny = 0.0.0.0/32 # virtual user auth users = rsync_backup # Secrets file for storing user and Password =/etc/rsync. password ## rsync_config ______ end ##
2. Create a shared directory and add rsync users
1 [[email protected] ~] # Useradd-m-S/sbin/nologin rsync # create rsync user 2 [email protected] ~] # Cat/etc/passwd | grep rsync3 rsync: X: 500: 500:/home/rsync:/sbin/nologin4 [[email protected] ~] # Cat/etc/group | grep rsync5 rsync: X: 500: 6 [[email protected] ~] # Mkdir/backup # create a shared directory
3. Change the/backup folder on a-server to rsync
1 [[email protected] ~] # Chown-r rsync/backup2 [[email protected] ~] # Ls-LD/backup3 drwxr-XR-X. 2 rsync root 4096 March 6 22:19/backup
4. Create an rsync virtual account name and password
1 1.5.5 create rsync virtual account name and password 2 3 [[email protected] ~] # Echo "rsync_backup: 123456">/etc/rsync. password4 [[email protected] ~] # Cat/etc/rsync. password5 rsync_backup: 123456
5. Set the account password file to 600 (required or not)
1 [[email protected] ~] # Chmod 600/etc/rsync. password2 [[email protected] ~] # Ll/etc/rsync. password3-RW -------. 1 Root 20 22:27/etc/rsync. Password
6. Start the service: rsync -- daemon
[[email protected] ~]# rsync --daemon[[email protected] ~]# netstat -antup | grep rsynctcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 5163/rsynctcp 0 0 :::873 :::* LISTEN 5163/rsync
7. Add to startup
[[email protected] ~]# echo "rsync --daemon" >> /etc/rc.local[[email protected] ~]# tail -1 /etc/rc.localrsync --daemon
Note:
Of course, you can also use the chkconfig rsync on command, but you must write a script suitable for the chkconfig operation.
How to restart the rsync service?
Pkill rsync # disable rsync
Rsync -- daemon # Start the rsync Service
Now rsync server a-server has been configured
2. Start to deploy the rsync service -- rsync client B-server. First, the client only needs to create a password file according to rsync1.
[[email protected] ~]# rpm -qa rsyncrsync-3.0.6-12.el6.x86_64[[email protected] ~]# echo "123456" > /etc/rsync.password
2. Set the Password File Permission to 600 (required or not)
[[email protected] ~]# chmod 600 /etc/rsync.password[[email protected] ~]# ls -ld /etc/rsync.password-rw-------. 1 root root 7 Mar 6 01:42 /etc/rsync.password
Now, the configuration of the B-server on the rsync client is complete.
Rsync server and client Creation