使用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

相关文章
|
存储 缓存 Oracle
Oracle JDBC 驱动程序
开始使用 Oracle JDBC 驱动程序 (Doc ID 1602866.1
3050 0
|
Linux 虚拟化 Windows
Bitnami:服务器套件的云部署工具
Bitnami是一个面向服务器维护者的云服务,直接提供适用于各种Linux发行版的免配置的服务器软件安装包。其自身定位为“服务器端的软件商店”。
5658 0
Bitnami:服务器套件的云部署工具
|
存储 安全 测试技术
快速教你如何使用postman工具进行接口测试?(配置全局token、JWT可用)
快速教你如何使用postman工具进行接口测试?(配置全局token、JWT可用)
1804 0
|
数据安全/隐私保护
使用校园账号登录WOS(Web of Science)并检索文献
使用校园账号登录WOS(Web of Science)并检索文献
2505 0
|
传感器 存储 IDE
Arduino的PID库
Arduino的PID库是一个用于实现比例-积分-微分(PID)控制算法的软件库。它能帮助开发者精确控制各种需要调节的系统,如温度、速度等,通过自动调整参数来达到或维持设定值。使用简单,适用于各种Arduino项目。
1432 3
|
机器学习/深度学习 人工智能 自然语言处理
【强化学习】强化学习的概述及应用,附带代码示例
强化学习(Reinforcement Learning, RL)是机器学习中的一种重要范式,它通过让智能体(agent)在环境中采取行动并根据所获得的奖励(reward)来学习最优的策略(policy)。简而言之,强化学习的目标是让智能体学会在特定环境下做出决策,以最大化累积奖励。这种学习方式模拟了生物体如何在环境给予的正反馈(奖励)和负反馈(惩罚)中学习行为的过程。
3683 4
|
运维 安全 前端开发
你好,生产力(番外篇1) - Linear, by the developer, for the developer
在生产力工具大类里,Project Management & Issue Tracking Tool(国内一般统称项管工具)可以说是其中历史最悠久也是最拥挤的品类。一方面项管工具是任何一家信息化管理的公司里最基本,最核心的工具,承担着安排计划,管理进度,追踪问题,串联其它各平台的任务。另一方面项管工具表面上的门槛比较低,Todo list其实也称得上是一个轻量化的项管工具。这两个因素叠加在
2870 0
|
关系型数据库 MySQL 中间件
如何设计可动态扩容缩的分库分表
如何设计可动态扩容缩的分库分表
1261 123
如何设计可动态扩容缩的分库分表

热门文章

最新文章