centos7安装配置rsync以及遇到问题

简介: 安装服务端安装软件:yum -y install rsync创建需同步的目录:mkdir -p /data编辑配置文件:vim /etc/rsyncd.confmotd file = /etc/rsyncd.

安装

服务端

安装软件:

yum  -y  install  rsync

创建需同步的目录:

mkdir  -p  /data

编辑配置文件:vim /etc/rsyncd.conf

motd file = /etc/rsyncd.motd
transfer logging = yes
log file = /var/log/rsyncd.log #日志存放路径
port = 873  #端口号
address = 192.168.0.37  #IP地址
uid = root #使用的用户名
gid = root  #使用的密码
use chroot = no
read only = no
max connections = 10
[common]
comment = rsync lee
path = /data
ignore errors
auth users = simops
secrets file = /etc/rsyncd.secrets
hosts allow = 192.168.0.0/255.255.255.0 #允许访问的地址段
hosts deny = *
list = false

UID = 0
GID = 0

创建用户密码:

echo  "simops:123456"  >  /etc/rsyncd.secrets
chmod  600  /etc/rsyncd.secrets

创建提示信息文件:

echo  "rsync simops"  >  /etc/rsyncd.motd

配置防火墙规则和关闭SElinux:

iptables  -I  INPUT  -p  tcp  --dport  873  -j  ACCEPT
setenforce 0 #临时关闭SElinux

启动服务:

rsync  --daemon
echo  "rsync  --daemon"  >>  /etc/rc.local

二、客户端(192.168.0.17):

安装软件:

yum  -y  install  rsync

创建需同步的目录:

mkdir  -p  /data

创建密码文件(免输入密码):

echo  "123456"  >  /root/passwd
chmod  600  /root/passwd

拉取:

rsync  -avz  --password-file=/root/passwd  simops@192.168.0.37::common  /data/

推送

rsync  -avz  --password-file=/root/passwd  /data  simops@192.168.0.37::common

遇到问题

1、执行推送命令之后报错

rsync  -avz  --password-file=/root/passwd  lee@192.168.0.37::common  /home/lee/rsync/
rsync  lee

@ERROR: invalid uid root #使用的用户名
rsync error: error starting client-server protocol (code 5) at main.c(1648) [Receiver=3.1.2]

解决方案在rsyncd.conf文件中添加下面两行即可解决问题

UID = 0 
GID = 0 

2、服务器端同步目录没有权限

rsync  -avz  --password-file=/root/passwd  simops@192.168.0.37::common  /home/lee/rsync/
rsync  lee

@ERROR: chdir failed
rsync error: error starting client-server protocol (code 5) at main.c(1648) [Receiver=3.1.2]

解决方案:服务器端同步目录没有权限,cwrsync默认用户是Svcwrsync。为同步目录添加用户Svcwrsync权限

3、没有关闭selinux

rsync  -avz  --password-file=/root/passwd simops@192.168.0.37::common  /data/
rsync  lee

receiving incremental file list
rsync: opendir "." (in common) failed: Permission denied (13)

sent 20 bytes  received 108 bytes  256.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1650) [generator=3.1.2]

这个问题看似已经同步可是去查看的时候没有同步过来
细细的检查了一下是selinux问题,关闭之后就可以了

目录
相关文章
|
4月前
|
应用服务中间件 Linux 网络安全
Centos 8.0中Nginx配置文件和https正书添加配置
这是一份Nginx配置文件,包含HTTP与HTTPS服务设置。主要功能如下:1) 将HTTP(80端口)请求重定向至HTTPS(443端口),增强安全性;2) 配置SSL证书,支持TLSv1.1至TLSv1.3协议;3) 使用uWSGI与后端应用通信(如Django);4) 静态文件托管路径设为`/root/code/static/`;5) 定制错误页面(404、50x)。适用于Web应用部署场景。
567 87
|
2月前
|
存储 Linux Apache
在CentOS上配置SVN至Web目录的自动同步
通过上述配置,每次当SVN仓库中提交新的更改时,`post-commit`钩子将被触发,SVN仓库的内容会自动同步到指定的Web目录,从而实现代码的连续部署。
110 16
|
2月前
|
NoSQL 安全 Linux
设置Redis在CentOS7上的自启动配置
这些步骤总结了在CentOS 7系统上设置Redis服务自启动的过程。这些命令提供了一个直接且明了的方式,确保Redis作为关键组件在系统启动时能自动运行,保障了依赖于Redis服务的应用的稳定性和可用性。
307 9
|
4月前
|
Linux
Centos6配置阿里云yum源报错
在CentOS 6配置阿里云Yum源时,可能出现EPEL仓库访问报错(404 Not Found)。解决方法:编辑`/etc/yum.repos.d/epel.repo`文件,将`enabled`和`gpgcheck`参数设为0 ``` 此设置可解决仓库无法访问的问题。
1147 29
|
4月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu中防火墙配置命令集汇
有了这些,你就能遨游在 CentOS 和 Ubuntu 的海洋中,频繁地改变你的防火墙设置,快速地应对各种安全威胁,同时也能保证你的系统可以正常工作。出发吧,勇敢的编程者,随着这些命令集的涌动,扬帆起航,走向安全的网络世界!
137 5
|
3月前
|
XML Java 应用服务中间件
在centos7.x上安装配置tomcat
本指南介绍了在Linux系统中部署Tomcat服务器的完整流程,包括关闭防火墙与SELinux、安装JDK、下载及解压Tomcat、启动和关闭Tomcat服务,以及配置Tomcat管理功能。同时,详细描述了如何导入项目到Tomcat的webapps目录、修改配置文件,并测试项目访问。通过这些步骤,您可以成功搭建并运行一个基于Tomcat的Web应用环境。
|
5月前
|
关系型数据库 MySQL Linux
CentOS 7系统下详细安装MySQL 5.7的步骤:包括密码配置、字符集配置、远程连接配置
以上就是在CentOS 7系统下安装MySQL 5.7的详细步骤。希望这个指南能帮助你顺利完成安装。
1302 26
|
5月前
|
安全 Linux 网络安全
在Linux(CentOS和AWS)上安装更新的git2的方法并配置github-ssh
经过以上这些步骤,你现在就能在GitHub上顺利往返,如同海洋中的航海者自由驰骋。欢迎你加入码农的世界,享受这编程的乐趣吧!
187 10
|
11月前
|
Linux 网络安全 Apache
CentOS 7.2配置Apache服务httpd(上)
CentOS 7.2配置Apache服务httpd(上)
672 1