之前做的笔记,下面的总结:
rsync实现数据同步
(两台主机必须时间同步),注意先将122的rsync配置完成,selinux必须关闭/警告,火墙关闭
主机112的配置:
yum install rsync -y
tar zxf sersync2.5.4_64bit_binary_stable_final.tar.gz
mv GNU-Linux-x86 /opt/
cd /opt/GNU-Linux-x86/
vim confxml.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<head version="2.5">
<host hostip="localhost" port="8008"></host>
<debug start="false"/>
<fileSystem xfs="false"/>
<filter start="false">
<exclude expression="(.*)\.svn"></exclude>
<exclude expression="(.*)\.gz"></exclude>
<exclude expression="^info/*"></exclude>
<exclude expression="^static/*"></exclude>
</filter>
<inotify>
<delete start="true"/>
<createFolder start="true"/>
<createFile start="ture"/>
<closeWrite start="true"/>
<moveFrom start="true"/>
<moveTo start="true"/>
<attrib start="true"/>
<modify start="true"/>
</inotify>
<sersync>
<localpath watch="/usr/local/apache-tomcat-7.0.37/webapps/ROOT">
//本地同步目录 <remote ip="192.168.0.122" name="web"/> //将112上的数据同步到122上
//注意web是与122上同名的
<!--<remote ip="192.168.8.39" name="tongbu"/>-->
<!--<remote ip="192.168.8.40" name="tongbu"/>-->
</localpath>
./sersync2 -r -d //当这个开启,并且两台主机的时间同步,是监控所同步目录的动作
//-r为同步目录,-d为打入后台
cd /usr/local/apache-tomcat-7.0.37/webapps/ROOT/
vim index.html
./sersync -n 8 -o abc.xml -r -d //若想同步多个目录可执行这个命令,系统将会开 启另一个控管进程,abc.xml是另外一个配置文件
主机122的配置:
yum install -y rsync xinetd
vim /etc/rsyncd.conf
uid=root
gid=root
max connections=1024
use chroot=no
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock
[web]
path=/usr/local/apache-tomcat-7.0.37/webapps/ROOT
comment = web files
ignore errors = yes
read only = no
hosts allow = 192.168.0.112
hosts deny = *
vim /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
}
/etc/init.d/xinetd start //rsync是由xinetd控管的,所以必须开启此服务
netstat -antlp //查看873端口是否打开
配置完毕
接下来进行测试
112上:vim /usr/local/apache-tomcat-7.0.37/webapps/ROOT/index.html
122上:cat /usr/local/apache-tomcat-7.0.37/webapps/ROOT/index.html
查看是否同步
阅读(4538) | 评论(0) | 转发(0) |