1

我正在使用这个 python 脚本将数据从一个 ElastiCache redis 实例迁移到另一个实例。它使用 redis 流水线以块的形式迁移数据。

https://gist.github.com/thomasst/afeda8fe80534a832607

但我收到了这个奇怪的错误:

Traceback (most recent call last):###########                                         | ETA:  0:00:12
  File "migrate-redis.py", line 95, in <module>
    migrate()
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 664, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 644, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 837, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python2.7/dist-packages/click/core.py", line 464, in invoke
    return callback(*args, **kwargs)
  File "migrate-redis.py", line 74, in migrate
    results = pipeline.execute(False)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2593, in execute
    return execute(conn, stack, raise_on_error)
  File "/usr/local/lib/python2.7/dist-packages/redis/client.py", line 2446, in _execute_transaction
    all_cmds = connection.pack_commands([args for args, _ in cmds])
  File "/usr/local/lib/python2.7/dist-packages/redis/connection.py", line 637, in pack_commands
    output.append(SYM_EMPTY.join(pieces))
MemoryError

RAM 没有问题,因为节点有 6 GB 的 RAM。

源redis的Memory Profile如下:

used_memory:1483900120
used_memory_human:1.38G
used_memory_rss:1945829376
used_memory_peak:2431795528
used_memory_peak_human:2.26G
used_memory_lua:86016
mem_fragmentation_ratio:1.31
mem_allocator:jemalloc-3.6.0

这可能是什么原因?

4

1 回答 1

0

从您的错误日志中,它与您的 redis 服务器无关。当您的 redis 客户端将所有命令打包到内存缓冲区中时,该错误就会发生。

也许您可以尝试减少 migrate-redis.py 中的 SCAN 计数选项,以测试它是否太大而无法打包。

于 2017-08-31T08:26:59.043 回答