推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
deepall
V2EX  ›  Python

hadoop 的 lease 机制

  •  
  •   deepall · Dec 24, 2019 · 3665 views
    This topic created in 2467 days ago, the information mentioned may be changed or developed.
    我使用 scrapy-redis 开发了一个分布式爬虫,并分别部署在 4 个 docker 中,抓取程序中的 pipeline 负责连接 hadoop 并将数据追加到 hadoop 中,但因为是分布式的存在,必定会造成同一时刻有多个 client 操作同一个 file,就违反了 hadoop 的 lease 机制,从而造成数据入库失败,大家有什么办法解决吗
    6 replies  •  2019-12-24 14:33:35 +08:00
    vveexx
        1
    vveexx  
       Dec 24, 2019   ❤️ 1
    和楼主的场景类似,我们走了 kafka,多生产者,单个消费者
    hdbzsgm
        2
    hdbzsgm  
       Dec 24, 2019   ❤️ 1
    简单场景 随便用个单点 redis 做锁喽
    deepall
        3
    deepall  
    OP
       Dec 24, 2019
    @vveexx @hdbzsgm 谢了两位,我还担心我说的无法理解,多个生产者,单个消费者,精辟
    F281M6Dh8DXpD1g2
        4
    F281M6Dh8DXpD1g2  
       Dec 24, 2019
    没这么复杂,每个爬虫自己写自己的文件最后合起来处理就行了
    deepall
        5
    deepall  
    OP
       Dec 24, 2019
    @liprais 你是这个意思吗,爬虫来一条数据,写入文件,最后在某个固定时间点 upload 到 hadoop 上
    Leiothrix
        6
    Leiothrix  
       Dec 24, 2019
    用 redis 实现一个简单的分布式进程锁可解,用 lua 脚本保证操作原子性
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   985 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 23:07 · PVG 07:07 · LAX 16:07 · JFK 19:07
    ♥ Do have faith in what you're doing.