两台Linux服务器 centos 多个文件目录实现同步

1.软件安装

首先检查是否已经安装,检查是否安装rsync软件
rpm -qa |grep rsync

主节点安装sersync
yum –y install sersync

备份节点安装rsync
yum –y install rsync

2.编写配置

  • 主节点为IP149 

在/usr/local/sersync/conf/tmp的下有个confxml.xml

复制一份到/usr/local/sersync/conf下,进行修改配置

sks_pdf.xml



    
     
    
	
    
	
    
	
	
	
	
    
    
	      
	  
	  
	   
	     
	       
	      
	      
    

    
	
	

        

  

     
	
      
     
     
	 
     
     
 


 
	
	    
		
		
	    
	
	
    

    
		
	
	    
	    
	

	
    

    
	
	    
	
    
    
	
	    
	    
	    
	
    



注意修改配置

两台Linux服务器 centos 多个文件目录实现同步_第1张图片

watch 为同步到备份端的目录。

remote为备份服务器的IP和路径配置别名,sgin_xml在后面会有对应的目录。

users为备份服务器的用户,我用的root所以是root。

passwordfile 是密码文件,填入对应的目录和地址即可。


rsync.password配置如下:

必须改变文件权限为600 ,chomod 600 /etc/eisp_rsync/rsync.password 

rsync.password

test
  • 备份服务器IP120

在/etc的的目录下新建一个rsyncd-eisp.conf文件

rsyncd-eisp.conf

#rsync_config_______________start
##rsyncd.conf start##
uid = root
gid = root
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd-eisp.pid
lock file = /var/run/rsync-eisp.lock
log file = /var/log/rsyncd-eisp.log
ignore errors
read only = false
list = false
hosts allow = 192.168.5.149
hosts deny = 0.0.0.0/32
auth users = root
secrets file = /etc/eisp_rsync/rsync.password
[sign_xml]
path = /application/tomcat7/webapps/TZ

#rsync_config_______________end
###########################################

两台Linux服务器 centos 多个文件目录实现同步_第2张图片

hosts allow 允许接入的IP。此处我的主服务器的149所以配置这个。

hosts deny 禁止接入的IP。

auth users 验证密码用户,此处我用的root用户。

secrets file 密码文件。指定你配置的目录即可

备份节点的rsync.password文件和主节点的不同,备份服务器需要加入验证的用户名格式固定为

系统用户:密码

必须改变文件权限为600,chomod 600 /etc/eisp_rsync/rsync.password 

root:test

3.启动服务

启动主节点 149机器上执行:

/usr/local/sersync/bin/sersync -r -d -o /usr/local/sersync/conf/sks_pdf.xml

启动备份节点:

/usr/bin/rsync --daemon --config=/etc/rsyncd-eisp.conf 

初始同步所有文件一次命令,在149的服务上执行:

cd /application/tomcat7/webapps/TZ && rsync -aruz -R  --timeout=100 "./" [email protected]::sign_xml --password-file=/etc/eisp_rsync/rsync.password

 

你可能感兴趣的:(linux,rsync,目录同步)