两遍服务器都安装好rsync后  如果做推送服务 被推送的服务器的 配置文件 注意事项

1服务端(192.168.1.241)配置的密匙文件 格式为【运行环境】

用户名:密码

root:123456

2 客户端(192.168.1.240)配置的密码文件[git代码托管]

密码

123456

客户端测试推送到服务器端

  1. rsync -vzrtopg --delete --progress --password-file=/etc/rsyncd/rsyncd.secrets /var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ root@192.168.1.241::linksame

环境服务器上面有两个 模块

(1) linksame

(2)  apps

inotufy 及时监控git代码修改 并推送到 服务器

/usr/local/inotify/rsync.sh

#!/bin/sh
srcdir=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ #源服务器地址
dstdir=linksame #241 目标服务器
rsyncuser=root #目标服务器用户名
rsyncpassdir=/etc/rsyncd/rsyncd.secrets #目标服务器密码
dstip="192.168.1.241" #目标服务器ip
for ip in $dstip
do
rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$ip::$dstdir --password-file=$rsyncpassdir
done
/usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move $srcdir | while read file
do
for ip in $dstip
do
rsync -avH --port=873 --progress --delete $srcdir $rsyncuser@$ip::$dstdir --password-file=$rsyncpassdir
echo " ${file} was rsynced" >> /tmp/rsync.log 2>&1
done
done

启动

#nohup /bin/bash /root/rsync.sh &

开机自启动

#echo "nohup /bin/bash /root/rsync.sh &" >> /etc/rc.local

监听本机多个文件夹下的文件单独创建监听文件 加入开机启动即可

  1. #!/bin/sh
  2. srcdir=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/linksame/ #源服务器地址
  3. srcdir2=/var/opt/gitlab/git-data/gitlab-satellites/ranmufei/apps/ #源服务器地址
  4. dstdir=linksame # 目标服务器
  5. dstdir2=apps # 目标服务器
  6. rsyncuser=root #目标服务器用户名
  7. rsyncpassdir=/etc/rsyncd/rsyncd.secrets #目标服务器密码
  8. dstip="192.168.1.241" #目标服务器ip
  9.  
  10. ##################linksame###############
  11. rsync -avH --port= --progress --delete $srcdir $rsyncuser@$dstip::$dstdir --password-file=$rsyncpassdir
  12.  
  13. /usr/local/inotify/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e close_write,modify,delete,create,attrib,move $srcdir | while read file
  14. do
  15.  
  16. rsync -avH --port= --progress --delete $srcdir $rsyncuser@$dstip::$dstdir --password-file=$rsyncpassdir
  17. echo " ${file} was rsynced" >> /tmp/rsync.log >&
  18.  
  19. done

一键安装包 服务器端 并没有安装git命令  如果要在服务器上面使用git 请单独安装 git

  1. yum install -y git

参考

http://www.osyunwei.com/archives/7435.html

