博客
关于我
Centos6.9-rsync+sersync实现服务器资源实时同步
阅读量:263 次
发布时间:2019-03-01

本文共 1468 字,大约阅读时间需要 4 分钟。

目标服务器配置

1. 安装 rsync

在目标服务器上安装 rsync,可以通过以下命令实现:

yum -y install rsync

2. 配置 rsync 服务

为了实现文件同步功能,我们需要配置 rsync 服务器。以下是详细的配置步骤:

2.1 Созд写 rsync 配置文件

创建或修改 rsync 的配置文件 rsyncd.conf,默认路径为 /etc/rsyncd.conf。配置文件内容如下:

# 设置同步用户UID和GIDuid = rootgid = root# 禁用 chroot 模拟use chroot = no# 允许所有 IP 访问(根据实际情况调整)hosts allow = *# 设置最大连接数max connections = 3# 生成 rsync 服务器的 PID 文件pid file = /var/run/rsyncd.pid# 设置锁文件路径lock file = /var/run/rsync.lock# 添加新的同步模块(如:tp5shop)[tp5shop]# 需要同步的本地目录(注意:路径需为绝对路径)path = /usr/local/nginx/html/tp5shop# 模块备注信息comment = tp5shop# 是否只读(默认为只读)read only = false

2.2 启动 rsync 服务

将 rsync 以守护进程形式启动:

/usr/bin/rsync --daemon

3. 源服务器配置

3.1 安装 sersync

源服务器需要安装并配置 sersync,实现文件监控与同步。安装步骤如下:

# 下载 sersync 二进制包wget https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/sersync/sersync2.5.4_64bit_binary_stable_final.tar.gz# 解压并移动到指定目录mv sersync2.5.4_64bit_binary_stable_final.tar.gz /usr/local/shellcd /usr/local/shelltar xf sersync2.5.4_64bit_binary_stable_final.tar.gzmv GNU-Linux-x86 sersync

3.2 配置 sersync 服务

根据实际需求修改 confxml.xml 配置文件:

vim confxml.xml

推荐修改内容如下:

3.3 启动 sersync 服务

启动 sersync 服务并设置为后台进程:

/usr/local/sersync/sersync2 -n 10 -d -o /usr/local/sersync/confxml.xml

3.4 配置文件过滤规则

confxml.xml 中添加需要的过滤规则(如以下示例):

4. 操作验证

验证配置是否正确,可以通过以下命令查看进程状态:

ps aux | grep sersync

5. 高级配置(如需)

根据实际需求,进一步优化配置:

  • 调整 max connections(最大连接数)
  • 修改 hosts allow(允许访问的 IP 集合)
  • 配置访问日志等

以上配置均可根据实际网络环境和需求进行调整。

转载地址:http://jbhx.baihongyu.com/

你可能感兴趣的文章
npm install的--save和--save-dev使用说明
查看>>
npm node pm2相关问题
查看>>
npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
查看>>
npm run build报Cannot find module错误的解决方法
查看>>
npm run build部署到云服务器中的Nginx(图文配置)
查看>>
npm run dev 和npm dev、npm run start和npm start、npm run serve和npm serve等的区别
查看>>
npm run dev 报错PS ‘vite‘ 不是内部或外部命令,也不是可运行的程序或批处理文件。
查看>>
npm scripts 使用指南
查看>>
npm should be run outside of the node repl, in your normal shell
查看>>
npm start运行了什么
查看>>
npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
查看>>
npm 下载依赖慢的解决方案(亲测有效)
查看>>
npm 安装依赖过程中报错:Error: Can‘t find Python executable “python“, you can set the PYTHON env variable
查看>>
npm.taobao.org 淘宝 npm 镜像证书过期?这样解决!
查看>>
npm—小记
查看>>
npm上传自己的项目
查看>>
npm介绍以及常用命令
查看>>
NPM使用前设置和升级
查看>>
npm入门,这篇就够了
查看>>
npm切换到淘宝源
查看>>