为什么 Memcached 是空的

为什么 Memcached 是空的

我已经将 memcached 添加到 LAMP 堆栈和 Wordpress 中,除了 memcached 内存为空之外,一切似乎都很好。当我使用memcdump --servers=127.0.0.1它什么也不返回。此外,当我通过远程登录 127.0.0.1 11211它似乎在运行但却是空的 -统计项目不返回任何内容

统计板块

STAT active_slabs 0
STAT total_malloced 0

我在这里遗漏了什么?

以下是我做过的所有检查

memcached统计数据全力输出

stats
STAT pid 37127
STAT uptime 12198
STAT time 1706711922
STAT version 1.5.22
STAT libevent 2.1.11-stable
STAT pointer_size 64
STAT rusage_user 1.447142
STAT rusage_system 0.916591
STAT max_connections 1024
STAT curr_connections 1
STAT total_connections 14
STAT rejected_connections 13
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 cmd_meta 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 11417
STAT bytes_written 6580
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 5100
STAT lru_maintainer_juggles 12246
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

我在 Ubuntu 20.04 和 Apache 2.4 上的 php-fpm (v7.4) 上运行 PHP。我已经安装了memcached(v1.5.22)通过 apt 以及php7.4-memcached包装和libmemcached 工具

netstat 显示它正在监听端口 11211

tcp    0    0 127.0.0.1:11211  0.0.0.0:*  LISTEN 37127/memcached 

一切都在本地主机上运行,​​因此我保留了默认的 /etc/memcached.conf

# run as a daemon
-d 
# memory
-m 64
# connection port
-p 11211
# user
-u memcache
# listen
-l 127.0.0.1
# pidfile
-P /var/run/memcached/memcached.pid

进程文件存在

-rw-r--r-- 1 memcache memcache 6 Jan 31 12:15 /var/run/memcached/memcached.pid

并且进程运行

ps -eaf | grep memcached
memcache   37127       1  0 12:15 ?        00:00:02 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid

服务正在运行(服务 memcached 状态)

Loaded: loaded (/lib/systemd/system/memcached.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2024-01-31 12:15:26 CET; 3h 19min ago
       Docs: man:memcached(1)
   Main PID: 37127 (memcached)
      Tasks: 10 (limit: 5846)
     Memory: 2.1M
     CGroup: /system.slice/memcached.service
             └─37127 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1 -P /var/run/memcached/memcached.pid

Jan 31 12:15:26 www systemd[1]: Started memcached daemon.

php 模块配置(/etc/php/7.4/mods-available/memcached.ini)没有太多

memcached.ini
; priority=25
extension=memcached.so
; You need to install php-igbinary package to use igbinary serializer
; and php-msgpack to use msgpack serializer
memcached.serializer=php

答案1

为了让 WordPress 使用您的memcached服务,您需要安装适当的缓存插件(有几十个这样的插件)并将其配置为使用您的memcached

相关内容