rsync 推送的更多相关文章

  1. rsync推送和拉取

    rsync格式: # 拷贝本地文件.当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式.如:rsync -a /data /backup rsync [OP ...

  2. rsync推送备份服务器(Linux)

    rsync推送备份服务器备份服务器操作需被备份的服务器操作批处理shell备份服务器操作#编辑配置文件vi /etc/rsyncd.conf uid = root #运行RSYNC守护进程的用户gid ...

  3. rsync 系统用户/虚拟用户 备份web服务器数据及无交互定时推送备份

    一.服务环境 (1),WEBserver(192.168.10.130) : BACKserver(192.168.10.129) (2),BACKserver服务器部署,安装所需软件,并启动 (3) ...

  4. 【NFS项目实战二】NFS共享数据的时时同步推送备份

    [NFS项目实战二]NFS共享数据的时时同步推送备份 标签(空格分隔): Linux服务搭建-陈思齐 ---本教学笔记是本人学习和工作生涯中的摘记整理而成,此为初稿(尚有诸多不完善之处),为原创作品, ...

  5. 使用git或TortoiseGit推送项目至gitlab

    一.Wins安装Git+Trtoisegit工具实现版本克隆与推送 Git:         https://git-scm.com/ Tortoisegit: https://tortoisegit ...

  6. 博客搬家 - 记第四次搬家(hugo建站推送到谷歌云存储)

    写在前面,搬迁记录 记录我的博客这次搬家过程.我的博客之前经历过: wordpress github page Bitcron - 机制很不错(写完的博客自动保存到dropbox并发布,可惜搜索引擎的 ...

  7. 在Openfire上弄一个简单的推送系统

    推送系统 说是推送系统有点大,其实就是一个消息广播功能吧.作用其实也就是由服务端接收到消息然后推送到订阅的客户端. 思路 对于推送最关键的是服务端向客户端发送数据,客户端向服务端订阅自己想要的消息.这 ...

  8. iOS---iOS10适配iOS当前所有系统的远程推送

    一.iOS推送通知简介 众所周知苹果的推送通知从iOS3开始出现, 每一年都会更新一些新的用法. 譬如iOS7出现的Silent remote notifications(远程静默推送), iOS8出 ...

  9. SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=》提升)

     SignalR快速入门 ~ 仿QQ即时聊天,消息推送,单聊,群聊,多群公聊(基础=>提升,5个Demo贯彻全篇,感兴趣的玩才是真的学) 官方demo:http://www.asp.net/si ...

随机推荐

  1. 【python】二进制、八进制、十六进制表示方法(3.0以上)

    2进制是以0b开头的: 例如: 0b11 则表示十进制的3 8进制是以0o开头的: 例如: 0o11则表示十进制的9 (与2.0版本有区别) 16进制是以0x开头的: 例如: 0x11则表示十进制的1 ...

  2. VC皮肤库之duilib

    首先是个国产的开源 的,directui 界面库,开放,共享,惠众,共赢,遵循bsd协议,可以免费用于商业项目,目前支持Windows 32 .Window CE.Mobile等平台. Duilib ...

  3. Oracle数据库常用函数

    Oracle常用函数: 20.COS返回一个给定数字的余弦SQL> select cos(-3.1415927) from dual;COS(-3.1415927)--------------- ...

  4. SpringMVC源码阅读(二)

    今天分析下ViewResolver和View的实现  下面是ModelAndView的实现 package org.springframework.web.servlet; import java.u ...

  5. winfrom拷贝文件

    //File.Copy(@"C:\Users\Administrator\Pictures\bg.png", @"g:\images\bg.png", true ...

  6. uva 10496 Collecting Beepers

    一个简单的货郎担问题,用状态压缩dp可以解决: 解法: d(i,S)=min{d(j,S-{j})+dis(i,j) | j belongs to S}; 边界条件:d(i,{})=dis(0,i). ...

  7. Hibernate 缓存 关于注解方式

    要引入 import org.hibernate.annotations.Cache; 在类前面添加: @Cache(usage= CacheConcurrencyStrategy.NONSTRICT ...

  8. http://www.cnblogs.com/xwdreamer/archive/2012/02/21/2360818.html

    http://www.cnblogs.com/xwdreamer/archive/2012/02/21/2360818.html

  9. Hibernate中对象的三种状态以及Session类中saveOrUpdate方法与merge方法的区别

    首先,用一张图说明一个对象,在Hibernate中,在调用了不同方法之后对象所处的不同状态 在Hibernate中,一个对象的状态可以被分为如图所示的三种 Transient:瞬时对象,该对象在数据库 ...

  10. 性能指标--并发用户数(Concurrent Users)

    并发用户数是指:在某一时间点,与被测目标系统同时进行交互的客户端用户的数量. 并发用户数有以下几种含义: 1. 并发虚拟用户数(Concurrent Virtual Users,Users_CVU) ...