赞
踩
问题:
将较大文件利用python 的redis包set,get时报错:
- BrokenPipeError: [Errno 32] Broken pipe
-
- redis.exceptions.ConnectionError: Error 104 while writing to socket. Connection reset by peer.
原因:
set或get数据时,数据过大,则会报以上错误。
Redis' String data type can be at most 512MB
解决方式:
利用split命令将大文件分割为较小文件:
方法1:指定分割后文件行数
通过指定分割后文件的行数来进行文件分割。
split -l 100000 online_discount_end2018-09-26 online_discount_end2018-09-26split
分割后效果,将75兆大小文件(1392082 行),按每个文件100000行分割:
- $ wc -l online_discount_end2018-09-26*
- 1392082 online_discount_end2018-09-26
- 100000 online_discount_end2018-09-26splitaa
- 100000 online_discount_end2018-09-26splitab
- 100000 online_discount_end2018-09-26splitac
- 100000 online_discount_end2018-09-26splitad
- 100000 online_discount_end2018-09-26splitae
- 100000 online_discount_end2018-09-26splitaf
- 100000 online_discount_end2018-09-26splitag
- 100000 online_discount_end2018-09-26splitah
- 100000 online_discount_end2018-09-26splitai
- 100000 online_discount_end2018-09-26splitaj
- 100000 online_discount_end2018-09-26splitak
- 100000 online_discount_end2018-09-26splital
- 100000 online_discount_end2018-09-26splitam
- 92082 online_discount_end2018-09-26splitan
- 2784164 total
其中后缀aa,ab,,,都是自动生成。
方法2:指定分割后文件大小
split -b 5m online_discount_end2018-09-26 online_discount_end2018-09-26split
参考:
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。