更新 'linux基础/lsyncd使用.md'
This commit is contained in:
parent
a81384ec17
commit
72a099a3c9
1 changed files with 131 additions and 0 deletions
|
@ -0,0 +1,131 @@
|
|||
# lsyncd服务器端
|
||||
## 安装lsyncd
|
||||
```bash
|
||||
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
|
||||
yum -y install lsyncd
|
||||
```
|
||||
## 配置服务器端
|
||||
```bash
|
||||
cat > /etc/lsyncd.conf << EOF
|
||||
----
|
||||
-- User configuration file for lsyncd.
|
||||
--
|
||||
-- Simple example for default rsync, but executing moves through on the target.
|
||||
--
|
||||
-- For more examples, see /usr/share/doc/lsyncd*/examples/
|
||||
--
|
||||
-- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"}
|
||||
settings {
|
||||
logfile = "/var/log/lsyncd/lsyncd.log",
|
||||
statusFile = "/var/log/lsyncd/lsyncd.status"
|
||||
}
|
||||
sync {
|
||||
default.rsyncssh, -- 使用ssh同步文件,需要与客户端免密,客户端不需要特殊配置
|
||||
source = "/opt/imis",
|
||||
host = "10.217.34.66",
|
||||
targetdir = "/data/imis",
|
||||
delete = false,
|
||||
delay = 0,
|
||||
rsync = {
|
||||
binary = "/usr/bin/rsync",
|
||||
archive = true,
|
||||
compress = true,
|
||||
verbose = true,
|
||||
owner = true,
|
||||
perms = true,
|
||||
_extra = {"--bwlimit=2000"},
|
||||
},
|
||||
ssh = {
|
||||
port = 22
|
||||
}
|
||||
}
|
||||
sync {
|
||||
default.rsync, -- 使用rsync同步文件,客户端需要安装rsyncd,且添加配置文件,密码文件(权限600),服务器端需要密码文件(权限600)
|
||||
source = "/opt/imis",
|
||||
target = "rsync@10.217.35.166::imis",
|
||||
delete = false,
|
||||
delay = 0,
|
||||
rsync = {
|
||||
binary = "/usr/bin/rsync",
|
||||
password_file = "/etc/rsync-pass",
|
||||
archive = true,
|
||||
compress = true,
|
||||
verbose = true,
|
||||
owner = true,
|
||||
perms = true,
|
||||
_extra = {"--bwlimit=2000"},
|
||||
},
|
||||
}
|
||||
EOF
|
||||
```
|
||||
```bash
|
||||
cat > /etc/rsync-pass << EOF
|
||||
dasfasfasf
|
||||
EOF
|
||||
chmod 600 /etc/rsync-pass
|
||||
```
|
||||
## 启动
|
||||
```bash
|
||||
systemctl restart lsyncd
|
||||
systemctl enable lsyncd
|
||||
```
|
||||
# (可选)rsync客户端
|
||||
只有使用rsync的客户端才需要配置
|
||||
## 安装rsync
|
||||
```bash
|
||||
yum -y install rsyncd
|
||||
```
|
||||
## 配置
|
||||
```bash
|
||||
cat > /etc/rsyncd.conf << EOF
|
||||
# /etc/rsyncd: configuration file for rsync daemon mode
|
||||
|
||||
# See rsyncd.conf man page for more options.
|
||||
|
||||
# configuration example:
|
||||
|
||||
# uid = nobody
|
||||
# gid = nobody
|
||||
# use chroot = yes
|
||||
# max connections = 4
|
||||
# pid file = /var/run/rsyncd.pid
|
||||
# exclude = lost+found/
|
||||
# transfer logging = yes
|
||||
# timeout = 900
|
||||
# ignore nonreadable = yes
|
||||
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2
|
||||
|
||||
# [ftp]
|
||||
# path = /home/ftp
|
||||
# comment = ftp export area
|
||||
uid = root
|
||||
gid = root
|
||||
use chroot = no
|
||||
max connections = 100
|
||||
timeout = 600
|
||||
pid file = /var/run/rsyncd.pid
|
||||
locak file = /var/run/rsyncd.lock
|
||||
log file = /var/log/rsyncd.log
|
||||
|
||||
[imis]
|
||||
path = /data/imis/
|
||||
read only = no
|
||||
list = yes
|
||||
ignore errors
|
||||
hosts allow = 10.217.34.12
|
||||
hosts deny = *
|
||||
auth users = rsync
|
||||
secrets file = /etc/rsyncd.pass
|
||||
EOF
|
||||
```
|
||||
```bash
|
||||
cat > /etc/rsyncd.pass << EOF
|
||||
rsync:dasfasfasf
|
||||
EOF
|
||||
chmod 600 /etc/rsyncd.pass
|
||||
```
|
||||
## 启动
|
||||
```bash
|
||||
systemctl restart rsyncd
|
||||
systemctl enable rsyncd
|
||||
```
|
Loading…
Add table
Add a link
Reference in a new issue