17:25 2013/10/18------------------ rsync linux 同步备份服务器 配置
vi /etc/rsyncd.conf 配置文件
/usr/bin/rsync --daemon 守护进程方式 启动
lsof -i:873 查看启动进程
iptables -A INPUT -p tcp --dport 873 -j ACCEPT 开启防火墙

rsync 配置文件

#pid file = /usr/local/rsync/rsyncd.pid #运行进程的ID写到哪里 原文中有的,我没有使,日志文件

#模块选项
[test] # 这里是认证的模块名,在client端需要指定
max connections = 5 #客户端最大连接数,默认0(没限制)
uid = root #指定该模块传输文件时守护进程应该具有的uid
gid = root #指定该模块传输文件时守护进程应该具有的gid
path = /var/www # 需要做备份的目录
ignore errors # 可以忽略一些无关的IO错误
read only = no #no客户端可上传文件,yes只读
write only = no #no客户端可下载文件,yes不能下载
hosts allow = * #充许任何主机连接
hosts deny = 10.5.3.77 #禁止指定的主机连接
auth users = root # 认证的用户名,如果没有这行,则表明是匿名
secrets file = /etc/rsync.pass # 指定认证口令文件位置

----

/usr/bin/rsync -vzrtopg --delete --progress root@192.168.1.107::test /ranmufei/

参考

http://www.iteye.com/topic/604436

http://blog.sina.com.cn/s/blog_5eda2dda01015fcs.html

测试通过的配置  用普通用户操作 默认服务器已经安装了 软件 centos 6.4 默认已经安装

1 服务器端的conf 配置

uid = nobody
gid = nobody
max connections = 4
read only = true
#hosts allow = 202.207.177.180
hosts allow = *
transfer logging = true
log format = %h %o %f %l %b
log file = /var/log/rsyncd.log
slp refresh = 300
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock

[web]
path = /var/www
comment = Mirror to Hk server
read only = true
list = false
auth users = freefei

[test]
path = /var/www
read only = false
auth users = freefei
secrets file = /etc/rsyncd.secrets

2 服务器端 创建密码文件

vim /etc/rsyncd.secrets

格式  为 freefei:123456

3 客户端

客户端只需要配置密码文件即可

vim /etc/rsync.pass

注意这里的密码 格式为  123456  (只有密码 没有用户名 和服务器端不同)

4  备份文件夹

备份test模块下的文件同步到 客户端 的“/ranmufei” 文件夹下

/usr/bin/rsync -vzrtopg --delete  --progress freefei@192.168.1.107::test /ranmufei --password-file=/etc/rsync.pass

5 rsync 开机启动

vi /etc/rc.local

加上

/usr/bin/rsync --daemon --config=/etc/rsyncd.conf

6 设置自动备份(定时备份 )

自动备份有两种方式 1 一种是用 系统的定时任务 定时执行 同步命令。

crontab 定时命令

-e 编辑
-r [UserName]: 删除目前的时程表
-l [UserName]: 列出目前的时程表
-v [UserName]:列出用户cron作业的状态
 
找时刻表中加入 一分钟备份一次
 
 --delete  表示服务器如果删除了改文件 备份服务器也要删除 做到真正的同步   切记该选择
 

*/1 * * * * /usr/bin/rsync -vzrtopg --delete --progress freefei@192.168.1.107::test /ranmufei --password-file=/etc/rsync.pass

每天上午9点20执行rysnc备份任务:
20 9 * * *        /usr/bin/rsync -vzrtopg --delete --progress freefei@192.168.1.107::test /ranmufei --password-file=/etc/rsync.pass

 
 

2 另外一种是吧要执行的任务写到shell中 等待执行

7 机器防火墙设置 rsync

防火墙问题处理

