gpt4 book ai didi

php - 从unix套接字获取PHP memcached统计信息和版本

转载 作者:行者123 更新时间:2023-12-03 11:55:20 25 4
gpt4 key购买 nike

在监听TCP端口时,我能够使用PHP 5.6成功获取memcached版本

<?php
$m = new Memcached();
$m->addServer('localhost', 11211);
print_r($m->getStats());
print_r($m->getVersion());
?>

然后我得到了我期望的输出
root@debian8x64:~# php memcached
Array
(
[localhost:11211] => Array
(
[pid] => 22165
[uptime] => 8
[threads] => 4
[time] => 1460472519
[pointer_size] => 64
[rusage_user_seconds] => 0
[rusage_user_microseconds] => 0
[rusage_system_seconds] => 0
[rusage_system_microseconds] => 0
[curr_items] => 0
[total_items] => 0
[limit_maxbytes] => 67108864
[curr_connections] => 5
[total_connections] => 6
[connection_structures] => 6
[bytes] => 0
[cmd_get] => 0
[cmd_set] => 0
[get_hits] => 0
[get_misses] => 0
[evictions] => 0
[bytes_read] => 8
[bytes_written] => 0
[version] => 1.4.25
)

)
Array
(
[localhost:11211] => 1.4.25
)

当我更改为unix套接字并指定端口0时
$m->addServer('/var/run/memcached.sock', 0);

我得到这个输出
Array
(
[/var/run/memached.sock:11211] => Array
(
[pid] => -1
[uptime] => 0
[threads] => 0
[time] => 0
[pointer_size] => 0
[rusage_user_seconds] => 0
[rusage_user_microseconds] => 0
[rusage_system_seconds] => 0
[rusage_system_microseconds] => 0
[curr_items] => 0
[total_items] => 0
[limit_maxbytes] => 0
[curr_connections] => 0
[total_connections] => 0
[connection_structures] => 0
[bytes] => 0
[cmd_get] => 0
[cmd_set] => 0
[get_hits] => 0
[get_misses] => 0
[evictions] => 0
[bytes_read] => 0
[bytes_written] => 0
[version] =>
)

)
Array
(
[/var/run/memached.sock:11211] => 255.255.255
)

我正在使用这些参数运行memcached只是为了进行测试
memcached -u root -s /var/run/memcached.sock -a 755 -vvvv

我的memcached php信息
memcached support => enabled
Version => 2.2.0
libmemcached version => 1.0.18
SASL support => yes
Session support => yes
igbinary support => no
json support => no
msgpack support => no
memcached
memcached support => enabled
libmemcached version => 1.0.18
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.serializer => php => php
memcached.sess_binary => 0 => 0
memcached.sess_connect_timeout => 1000 => 1000
memcached.sess_consistent_hash => 0 => 0
memcached.sess_lock_expire => 0 => 0
memcached.sess_lock_max_wait => 0 => 0
memcached.sess_lock_wait => 150000 => 150000
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_prefix => memc.sess.key. => memc.sess.key.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed => 0 => 0
memcached.store_retry_count => 2 => 2

最佳答案

尽管我所阅读的755内容还不够,但问题最终还是与权限相关。如果要保证memcached Unix套接字可以正常工作,请在/tmp文件夹中使用777,因为Unix套接字可以正常工作。

更加安全的解决方案可以是found here,与ng5-x或Apache的php5-fpm或php7.0-fpm一起使用。

关于php - 从unix套接字获取PHP memcached统计信息和版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36576873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com