当前位置:网站首页>Shell script topic (07): file from cfs to bos
Shell script topic (07): file from cfs to bos
2022-08-01 18:53:00 【51CTO】
一、背景
Production produces thousands of audio files every day,There are several sizesG.这些文件存放在cfs内,由于cfsThe usage fee is higher,容量较小,Periodic manual transfers to larger spaces are required for less costbos内.This procedure is to change the manual operation to the automatic way.Involves log output、文件比对、文件复制、文件删除、监控告警等.
二、名词解释
cfs:文件储存CFSare file and protocol storage,It can be understood as a higher-level object storageBOS,文件储存CFSCan't do calculations,Just gateway protocol storage,Reading and writing of pictures and documents、and higher level of security.
bos:对象储存BOSSimilar to Baidu Cloud Disk,But it's enterprise level,对象储存BOS提供一个简单的 Web 服务接口,Can be used to store and extract any amount of data.
cfsShared use by multiple servers,Use cost ratiobos高很多.
三、Program working logic
Most of the audio files generated each day are stored in date-named directories,This directory also has one level of subdirectoriesxxdata,A small number of recording files are stored in this subdirectory.首先将n天前的cfsDate directory copied tobos,Then compare whether they are consistent,Alignment containsmd5和diffand file count comparison,If they are consistent, delete the originalcfsRecording file directory,Exit if there is an inconsistency,Finally, a successful notification or a failed alarm is sent through WeChat.
四、日志说明
Every step of the program has a detailed log record,Including the existence of the source file directory and the target directory、Which files were copied、删除了哪些文件、md5Generation and alignment、Which operations failed etc.The normal operation of the program or the failure of the operation can be viewed through the log location.
五、各模块介绍
本程序共有9个模块,下面一一介绍
1.日志模块logs_bak
本程序共有4个日志,分别是all:Record all actions during the execution of this program;alter:Only the error content of each step is recorded,The log is empty if successful;cron:Record the execution of scheduled tasks every day;md5:记录md5Generation and alignment.
除了cron日志外,The other three logs will be backed up by date cutover when the program is running.
2.Directory inspection modulefile_check
Check the source file directorySOURCE_PATHand backup directoryDEST_PATH是否存在,因为有可能出现cfs或者bosMount failed problem.Continue if all paths exist, otherwise report an error and exit.
运行日志截图:
3.生成源文件md5value modulemd5_a
Get a list of audio files in the first level of the date directory and generate themmd5文件md5_a.txt,The file is being copied tobos后进行md5will be used for comparison.Continue if the file is generated normally,Otherwise, write to the alarm log and exit.
运行日志截图:
4.生成源文件md5value modulemd5_b
Get the list of recording files in the second level of the date directory and generate themmd5文件md5_b.txt,The file is being copied tobos后进行md5will be used for comparison.Continue if the file is generated normally,Otherwise, write to the alarm log and exit.
运行日志截图:
5.File copy modulefile_cp
通过cpThe command will record the file bycfs复制到bos,A detailed log is recorded during the replication process.Continue if the copy is successful,Otherwise, write to the alarm log and exit.
运行日志截图:
6.md5比较模块diff_md5_a
在bosThe first level target directory to run’md5sum -c md5_a.txt’Make the recording file of the first layermd5比对,If the comparison is normal, continue,Otherwise, write to the alarm log and exit.
运行日志截图:
7.md5比较模块diff_md5_b
在bosrun from the second level target directory’md5sum -c md5_b.txt’Make the recording file of the second layermd5比对,If the comparison is normal, continue,Otherwise, write to the alarm log and exit.
运行日志截图:
8.Source file remove moduleorg_file_rm
The first layer and the second layer will be performed before the automatic deletion of the source recording filediffAlignment and alignment of the number of source and target files,Continue if all three conditions are met,If one is not satisfied, write the alarm log and exit.
运行日志截图:
9.Alarm or notification module
通过spugThe platform custom script issues an alert or notification message
If the alarm log is empty, a notification message is sent’the files ${DATE} copy sucessed’,If it is not empty, the alarm content will be issued.
A screenshot of the alert or notification WeChat:
spugSee the platform for details: 自动化运维平台Spug测试
六、运行方式
This program runs in a timed task mode,每天凌晨1点开始.
运行日志截图:
更多shell文章详见: shell脚本专题
边栏推荐
- 【LeetCode】Day109-the longest palindrome string
- 【综述专栏】IJCAI 2022 | 图结构学习最新综述:研究进展与未来展望
- Keras深度学习实战——交通标志识别
- ACID Characteristics and Implementation Methods of MySQL Relational Database Transactions
- Leetcode71. Simplified Paths
- ExcelPatternTool: Excel表格-数据库互导工具
- Fuzzy query in Map pass-by-value and object pass-by-value
- 想随时、随地、随心使用数据库的朋友们,全体注意!
- 2022年 PHP面试问题记录
- [National Programming] "Software Programming - Lecture Video" [Zero Basic Introduction to Practical Application]
猜你喜欢
Hardware Bear Original Collection (Updated 2022/07)
日志工厂(详细)
odoo coding conventions (programming conventions, coding guidelines)
OpenCV installation, QT, VS configuration project settings
暑假第二周总结博客
odoo 编码规范(编程规范、编码指南)
明尼苏达大学团队结合高通量实验与机器学习,实现有效可预测的特定位点重组过程,可调节基因编辑速度
在表格数据上,为什么基于树的模型仍然优于深度学习?
How many steps does it take to convert an ENS domain name into music?
Flowable-based upp (unified process platform) running performance optimization
随机推荐
Map by value
【全民编程】《软件编程-讲课视频》【零基础入门到实战应用】
Selenium在远程中的截图
行业沙龙第二期丨如何通过供应链数字化业务协同,赋能化工企业降本增效?
Leetcode71. 简化路径
7月30号|来一场手把手助您打造智能视觉新爆款的技术动手实验
Multi-Party Threshold Private Set Intersection with Sublinear Communication-2021:解读
What is the JVM runtime data area and the JMM memory model
AntDB数据库亮相24届高速展,助力智慧高速创新应用
typora操作手册
Go GORM事务实例分析
公用函数----mfc
Leetcode74. Search 2D Matrix
三种方案解决:npm WARN config global --global, --local are deprecated. Use --location=global instead.
国标GB28181协议EasyGBS平台兼容老版本收流端口的功能实现
【Translation】OpenMetrics cultivated by CNCF becomes an incubation project
2022,程序员应该如何找工作
ACID Characteristics and Implementation Methods of MySQL Relational Database Transactions
LeetCode 1374. Generate an odd number of each character string
通配符 SSL/TLS 证书