CentOS 6.6 rsync Server and Client configuration
Basic information
system version |
hostname |
ip address |
role |
centos 6.6 |
backup |
10.0.0.10 |
rsync server |
centos 6.6 |
lamp01 |
10.0.0.8 |
rsync client |
CentOS 6.6 |
Lnmp02 |
10.0.0.9 |
rsync Client |
Server-side configuration
Create an rsync profile and write the configuration (the default rsync file does not exist and needs to be created)
[Email protected] ~]# touch/etc/rsyncd.conf
[Email protected] ~]# vim/etc/rsyncd.conf
[Email protected] ~]# cat/etc/rsyncd.conf
#Rsync Server
#created by Wangning 10:322017-6-8
# #rsyncd. conf start##
UID = rsync
GID = rsync
Use chroot = no
Max connections = 2000
Timeout = 600
PID file =/var/run/rsyncd.pid
Lock file =/var/run/rsync.lock
Log file =/var/log/rsyncd.log
Ignore errors
Read Only = False
List = False
Hosts allow = 10.0.0.0/24
Hosts Deny = 0.0.0.0/32
Auth users = Rsync_backup
Secrets File =/etc/rsync.password
#####################################
[Backup]
Comment = Backup server by wangning 10:39 2017-6-8
Path =/backup
2. Create rsync user and /backup directory, and /backup directory will change owner to rsync user
[Email protected] ~]# useradd rsync-s/sbin/nologin–m
[Email protected] ~]# Mkdir/backup
[Email protected] ~]# chown-r rsync/backup/
3. Create the Rsync.password file, set the permissions to ., and write the user name and password
[Email protected] ~]# echo "rsync_backup:123456" >>/etc/rsync.password
[Email protected] ~]# chmod 600/etc/rsync.password
4. Start the rsync daemon process and check to see if it starts successfully
[Email protected] ~]# Rsync–daemon
[[email protected] ~]# ps-ef|greprsync|grep-v grep
Root 1942 1 0 04:31? 00:00:00 Rsync–daemon
[Email protected] ~]# Netstat-tulpn|grep rsync
TCP 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1942/rsync
TCP 0 0::: 873:::* LISTEN 1942/rsync
[Email protected] ~]# Ss-tulpn|greprsync # # #ss like netstat
TCP LISTEN 0 5::: 873:::* Users: (("rsync", 1942,5)
TCP LISTEN 0 5 *:873 *:* Users: (("Rsync", 1942, 3)
5. Add rsync 's daemon process to boot
[Email protected] ~]# echo "rsync--daemon" >>/etc/rc.local
6. If you only need a LAN connection to the Rsync server and do not need an Internet connection, then you can bind the machine IP
[Email protected] ~]# Netstat-tulpn|grep rsync
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/99/EA/wKioL1lOZOqjQQSDAABAEFr8ClQ649.png "/>
[Email protected] ~]# pkill rsync # # #先杀死rsync进程
[Email protected] ~]# ps-ef|grep rsync # # #进程是否已杀死
[Email protected] ~]# rsync--daemon--address=10.0.0.10 # # #绑定本机IP
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/99/EA/wKiom1lOZOyjEYJsAAAwZaBoJLE699.png "/>
Client configuration (both push and pull are on the client)
1. Create a password file Rsync.password, set permissions 600, and write password 123456 to this file
[Email protected] ~]# echo "123456" >/etc/rsync.password
[Email protected] ~]# chmod 600/etc/rsync.password
2. Push the contents of the client's/tmp directory to the/backup directory on the server (this is a better push)
[Email protected] ~]# rsync-avz/tmp/[email protected]::backup--password-file=/etc/rsync.password # # #:: After backup is the module name, corresponding to [backup] in/etc/rsyncd.conf
[Email protected] ~]# rsync-avz--delete/tmp/[email protected]::backup--password-file=/etc/rsync.password # #加--dele Te means no differential synchronization, local and server-side directory content is consistent,--delete try not to use
[Email protected] ~]# rsync-avz--exclude=1.txt/tmp/[email protected]::backup--password-file=/etc/rsync.password # # Plus--exclude says other files are pushed in addition to the 1.txt file.
[Email protected] ~]# Rsync-avz--exclude={1,3,5}/tmp/[email protected]::backup--password-file=/etc/rsync.password # #加--exclude={1,3,5} indicates that other files are pushed except for the 1.txt,3.txt,5.txt file.
3. Pull the contents of the/backup directory from the server to the client's/tmp directory
[Email protected] ~]# Rsync-avz [email protected]::backup--password-file=/etc/rsync.password/tmp/
This article is from the "Galloping Camel" blog, make sure to keep this source http://wn2100.blog.51cto.com/9915310/1941590
Cnetos 6.6 Rsync's server and client configuration