奥德赛sync项目案例,rsync从Linux到Linux的文书同步

作者: 计算机网络  发布:2019-11-08
名称
角色
IP地址
Rsync-server
(RHEL5)
服务器
Eth0:192.168.1.1
Rsync-client
(RHEL5)
客户端
Eth0:192.168.1.2

节点名称 用场 IP地址 网址发表路线

服务器端

Web1 服务节点1 192.168.1.11 /web1/wwwroot

网卡配置

Web2 服务节点2 192.168.1.22 /web2/wwwroot

[root@localhost ~]# ifconfig eth0

Server 内容发布节点 192.168.1.99 /web/wwwroot

eth0      Link encap:Ethernet HWaddr 00:0C:29:1A:AB:E4 

Setup-1、在2个劳务节点上布置rsync

          inet addr:192.168.1.1 Bcast:192.168.1.255 Mask:255.255.255.0

1-1、 在web1上的配备

安装rsync

[root@web1 ~]# ifconfig eth0

[root@localhost ~]# yum install rsync

eth0      Link encap:Ethernet  HWaddr 00:0C:29:4E:07:88

创制rsync.conf配置文件(暗中同意不设有卡塔尔

inet addr:192.168.1.11  Bcast:192.168.1.255  Mask:255.255.255.0

[root@localhost ~]# vim /etc/rsyncd.conf

inet6 addr: fe80::20c:29ff:fe4e:788/64 Scope:Link

uid = nobody

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

gid = nobody

RX packets:571 errors:0 dropped:0 overruns:0 frame:0

use chroot = no

TX packets:172 errors:0 dropped:0 overruns:0 carrier:0

max connections = 4

collisions:0 txqueuelen:1000

pid file = /var/run/rsyncd.pid

RX bytes:137838 (134.6 KiB)  TX bytes:26054 (25.4 KiB)

lock file = /var/run/rsync.lock

Interrupt:59 Base address:0x2024

log file = /var/log/rsyncd.log

[root@web1 ~]# cat /etc/hosts

#address = 192.168.1.1  #可写,可不写,服务端ip地址

# Do not remove the following line, or various programs

[data] #备份模块

# that require network functionality will fail.

path = /opt/data

192.168.1.11 web1.benet.com web1

ignore errors #忽视错误

192.168.1.22 web2.benet.com web2

read only = yes

192.168.1.99 web.benet.com web

host allow = 192.168.1.2   #允许同步的客商端ip地址,也得以允许持有主机

[root@web1 ~]# cat /etc/sysconfig/network

auth users = benet #一起数据服务器端用的顾客名

NETWORKING=yes

secrets file = /etc/rsyncd.scrt   #服务器端用的密码所放地点

NETWORKING_IPV6=no

始建密码文件

HOSTNAME=web1.benet.com

[root@localhost ~]# echo "benet:123" > /etc/rsyncd.scrt

[root@web1 ~]# vi /etc/rsyncd.conf

[root@localhost ~]# cat /etc/rsyncd.scrt

uid = nobody

benet:123

gid = nobody

改造权限

use chroot = yes

[root@localhost ~]# chmod 600 /etc/rsyncd.scrt

port 873

启动rsync服务

log file = /var/log/rsyncd.log

[root@localhost ~]# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf

pid file = /var/run/rsyncd.pid

[root@localhost ~]# netstat -anpl |grep 873

hosts allow = 192.168.1.0/24

tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      11484/rsync        

[web1]

开机自动运营服务

path = /web1/wwwroot/

[root@localhost ~]# echo "/usr/bin/rsync --daemon" >> /etc/rc.local

comment = web1 file

甘休服务

read only = no

[root@localhost ~]# kill -9 `cat /var/run/rsyncd.pid`

uid = root

去opt下创办目录data

gid = root

[root@localhost ~]# cd opt

dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.Z

[root@localhost opt]# mkdir data

auth users = webuser

[root@localhost data]# echo "1111111111111111111" > 123

secrets file = /etc/web.pass

图片 1

[root@web1 ~]# vi /etc/web.pass

webuser:pwd123

[root@web1 ~]# chmod 600 /etc/web.pass

[root@web1 ~]# rsync --daemon

[root@web1 ~]# netstat -anpt |grep rsync

tcp        0      0 :::873                      :::*                        LISTEN      4383/rsync

[root@web1 ~]# echo "rsync –daemon &" >> /etc/rc.local

[root@web1 ~]# mkdir -p /web1/wwwroot

1-2、 在web2上的布局

[root@web2 ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:FE:39:09

inet addr:192.168.1.22  Bcast:192.168.1.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fefe:3909/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:322 errors:0 dropped:0 overruns:0 frame:0

TX packets:135 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:84643 (82.6 KiB)  TX bytes:21765 (21.2 KiB)

Interrupt:59 Base address:0x2024

[root@web2 ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

192.168.1.11 web1.benet.com web1

192.168.1.22 web2.benet.com web2

192.168.1.99 web.benet.com web

[root@web2 ~]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=web2.benet.com

[root@web2 ~]# vi /etc/rsyncd.conf

uid = nobody

gid = nobody

use chroot = yes

port 873

log file = /var/log/rsyncd.log

pid file = /var/run/rsyncd.pid

hosts allow = 192.168.1.0/24

[web2]

path = /web2/wwwroot

comment = web2 file

read only = no

uid = root

gid = root

dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.Z

auth users = webuser

secrets file = /etc/web.pass

[root@web2 ~]# vi /etc/web.pass

webuser:pwd123

[root@web2 ~]# chmod 600 /etc/web.pass

[root@web2 ~]# mkdir -p /web2/wwwroot

[root@web2 ~]# rsync --daemon

[root@web2 ~]# netstat -antp |grep rsync

tcp        0      0 0.0.0.0:873                0.0.0.0:*                  LISTEN      4278/rsync

tcp        0      0 :::873                      :::*                        LISTEN      4278/rsync

[root@web2 ~]# echo "rsync --daemon &" >> /etc/rc.local

Setup-2、在剧情揭橥节点上的配备

[root@web ~]# ifconfig eth0

eth0      Link encap:Ethernet  HWaddr 00:0C:29:6C:9D:FF

inet addr:192.168.1.99  Bcast:192.168.1.255  Mask:255.255.255.0

inet6 addr: fe80::20c:29ff:fe6c:9dff/64 Scope:Link

UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

RX packets:184 errors:0 dropped:0 overruns:0 frame:0

TX packets:163 errors:0 dropped:0 overruns:0 carrier:0

collisions:0 txqueuelen:1000

RX bytes:31797 (31.0 KiB)  TX bytes:23579 (23.0 KiB)

Interrupt:59 Base address:0x2024

[root@web ~]# cat /etc/sysconfig/network

NETWORKING=yes

NETWORKING_IPV6=no

HOSTNAME=web.benet.com

[root@web ~]# cat /etc/hosts

# Do not remove the following line, or various programs

# that require network functionality will fail.

192.168.1.11 web1.benet.com web1

192.168.1.22 web2.benet.com web2

192.168.1.99 web.benet.com web

2-1、安装inotify-tools工具

[root@web ~]# tar zxf inotify-tools-3.13.tar.gz

[root@web ~]# cd inotify-tools-3.13

[root@web inotify-tools-3.13]# ./configure ; make ; make install

[root@web ~]# ls /usr/local/bin/

inotifywait  inotifywatch

[root@web ~]# mkdir -p /web/wwwroot

[root@web ~]# vi /etc/server.pass

pwd123

[root@web ~]# chmod 600 /etc/server.pass

2-2、

[root@web ~]# vi /opt/inotify.sh

#!/bin/bash

#

host1=web1

host2=web2

src="/web/wwwroot/"

dst1=web1

dst2=web2

user=webuser

/usr/local/bin/inotifywait -mrq --timefmt '%d/%m/%y %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib,move $src |while read files

do

/usr/bin/rsync -vzrtopg --delete --password-file=/etc/server.pass $src $user@$host1::$dst1

/usr/bin/rsync -vzrtopg --delete --password-file=/etc/server.pass $src $user@$host2::$dst2

echo "${files} was rsynced" >> /tmp/rsync.log 2>&1

done


一块多个文件夹(被同步端卡塔 尔(英语:State of Qatar)

uid = nobody

gid = nobody

use chroot = yes

port 873

log file = /var/log/rsyncd.log

pid file = /var/run/rsyncd.pid

#必须改正

hosts allow =10.132.14.153/32

[web1]

path = /eduvideo/mount1

comment = web1 file

read only = no

uid = root

gid = root

dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.Z

auth users = webuser

secrets file = /etc/web.pass

[web2]

path = /eduvideo/mount2

comment = web2 file

read only = no

uid = root

gid = root

dont compress = *.gz *.bz2 *.tgz *.zip *.rar *.Z

auth users = webuser

secrets file = /etc/web.pass

inotify脚本,七个目录分开写就能够

本文由金沙澳门官网送注册58发布于计算机网络,转载请注明出处:奥德赛sync项目案例,rsync从Linux到Linux的文书同步

关键词: