获取统计信息时,Memcached 在 "END" 后挂起

Memcached hangs after "END" when getting stats

enter code here我在 Microsoft Azure ubuntu 18.04 服务器上安装了 memcached。首先我们尝试将它安装在 docker 容器中,但我们删除了它并使用 sudo apt-get install memcached libmemcached-tools -y 安装了它。配置是默认配置。当我 运行 echo stats | nc 127.0.0.1 11211 它像这样

打印出正常结束时的统计数据
deploy@xyz-api-01:~$ echo stats | nc 127.0.0.1 11211
STAT pid 65896
STAT uptime 6847
STAT time 1584992459
STAT version 1.5.6 Ubuntu
STAT libevent 2.1.8-stable
STAT pointer_size 64
STAT rusage_user 0.597944
STAT rusage_system 0.768785
STAT max_connections 1024
STAT curr_connections 1
STAT total_connections 7
STAT rejected_connections 0
STAT connection_structures 2
STAT reserved_fds 20
STAT cmd_get 1
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 1
STAT get_expired 0
STAT get_flushed 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 64
STAT bytes_written 9509
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT time_in_listen_disabled_us 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT slab_reassign_rescues 0
STAT slab_reassign_chunk_rescues 0
STAT slab_reassign_evictions_nomem 0
STAT slab_reassign_inline_reclaim 0
STAT slab_reassign_busy_items 0
STAT slab_reassign_busy_deletes 0
STAT slab_reassign_running 0
STAT slabs_moved 0
STAT lru_crawler_running 0
STAT lru_crawler_starts 3825
STAT lru_maintainer_juggles 6891
STAT malloc_fails 0
STAT log_worker_dropped 0
STAT log_worker_written 0
STAT log_watcher_skipped 0
STAT log_watcher_sent 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT slab_global_page_pool 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evicted_active 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT crawler_items_checked 0
STAT lrutail_reflocked 0
STAT moves_to_cold 0
STAT moves_to_warm 0
STAT moves_within_lru 0
STAT direct_reclaims 0
STAT lru_bumps_dropped 0
END

此时它挂起了,好像它在等待什么,但输入命令没有任何作用。它一直在那里,直到我键入 CTRL+C。当它 运行 在 docker 容器中时,我们遇到了完全相同的问题,这就是为什么我们尝试将它直接安装在服务器中以防容器出现问题。我们使用 memcached 的应用程序在尝试连接到 memcached 时也会超时,所以我不认为这只是一个终端问题。

谷歌搜索没有找到任何关于这个特定问题的帖子,大多数遇到 memcached 挂起问题的人发现它挂起一段时间然后最终 returns。我以前从未见过这种行为,而且我在配置或任何地方都找不到任何可以解释这一点的东西。如果有人知道可能导致此问题的原因或我需要检查的某些配置,我将不胜感激。

nc 本质上是连接和聆听,除非您告诉它不要停止,否则它不会停止聆听。所以CTRL+C,或者如果你想强制它在一秒后超时:

echo stats | nc -w 1 127.0.0.1 11211

这里没有发生任何错误。这是关于 nc 的工作原理。

https://www.tutorialspoint.com/unix_commands/nc.htm

您需要发送退出命令,例如:

printf "stats\nquit\n" | nc 127.0.0.1 11211