(1) 修改防火墙文件 vi /etc/sysconfig/iptables
删除全部 重新添加上
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT DROP [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
#ssh
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#http
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
#mysql
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
#rsync
-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

保存 重启
注意 两台服务器都要这样弄

开启:service iptables start

  关闭:service iptables stop

http://wenku.baidu.com/view/c326120f844769eae009edfc.html

http://blog.csdn.net/tsuliuchao/article/details/4742796

数据库备份

注意 wdlinux 一键安装包  要开启管理面板  切记要在防火墙里面 加上 8080端口开启

linux 同步备份 rsyncd 相关设置的更多相关文章

  1. Linux Rsync实现文件同步备份(转载)

    原文地址:Linux Rsync实现文件同步备份作者:夷北 转自:http://www.mike.org.cn/blog/index.php?load=read&id=639###pp=0 [ ...

  2. linux定时备份mysql并同步到其它服务器

    数据在任何一家公司里面都是最核心的资产,定期备份则是为了保证数据库出现问题的时候能够及时回滚到最近的备份点,将损失缩小到最小 这篇文章将会两部分来说明:1.mysql的定期备份:2.同步到其它服务器 ...

  3. linux定时备份mysql数据并同步到其他服务器

    (备份还原操作) ###导出数据库 /usr/bin/mysqldump -u root -pwd database > database20180808.sql ###导入数据库 mysql ...

  4. Linux下简单粗暴使用rsync实现文件同步备份【转】

    这篇来说说如何安全的备份,还有一点不同的是上一篇是备份服务器拉取数据,这里要讲的是主服务器如何推送数据实现备份. 一.备份服务器配置rsync文件 vim /etc/rsyncd.conf #工作中指 ...

  5. rsync从linux到linux的文件同步备份

    rsync从linux到linux的文件同步备份 一.环境 需要备份文件的服务器(服务器端):192.168.1.201 (RHEL 5) 接收备份文件的服务器(客户端):192.168.1.202 ...

  6. Linux下实现Rsync目录同步备份

    需求:对于开发机器做目录的数据备份 测试机IP:192.168.1.100   WEB目录:/bckup/ 下面我将用一台机器来备份上面测试机 /bckup下的所有数据,并实现时时同步 备份机器IP: ...

  7. Linux 之 网络相关设置

    网络相关设置 参考教程:[千峰教育] 命令: ping: 作用:通常用于检测网络设备的连通性. 格式:ping IP/域名 选项:-c,指定方式测试数据包的次数 实例:ping www.baidu.c ...

  8. python 之调用Linux shell命令及相关高级应用

    最近根据老大要求,将数据进行同步备份,结合第三方提供的工具.第三方服务其实是有python demo的,本想研究下实际的python sdk搞个demo开发的,但是发现有些组建装起来确实头大,而且本公 ...

  9. CentOS 6.5 rsync+inotify实现数据实时同步备份

    CentOS 6.5 rsync+inotify实现数据实时同步备份 rsync    remote sync 远程同步,同步是把数据从缓冲区同步到磁盘上去的.数据在内存缓存区完成之后还没有写入到磁盘 ...

随机推荐

  1. #Leet Code# Root to leaf

    语言:Python 描述:使用递归实现 def getList(self, node): if node is None: return [] if node.left is None and nod ...

  2. Winbind authentication against active directory

    Winbind authentication against active directory Description This tip will describe how to configure ...

  3. iOS: 属性列表介绍 Introduction to Property Lists

    iOS: 属性列表介绍 Introduction to Property Lists 从本质上说, 属性列表就是苹果的对象数据序列化与反序列化方式 属性列表使用几种数据类型把数据组织为键值表和值表 P ...

  4. const变量与define定义常量的区别

    一.概念性区别 const 变量就是在普通变量前边加上一个关键字const,它赋值的唯一机会就是“定义时”,此变量不能被程序修改,存储在rodata区. define定义的是常量,不是变量,所以编译器 ...

  5. HDFS 搭建记录

    1. 三台服务: 172.17.0.62(namenode) 172.17.0.68(datanode) 172.17.0.76(datanode) /etc/hosts包含的内容: 三台都包含的域名 ...

  6. JAVA面试题相关基础知识

        1.面向对象的特征有哪些方面 ①抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部分细节 ...

  7. GNOME Shell叫板Ubuntu Unity:优劣PK

    转自GNOME Shell叫板Ubuntu Unity:优劣PK GNOME Shell 对阵 Ubuntu Unity--默认桌面界面的战火一触即发.双方在台上已经对峙了很长时间,现在是时候决定谁会 ...

  8. Caocao's Bridges

    hdu4738:http://acm.hdu.edu.cn/showproblem.php?pid=4738 题意:抽象出来就是求一条边权最小的割边. 题解:直接用tarjan即可破.但是如果只注重这 ...

  9. java + spring (jython\python\script) Error:SyntaxError: no viable alternative at character '\n'

    使用Jython结合java和Python开发功能时,要是遇到如下情况: 2016-03-10 16:16:49 DEBUG [com.freedom.orion.configs.JyhtonConf ...

  10. python functools模块

    functools.partial 作用: functools.partial 通过包装手法,允许我们 "重新定义" 函数签名 用一些默认参数包装一个可调用对象,返回结果是可调用对 ...