1.介绍

\

2.业务服务器远程更新浏览服务器文件的脚本

#!/bin/bash

operate=$
ip=$
conf_file="/var/www/html/test/ip_list"
file_chsum="/var/www/html/test/cksvalue"
file_ser="10.60.10.62" cksum(){
ssh ${file_ser} "cksum ${conf_file}|awk '{print\$1}' > ${file_chsum}"
if [ $? -ne ];then
#生成cksum值失败
echo ""
fi
} if [[ ! $ip =~ ^[-]{,}\.[-]{,}\.[-]{,}\.[-]{,}$ ]];then
#IP不合法
echo "";
exit ;
fi if [[ "${operate}" == "add" ]];then
ips=`ssh ${file_ser} "cat $conf_file|grep ${ip}/32|wc -l"`
if [ ${ips} -eq ];then
ssh ${file_ser} "echo "${ip}/" >> $conf_file"
if [ $? -eq ];then
cksum
#添加IP成功
echo ""
exit ;
else
#添加IP失败
echo ""
exit ;
fi
else
#添加IP成功(IP已存在)
echo "";
exit ;
fi
elif [[ "${operate}" == "del" ]];then
ssh ${file_ser} "sed -i '/${ip}\/32/d' $conf_file"
if [ $? -eq ];then
cksum
#删除IP成功
echo ""
exit ;
else
#删除IP失败
echo ""
exit ;
fi
else
#参数1($)不合法
echo ""
exit ;
fi

3.浏览服务器采用http的方式提供配置文件和cksum值的浏览和下载

4.VPS主机群每隔30校验一次配置文件的cksum值来保持配置文件的最新状态

* * * * * sleep  && sh /tmp/sync_customIP.sh
* * * * * sleep && sh /tmp/sync_customIP.sh
#!/bin/bash

conf_file_url="http://10.60.10.62:8060/test/ip_list"
cksum_url="http://10.60.10.62:8060/test/cksvalue"
local_conf_file="/tmp/ip_list"
time=`date`
log="/tmp/sync_customIP.log" get_cksum() {
remote_cksum=`curl -s "${cksum_url}"`
local_cksum=`cksum ${local_conf_file}|awk '{print\$1}'`
} sync_file() {
cat ${local_conf_file} > /tmp/.tmp_ip.txt
wget -q ${conf_file_url} -O ${local_conf_file};
} get_cksum if [[ "$remote_cksum" != "$local_cksum" ]];then
sync_file
get_cksum
if [[ "$remote_cksum" != "$local_cksum" ]];then
cat /tmp/.tmp_ip.txt > ${local_conf_file}
echo "${time} sync fail.." >> $log
else
echo "${time} sync success.." >> $log
fi
else
echo "${time} there are no need to sync.. ">> $log
fi log_count=`cat $log |wc -l`
if [ $log_count -gt ];then
sed -i '1,1000d' $log
fi

服务器群秒级别文件同步(ssh+SHELL)的更多相关文章

  1. 负载均衡配置下的不同服务器【Linux】文件同步问题

    负载均衡配置下的不同服务器[Linux]文件同步问题2017年04月13日 22:04:28 守望dfdfdf 阅读数:2468 标签: linux负载均衡服务器 更多个人分类: 工作 问题编辑版权声 ...

  2. linux多服务器之间的目录文件同步

    一.rsync是什么 在开始正式学习rsync之前,我们先来回答这个问题:rsync是什么. rsync(remote synchronize)是Liunx/Unix下的一个远程数据同步工具.它可通过 ...

  3. 文件同步服务器,iis 集群 ,代码同步(一)

    文件同步服务器 BitTorrent Sync 有点像TeamViewer远程协助 软件,私钥连接. 使用版本就30 天,最近测试了,功能不够理想.有点遗憾,我觉得我可以写一个! 确实很好用.

  4. rsync+sersync+inotify实现服务器间文件同步之一

    rsync+sersync+inotify实现服务器间文件同步之一:rsync安装配置 2013年12月14日 ⁄ Linux管理, 服务器集群技术 ⁄ 共 4925字 ⁄ rsync+sersync ...

  5. 使用inotify+rsync实现服务器间文件同步

      1. rsync 1.1 什么是rsync   rsync是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件.它使用所谓的“Rsync演算法”来使本地和远程两个主机之间的文件达到 ...

  6. BAT实现服务器文件同步

    服务器文件同步有很多工具,例如 GoodSync.rsync.BitTorrent Sync等……其实WINDOWS下自带了一个文件同步利器:ROBOCOPY.它是一个命令行的目录复制命令,自从Win ...

  7. BitTorrent Sync - 神奇的文件同步软件,无需服务器让多台电脑互相同步!

    176,487 微博 腾讯 空间 微信 141 49 如今人们对文件备份和同步的需求已经越来越强烈了.像 Dropbox 一样的云存储网盘有很多,但它们都有一个局限性,就是所有的文件都得经过它们的服务 ...

  8. linux服务器之间的文件同步;rsync+inotifywait;同步多个目录

    1.双向同步:unison+inotify 2.单向同步:rsync+inotify python版的pyinotify 本文介绍第二种方法: 1.Inotify 是一个 Linux特性,它监控文件系 ...

  9. Rsync+inotify实现文件实时同步#附shell脚本

    强烈推荐先仔细看此文 https://segmentfault.com/a/1190000002427568 实验环境 centos 7.3 vm2:192.168.221.128 同步服务器 vm1 ...

随机推荐

  1. git绑定两个远程仓库

    最近在做公司项目,之前公司项目统一托管在codding 码云,最近我想把项目与自己的gitlab私人仓库再连接一下,作为自己作品收录的地方,这里总结一下用到的git命令及问题. 1.首先, 找到当前已 ...

  2. 找不到 android-support-v4 解决办法

    Project->properties->Java Build Path->Libraries->Add External Jars中加入sdk目录下的extras/andro ...

  3. 比SRCNN效果好的传统超分辨率算法汇总

    1.基于深度协作表达的人脸图像超分辨率算法研究与应用_百度学术 采用一种深度协作表达算法框架,构造深度的多线性模型 分段拟合高低分辨率图像块之间的非线性关系,本文算法简洁高效,提供了一种新的深度学习模 ...

  4. C#------如何深度克隆一个对象

    普通版: public static object CloneObject( object obj ) { using ( MemoryStream memStream = new MemoryStr ...

  5. Go之并发处理(售票问题)

    老问题:模拟一个售票窗口进行售票 先定义类型Ticket(车票)和Conductor(销售员)--偷懒了,把售票和产票都交给Conductor了 package util import () //-- ...

  6. Go错误处理(二)

    1,.error接口的定义 type error interface{ Error()string } 2.error的使用 func Foo(param int)(n int,err error){ ...

  7. 给button添加边框和圆角

    button是我们经常用到的控件,我把它的属性罗列一下: UIButton *Button = [[UIButton alloc] initWithFrame:CGRectMake(, , , )]; ...

  8. 【Python】TF环境

    1.pip show pip 2.python -m pip install --upgrade pip 3.conda list 4.pip install tensorflow 5.pip ins ...

  9. [Windows] Windows 8.1 取消在任务栏显示应用商店的应用

  10. DRBD架构详解(原创)

    DRBD概述Distributed Replicated Block Device(DRBD)是一种基于软件的,无共享,复制的存储解决方案,在服务器之间的对块设备(硬盘,分区,逻辑卷等)进行镜像.DR ...