使用xinetd來管理rsync軟件以及部署操作

一環境

源服務器:

10.0.1.232

同步到目標的服務器

10.0.1.254

二具體操作:

2.1目標服務器上操作:

1.關閉selinux,防火牆開啓873端口

2.在目標服務器安裝Rsync服務端

創建啓動用戶

useradd rsync -s /sbin/nologin -M

安裝Rsync服務端軟件

[root@localhost pic]# yuminstall rsync xinetd –y

[root@localhost pic]#  yum install rsync xinetd –y #安裝

vi /etc/xinetd.d/rsync #編輯配置文件,設置開機啓動rsync

disable = no #修改爲no

:wq! #保存退出

/etc/init.d/xinetd start #啓動(CentOS中是以xinetd來管理Rsync服務的)

 

[root@localhost pic]# cat/etc/xinetd.d/rsync

# default: off

# description: The rsyncserver is a good addition to an ftp server, as it \

#       allows crc checksumming etc.

service rsync

{

         disable     = no

         flags                   =IPv6

         socket_type     =stream

         wait            = no

         user            = root

         server          =/usr/bin/rsync

         server_args     =--daemon

         log_on_failure  +=USERID

}

創建rsyncd.conf配置文件

[root@localhost pic]# cat /etc/rsyncd.conf

#rsync_config_______________start

#created by wujianwnei

#QQ 604480554

##rsyncd.conf start##

uid = root

gid = root

port=873

use chroot = no

read only = no

list = no

max connections = 200

timeout = 300

auth users = tongbu_user

hosts allow = 10.0.1.232

#hosts deny =

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsync.lock

log file = /var/log/rsyncd.log

secrets file = /etc/rsync.pass

motd file = /etc/rsyncd.Motd

 

[mhttongbu1]

path = /data/matula/pic/cover/

comment = mhttongbu1

 

[mhttongbu2]

path = /data1/pic/cov/

comment = mhttongbu2

 

在目標服務器上開啓兩個同步模塊,指定同步源數據到目標服務器上的兩個不同的目錄

 創建用戶認證文件

[root@localhost pic]# cat /etc/rsync.pass

tongbu_user:zy@test01@user

設置文件權限

chmod 600 /etc/rsyncd.conf 

chmod 600 /etc/rsync.pass 

啓動rsync

/etc/init.d/xinetd start  #啓動

service xinetd stop   #停止

service xinetd restart  #重新啓動

 

2.2在源服務器上操作:

在服務器10.0.1.232上操作

 

2.2.1關閉SELINUX

2.2.2開啓防火牆tcp 873端口

vi /etc/sysconfig/iptables  #編輯防火牆配置文件

-A INPUT -m state --state NEW -m tcp -p tcp --dport873 -j ACCEPT

:wq! #保存退出

/etc/init.d/iptables restart #最後重啓防火牆使配置生效

2.2.3安裝Rsync客戶端

whereis rsync   #查看系統是否已安裝rsync,出現下面的提示,說明已經安裝

rsync: /usr/bin/rsync/usr/share/man/man1/rsync.1.gz

yum install  xinetd  #只安裝xinetd即可,CentOS中是以xinetd來管理rsync服務的

yum install rsync xinetd #如果默認沒有rsync,運行此命令進行安裝rsyncxinetd

vi /etc/xinetd.d/rsync #編輯配置文件,設置開機啓動rsync

disable = no #修改爲no

/etc/init.d/xinetd start #啓動(CentOS中是以xinetd來管理rsync服務的)

 

2.2.4創建認證密碼文件(源服務器)

[root@mantu_hw data]# cat /etc/passwd.txt

zy@test01@user

 

[root@mantu_hw data]#chmod 600/etc/passwd.txt 

 

2.3測試源服務器和目標服務器之間的同步

在源服務器上操作:

[root@mantu_hw test02]# ll /tmp/test01/

總用量 32

drwxr-xr-x 2 root root 4096 2  13 15:08 2

drwxr-xr-x 2 root root 4096 2  13 15:43 234

drwxr-xr-x 2 root root 4096 2  13 15:08 3

drwxr-xr-x 2 root root 4096 2  13 15:15 45

drwxr-xr-x 2 root root 4096 2  13 15:43 4567

-rw-r--r-- 1 root root    4 2  13 15:42 test03

-rw-r--r-- 1 root root    5 2  13 16:05 test05

-rw-r--r-- 1 root root    3 2  13 15:08 txt01

 

[root@mantu_hw test02]# rsync -avH --port=873--progress  /tmp/test01  [email protected]::mhttongbu1--password-file=/etc/passwd.txt

ip爲目標服務器的ip

sending incremental file list

test01/

test01/test03

           4100%    0.00kB/s    0:00:00 (xfer#1, to-check=7/9)

test01/test05

           5100%    0.41kB/s    0:00:00 (xfer#2, to-check=6/9)

test01/txt01

           3100%    0.17kB/s    0:00:00 (xfer#3, to-check=5/9)

test01/2/

test01/234/

test01/3/

test01/45/

test01/4567/

 

sent 350 bytes received 89 bytes  67.54 bytes/sec

total size is 12 speedup is 0.03

 

在目標服務器上查看:

test01目錄以及下面的內容全部同步到目標服務器的/data/matula/pic/cover/

 

[root@localhost cover]# ll/data/matula/pic/cover/test01/

總用量 32

drwxr-xr-x 2 root root 4096 2  13 15:08 2

drwxr-xr-x 2 root root 4096 2  13 15:43 234

drwxr-xr-x 2 root root 4096 2  13 15:08 3

drwxr-xr-x 2 root root 4096 2  13 15:15 45

drwxr-xr-x 2 root root 4096 2  13 15:43 4567

-rw-r--r-- 1 root root    4 2  13 15:42 test03

-rw-r--r-- 1 root root    5 2  13 16:05 test05

-rw-r--r-- 1 root root    3 2  13 15:08 txt


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章