Samba共享服务部署+inotify&rsync文件同步

目录名称

目录大小(推荐)

备注

/data/sdv1/input

1TB 

数据目录(A)

/data/sdv1/output

1TB 

数据目录(B)

一、安装配置samba

1.安装Samba

yum install samba -y

2.配置Samba

mv /etc/samba/smb.conf /etc/samba/smb.conf.backup
# cat << EOF >> /etc/samba/smb.conf
[global]
#Audit settings
        full_audit:prefix = %u|%I|s
        full_audit:failure = connect
        full_audit:sucess = connect disconnect opendir mkdir rmdir closedir open close fchmod chown fchown chdir
        full_audit:facility = local5
        full_audit:priority = notice
        workgroup = MYGROUP
        server string = Samba Server Version %v
        log file = /var/log/samba/%m.log
        log level = 3
        max log size = 50
        security = user
        passdb backend = tdbsam
        load printers = no
        cups options = bsd
        printcap name = /dev/null
[homes]
        comment = Home Directories
        browseable = no
        writable = no
[printers]
        comment = All Printers
        path = /var/spool/samba
        browseable = no
        guest ok = yes
        writable = no
        printable = yes
[共享文件_A访问]
comment = 共享文件
path = /data/sdv1/input
vfs object=full_audit
browseable = yes
writable = yes
veto files = /*.exe/*.com/*.dll/*.bat/*.sh/*.zip/*.tar/*.gz/*.rar/*.cab/*.uue/*.arj/*.bz2/*.iso/*.7z/*.3gpp/*.ac3/*.asf/*.au/*.dot/*.dtd/*.dwg/*.dxf/*.js/*.json/*.mp2/*.mp3/*.mp4/*.mpeg/*.mpg/*.mpp/*.ogg/*.pot/*.pps/*.rtf/*.svf/*.tif/*.tiff/*.wdb/*.xlt/*.xlw/
valid users = input,@input
write list =  +input
create mode = 0600
force create mode = 0600
directory mode = 0755
map archive = no
force directory mode = 0755
guest ok = no
hosts allow=172.27.28.,172.27.15.
[共享文件_B访问]
comment = 共享文件
path = /data/sdv1/output
browseable = yes
guest ok = yes
hosts allow=172.27.25.0/24
EOF

3.启动Samba

systemctl enable smb.service
systemctl start smb.service

二、安装配置Rsync&Inotify

1.安装Rsync&Inotify

yum install rsync inotify-tools -y

2.同步脚本

同步脚本放在/data/sdv1/input目录

#!/bin/bash
source /etc/profile
cd ${src}                            
/usr/local/bin/inotifywait -mrq --format  '%Xe %w%f' -e modify,create,delete,attrib,close_write,move ./ | while read file
do
        echo "-------------------------------$(date)------------------------------------"
        echo $file
        then
                echo 'CREATE or MODIFY or CLOSE_WRITE or MOVED_TO'
                /bin/rsync -avzrtopg --delete --ignore-errors  $(dirname ${INO_FILE}) ${des}
        fi
        if [[ $INO_EVENT =~ 'DELETE' ]] || [[ $INO_EVENT =~ 'MOVED_FROM' ]]||[[ $INO_EVENT =~ 'ATTRIB' ]]
        then
                echo 'DELETE or MOVED_FROM'
                /bin/rsync -avzR --delete --ignore-errors  $(dirname ${INO_FILE}) ${des}
        fi
done

3.启动同步脚本

cd /data/sdv1/input
nohup ./inotify.sh  >> /data/sdv1/inotify.out &

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

曹宇飞丶

您的鼓励是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值