Magento会话消失与memcache开启 [英] Magento sessions disappearing with memcache turned on

查看:188
本文介绍了Magento会话消失与memcache开启的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个问题,我们有会话从Magento 1.10随机消失,当我们启用了memcache(在nginx web服务器上)。

We are having an issue where we have sessions disappearing randomly from Magento 1.10, when we have memcache enabled (on an nginx web server).

无论我们在Magento中设置cookie到期时间,由于某种原因,任何随机时间在一小时内会话消失。

It does not seem to matter what we set the cookie expiration time to in Magento, for some reason any random time within an hour the session goes away.

如果我们关闭memcache,

If we turn memcache off, it works fine.

我们最终需要多个服务器连接到一个基于会话的缓存解决方案,因此memcache似乎是唯一的选择。此外,我们现在只是在memcache缓存会话,当我检查memcache统计信息,我们没有接近阈值限制。

We will eventually need multiple servers connecting to one session based caching solution, so memcache seems like the only option. Also, we are only caching sessions within memcache right now and when I check the memcache stats, we are nowhere near the threshold limit.

这里是内存缓存设置在 local.xml

Here are the memcache settings in the local.xml:

<cache>
    <type>memcached</type>
            <path/>
            <servers>
                <localhost>
                    <host><![CDATA[127.0.0.1]]></host>
                    <port><![CDATA[11211]]></port>
                    <persistent><![CDATA[1]]></persistent>
                </localhost>
            </servers>
</cache>
<session_save><![CDATA[memcache]]></session_save> <!-- db / memcache / empty=files -->
<session_save_path><![CDATA[tcp://localhost:11211?persistent=0&weight;=2&timeout;=10&retry;_interval=10]]></session_save_path>
<session_cache_limiter><![CDATA[private]]></session_cache_limiter>

这整个事情的困难部分是,它很难重现,因为会话清除在一小时内。有时候是在一分钟之内,有时候是45 ...

The hard part of this whole thing is, that it is very hard to reproduce as the session clears sometime within an hour. Sometimes it is within a minute, sometimes 45...

我们有几个人在这里尝试在多个虚拟服务器系统的所有不同的浏览器)和他们都似乎清楚相同的时间。

We have had several people here try it in all of the different browsers in multiple virtual server systems (to eliminate conflicts) and they all seem to clear about the same timeish.

现在的逻辑将决定,有一个进程,刷新内存缓存,但我不知道如何测试,如果我做了,如何告诉它是什么清除它。我浏览了Magento代码,但我找不到任何看起来像是清除这个或删除会话从内存缓存。

Now logic would dictate, that there is a process that is flushing the memcache, but I have not idea how to test for that and if I did, how to tell what it was that cleared it. I looked through the Magento code, but I could not find anything that looked like it was clearing this or removing the session from memcache.

我发现的是,在会话结束后,前端cookie保留在浏览器上,当我检查memcache slabs,cookie消失了。

What I did find though is, that the "frontend" cookie stays on the browser after the session is gone and when I check in the memcache slabs, the cookie is gone.

并非所有的键/值都从memcache中消失,在这种情况下只是其中的一些。矿和2或3其他由于某些原因完全失踪。

Not all of the key/values are gone from memcache, in this case just some of them. Mine and 2 or 3 others for some reason were completely missing.

现在,我要求的不只是有人遇到这个问题,但是有没有任何人有什么其他想法尝试?

Now, what I am asking is not only has anyone ran into this, but does anyone have any additional ideas on what to try?

我一直在使用(着名的)memcache.php文件来监视服务器上的memcache系统。任何其他想法/应用程序我可以尝试?

I have been using the (famous) memcache.php file to monitor the memcache system on the server. Any other ideas/apps I can try?

推荐答案

这可能是或可能不是你的问题,把它放在这里,因为别人可能会发现它有用。

This may or may not be your issue, but it was mine. Putting it here since others may find it useful.

Memcached对超过30天(2592000秒)的超时时间不会太好。显然,它会将大于那个数字的数字解释为自从时代起的日期,并过期项目。

Memcached doesn't take too well to expire times beyond 30 days (2592000 seconds.) Apparently, it interprets numbers larger than that as dates, since the epoch, and expires items immediately.

Magento的local.xml的session *元素设置PHP环境变量。任何未在local.xml中设置的相关PHP环境变量都是从php.ini(或其他.ini。)中设置

The session* elements of Magento's local.xml set PHP environment variables. Any relevant PHP environment variables that are not set in the local.xml get set from the php.ini (or other .ini.)

因此:

在php.ini中,如果session.gc_maxlifetime设置为2592000以上,你将得到一个不工作的memcached。

In php.ini, if session.gc_maxlifetime is set above 2592000, you'll get a non-working memcached.

因此,将php.ini中的行更改为以下内容:

Therefore, change the line in php.ini to the following:

session.gc_maxlifetime = 2592000

这篇关于Magento会话消失与memcache开启的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