使用gsutil上传8.6T大文件时进程挂起,求解决方案
解决8.6T大文件上传Google Cloud Storage挂起的方案
优化gsutil上传参数
默认的小分片阈值会让8.6T文件生成海量分片,容易引发资源耗尽或连接异常。调整参数减少分片数量并控制并发:
nohup gsutil -o "GSUtil:parallel_composite_upload_threshold=10G" -o "GSUtil:parallel_process_count=8" -o "GSUtil:parallel_thread_count=10" cp big_file.jsonl gs://bucket/big_file.jsonl > nohup.mv-big-file.out 2>&1 &
parallel_composite_upload_threshold=10G:将分片大小设为10G,大幅降低分片总数parallel_process_count=8和parallel_thread_count=10:限制并发数,避免服务器资源过载
改用rsync实现断点续传
gsutil rsync比cp更适配大文件传输,支持自动跳过已上传部分,即使中断也能从断点恢复:
nohup gsutil -o "GSUtil:parallel_composite_upload_threshold=10G" rsync -P big_file.jsonl gs://bucket/big_file.jsonl > nohup.mv-big-file.out 2>&1 &
-P参数:实时显示上传进度,方便监控状态
拆分文件后分批上传+云端合并
如果单文件上传始终不稳定,可拆分文件后批量上传,再在GCS合并:
- 拆分本地文件(按300G分片,避免超过GCS compose的32片限制):
split -b 300G big_file.jsonl big_file_part_
- 批量上传分片:
nohup gsutil -m cp big_file_part_* gs://bucket/ > nohup.mv-big-file.out 2>&1 &
- 在GCS合并所有分片为原文件:
gsutil compose gs://bucket/big_file_part_* gs://bucket/big_file.jsonl
- 删除临时分片:
gsutil rm gs://bucket/big_file_part_*
排查进程挂起原因
- 实时查看日志,确认是否有隐藏错误:
tail -f nohup.mv-big-file.out
- 检查服务器资源占用,确认是否因CPU、内存或带宽耗尽导致进程挂起:
top
替代工具:使用gcloud storage
gcloud storage是gsutil的下一代工具,对大文件传输的稳定性和性能更优:
nohup gcloud storage cp big_file.jsonl gs://bucket/big_file.jsonl --parallel-composite-upload-threshold=10G --process-count=8 > nohup.mv-big-file.out 2>&1 &
内容的提问来源于stack exchange,提问作者Bob van Luijt
相关产品推荐
相关产品推荐

