使用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  tongbu_user@10.0.1.254::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

]
 本文转自 wjw555 51CTO博客,原文链接:http://blog.51cto.com/wujianwei/1962471

相关文章
|
安全 Linux 数据安全/隐私保护
谁再说不会搭建vsftpd,就把这个脚本给他扔过去!——CentOS7下一键脚本搭建虚拟用户模式的vsftpd服务器
谁再说不会搭建vsftpd,就把这个脚本给他扔过去!——CentOS7下一键脚本搭建虚拟用户模式的vsftpd服务器
354 0
谁再说不会搭建vsftpd,就把这个脚本给他扔过去!——CentOS7下一键脚本搭建虚拟用户模式的vsftpd服务器
|
网络安全 Windows Shell
Ansible 管理windwos服务器(一)
不废话了,开始吧 Ansible管理Windwos需要在windows上执行Powershell脚本,并且Powershell脚本还有版本要求有必要条件:必要条件: (1) 必须开启以及配置Powershellhttps://github.
1568 0
|
存储 网络协议 开发工具
|
数据安全/隐私保护 网络协议 数据库
|
Web App开发 开发工具