我无法找到任何文章来回答这个问题,所以我最好的选择是在这里发布:
脚本
我们有2个应用程序服务器在生产托管PHP网站,我想在2之间同步一些文件夹,同样是为开发环境设置没有问题,我已经按照URL“http://www.cloudedify.com/synchronising-files-in-cloud-with-csync2/”的所有说明,我仍然似乎有相同的结果,防火墙已被禁用在两个盒子上用于故障目的:
配置文件:
cysnc2.cfg
nossl * *; group production { host server1; host server2; key /etc/csync-production-group.key; include /etc/httpd/sites-available; include /xxxxxx/public_html/files include /xxxxxxx/magento/media/catalog/product include /xxxxxxx/magento/media/brands exclude *.log; exclude /xxxx/public_html/file/cache; exclude /xxxxx/public_html/magento/var/cache; exclude /xxxx/public_html/logs; exclude /xxxxx/public_html/magento/var/log; backup-directory /data/sync-conflicts/; backup-generations 2; auto younger; }
/etc/xinetd.d/csync2
csync2.cfg
service csync2 { disable = no flags = REUSE socket_type = stream wait = no user = root group = root server = /usr/sbin/csync2 server_args = -i -D /data/sync-db/ port = 30865 type = UNLISTED log_type = FILE /data/logs/csync2/csync2-xinetd.log log_on_failure += USERID }
我确保守护进程正在端口30865上的服务器上监听,并且在两台服务器上都匹配了密钥
我在每台服务器上运行tcpdump,输出如下:
12:20:31.366771 IP server1.49919 > server2.csync2: Flags [S],seq 445156159,win 14600,options [mss 1460,sackOK,TS val 794864936 ecr 0,nop,wscale 7],length 0 12:20:31.366810 IP server2.csync2 > server1.49919: Flags [S.],seq 450593575,ack 445156160,win 14480,TS val 794798911 ecr 794864936,length 0 12:20:31.367101 IP server1.49919 > server2.csync2: Flags [.],ack 1,win 115,options [nop,TS val 794864937 ecr 794798911],length 0 12:20:31.367138 IP server1.49919 > server2.csync2: Flags [P.],seq 1:9,length 8 12:20:31.367147 IP server2.csync2 > server1.49919: Flags [.],ack 9,win 114,TS val 794798912 ecr 794864937],length 0 12:20:31.368625 IP server2.csync2 > server1.49919: Flags [R.],seq 1,TS val 794798913 ecr 794864937],length 0
还有什么我错过或应该做的吗?
解决方法
我不得不删除我提供给csync2的-N主机的127.0.0.1条目. “app1”的127.0.0.1条目导致csync2客户端要绑定到127.0.0.1而不是使用内部网络.
相反,使用守护进程,我使用包装器而不是直接调用csync2来强制执行我的-N主机名首选项.
#!/bin/sh # cluster-csync2.sh CSYNC2_SYSTEM_DIR=/etc /opt/cluster/bin/csync2 -i -D /var/lib/csync2 -N `hostname -s`
我的/etc/inetd.conf条目(端口在/ etc / services中定义):
csync2 stream tcp nowait root /opt/cluster/bin/cluster-csync2.sh cluster-csync2.sh