linux文件同步工具rsync配置方法.docx
文本预览下载声明
查看SELinux状态:1、/usr/sbin/sestatus -v ##如果SELinux status参数为enabled即为开启状态SELinux status: enabled2、getenforce ##也可以用这个命令检查关闭SELinux:1、临时关闭(不用重启机器):setenforce 0 ##设置SELinux 成为permissive模式 ##setenforce 1 设置SELinux 成为enforcing模式2、修改配置文件需要重启机器:修改/etc/selinux/config 文件将SELINUX=enforcing改为SELINUX=disabled重启机器即可首先配置服务器之间的信任关系一、服务器端配置1、关闭防火墙和SELinuxservice iptables stop #关闭iptableschkconfig iptables off #关闭自动启动setenforce 0 #临时关闭SELinux2、定义配置文件/etc/rsyncd.confuid = nobody#进行备份的用户,拷贝过来的文件显示的用户属性gid = nobody#进行备份的组,拷贝过来的文件显示的组属性user chroot = nomax connections = 200timeout = 600pid file = /var/run/rsyncd.pidlock file = /var/run/rsyncd.locklog file = /var/log/rsyncd.log[backup] #对外公布的名字,客户机备份的数据存储在此目录中path = /backup/ignore errorsread only = nolist = nohosts allow = /auth users = test #认证的用户名。服务器实实在在的用户secrets file = /etc/rsyncd.password3、编辑/etc/xinetd.d/rsync配置文件# default: off# description: The rsync server is a good addition to an ftp server, as it \# allows crc checksumming etc.service rsync{ disable = no #将默认的yes改为no# flags = IPv6 socket_type = stream wait = no user = root server = /usr/bin/rsync server_args = --daemon log_on_failure += USERID}重启服务service xinetd restart4、建共享目录、加权限、建密码文件mkdir /backupchmod -R 777 /backupecho test:test /etc/rsyncd.password #test:test是用户名和密码chmod 600 /etc/rsyncd.password其中/backup/. 目录所属的用户和用户组要设置为uid和gid的用户二、客户端配置1、新建密码文件echo test /etc/rsyncd.password #客户端只需要密码,不需要用户名chmod 600 /etc/rsyncd.password2、新建脚本命令rsync -vzrtopg --delete /usr/longrise/ DB01@44::backup --password-file=/etc/rsyncd.password #其中/usr/longrise 为本地文件夹目录,DB01@44::backup为远端目录同步本地/usr/longrise目录的文件及文件夹到远端(rsync服务器)目录下,并删除远端服务器端存在而本地目录中不存在的文件及目录参数解析:1.rsyncd.conf配置文件1.1 全局参数在[moudle]之前的参数都是全局参数,也可以在全局参数下定义部分模块参数,这时该参数的值就是所有模块的默认值。port:指定后台程序使用的端口号,默认是873log file:指定rsync的日志文件,而不把日志发送
显示全部