Ubuntu 10.4 上的 APC 配置。 apc.shm_size、apc.shm_segments 和 Apache 的问题
我刚刚安装了 APC 以在我的 Ubuntu VPS 服务器上缓存我的 PHP 代码。使用
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart
这个效果很好。然而,在增加分配给 APC 的 RAM 块时我遇到了一些问题。如果我运行 apc.php,它会向我提供有关共享内存的信息。
Shared Memory 1 Segment(s) with 30.0 MBytes (mmap memory, pthread mutex locking)
即使我配置了
apc.shm_segments 3
不设置默认值
apc.shm_size 30
此外,我还遇到一个问题,即一旦我在 apc.ini
或 php.ini 中设置
apache 在重新启动/优雅时挂起并且不会出现。apc.shm_size
我的问题: 1.如果分配给APC的内存是apc.shm_size * apc.shm_segments
为什么我只能看到90M? 2. 有人遇到过 Apache 在 apc.shm_size
设置上挂起的问题吗?我该如何解决这个问题?
非常感谢!
I've just installed APC to cache my PHP code on my Ubuntu VPS server. Using
sudo apt-get install php-apc
sudo /etc/init.d/apache2 restart
This worked fine. However, I encounter some problems increasing the chunk of RAM allocated to APC. If I run apc.php it gives me this information about the shared memory.
Shared Memory 1 Segment(s) with 30.0 MBytes (mmap memory, pthread mutex locking)
Even though I configured
apc.shm_segments 3
Not setting the default
apc.shm_size 30
In addition I've got the problem that as soon as I set apc.shm_size
in apc.ini
or php.ini
apache hangs on restart/graceful and wont come up.
My questions:
1. If the memory allocated to APC is apc.shm_size * apc.shm_segments
why can I only see 90M?
2. Has got anyone had the problem with the hanging Apache on setting of apc.shm_size
? How would I fix that?
Many thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该检查共享内存的内核最大大小。在类似 debian 的发行版上,它的值相当低(而 ubuntu 是类似 debian 的发行版)。
通过 sysctl.conf 改变它可以帮助你。获取当前值:
这是一个以字节为单位的值。
这可以解释当你设置太大的数字时 apache 崩溃的原因(但你应该在 error.log 中有一些关于它的信息)。
寻找 此响应 APC 并不总是使用
apc.shm_segments
。我们可以在这里看到一些解释: http://www.php.net /manual/fr/apc.configuration.php#94529:但正如这一评论中所说,使用多个共享段肯定比使用一个大段更糟糕。至少有两个大型应用程序大量使用大共享内存,并且总是需要为此更改内核设置,它们是 Varnish 和 PostgreSQL。两者都选择使用一个大的共享段而不是多个。
You should check the kernel max size for shared memory. On debian-like distribution it's quite low (and ubuntu is a debian-like).
Altering it via sysctl.conf could help you.? Get current value with:
It's a value in Bytes.
This could explain apache crash when you set a too big number (but you should have something about it in error.log).
Seem for this response that
apc.shm_segments
is not always used by APC. We can see some explanations here: http://www.php.net/manual/fr/apc.configuration.php#94529:But as said in this comment, using several shared segments is certainly worst as using a big one. there is at least two big application which makes heavy use of big shared memory and which always needs an alteration of the kernel settings for that, it's Varnish and PostgreSQL. Both made the choice of using a big shared segment instead of several.
似乎我发现了问题
在我的机器上安装了旧版本的
APC
。在该版本中,apc.shm_size=30M
必须在内存大小中不包含 M 的情况下进行配置。因此,新版本的 APC 使用apc.shm_size=30M
旧版本apc.shm_size=30
。一旦我进行了更改,Apache 就毫无故障地重新启动了。Seems like i found the problem
Installed an old version of
APC
on my machine. In that versionapc.shm_size=30M
has to be configuered without the M in the memory size. Thus new versions of APC useapc.shm_size=30M
old versionapc.shm_size=30
. Once I made the change Apache restarted without a glitch.