目录名称 | 目录大小(推荐) | 备注 |
/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 &