双机热备(实时数据同步)

实验:定时同步数据
准备俩台实验机器,一台作为服务器server,一台作为client
server:192.168.18.126
client:192.168.18.127


如果想把126的数据实时同步到127:
sersync2监控------>126
rsync 服务端  ------>127




在126操作:
把sersync2工具上传到126
插件下载地址:http://download.csdn.net/detail/funk4/8125367
解压,并配置confxml.xml


<sersync>
        
<localpath watch="/opt/tongbu">
         #126机器的同步数据文件夹路径   
<remote ip="192.168.18.127" name="tongbu"/>#127机器同步数据文件名


<commonParams params="-artuz"/>
            
<auth start="true" users="lewis" passwordfile="/etc/rsync.pass"/>




在127操作:


1 install
yum install rsync




2  
touch this directory


[root@www rsyncd]# pwd
/etc/rsyncd
[root@www rsyncd]# ls -l
-rw-r--r-- 1 root root 491 07-25 11:08 rsyncd.conf
-rw-r--r-- 1 root root  64 07-25 10:26 rsyncd.motd
-rw------- 1 root root   8 07-25 10:26 rsyncd.secrets


3  vim /etc/rsyncd/rsyncd.conf
uid=root
gid=root
port=873
max connections=0
log file=/var/log/rsyncd.log
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsyncd.lock


motd file=/etc/rsyncd/rsyncd.motd
read only=yes




[cache]
path=/cache
list=yes
ignore errors
auth users=lewis#设置虚拟用户
secrets file=/etc/rsyncd/rsyncd.p#虚拟用户密码
read only=no


[root@www rsyncd]# cat rsyncd.motd #欢迎页面
#####################
 welcome
#####################




[root@www rsyncd]# cat rsyncd.p 
lewis:123


[root@www rsyncd]# chmod 600 rsyncd.p


4 start #启动
[root@www rsyncd]# rsync --daemon --config=/etc/rsyncd/rsyncd.conf 
[root@www rsyncd]# lsof -i:873 #检查873端口
COMMAND  PID USER   FD   TYPE DEVICE SIZE NODE NAME
rsync   8043 root    4u  IPv6  22013       TCP *:rsync (LISTEN)
rsync   8043 root    5u  IPv4  22014       TCP *:rsync (LISTEN)


在再126操作:


[root@www GNU-Linux-x86]# cat /etc/rsync.pass
123


[root@www GNU-Linux-x86]# chmod 600 /etc/rsync.pass
[root@www www]# ps axu | grep rsync 如果有运行过rsyncd,请删除(中午做了定时同步时,遗留下的进程)
root      8043  0.0  0.0   5252   480 ?        Ss   11:08   0:00 rsync --daemon --config=/etc/rsyncd/rsyncd.conf
root      8668  0.0  0.0   5024   696 pts/3    S+   11:46   0:00 grep rsync
[root@www www]# kill -9 8043




开始测试:
pwd
/opt/rsync/GNU-Linux-x86
./sersync2 -r #第一次执行记得加  -r




###################以下是成功信息提示:


set the system param
execute:echo 50000000 > /proc/sys/fs/inotify/max_user_watches
execute:echo 327679 > /proc/sys/fs/inotify/max_queued_events
parse the command param
daemon thread num: 10
parse xml config file
host ip : localhost     host port: 8008
use rsync password-file :
user is lewis
passwordfile is         /etc/146rsync.pass
config xml parse success
please set /etc/rsyncd.conf max connections=0 Manually
sersync working thread 12  = 1(primary thread) + 1(fail retry thread) + 10(daemon sub threads) 
Max threads numbers is: 22 = 12(Thread pool nums) + 10(Sub threads)
please according your cpu ,use -n param to adjust the cpu rate
run the sersync: 
watch path is: /opt/tongbu


#####################
现在可以在/opt/tongbu下建立文件,然后去127上查看根目录下的tongbu文件夹下是否有相同数据吧!









  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

撸依天

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值