在nodejs app中使用memcached故障转移服务器

时间:2014-10-06 22:05:29

标签: node.js memcached

我正在尝试使用node-memcached驱动程序为nodejs应用设置健壮的 memcached 配置,但在一台服务器上似乎没有使用指定的故障转移服务器模具

我的本​​地实验如下:

memcached -p 11212

节点

MC = require('memcached')
c = new MC('localhost:11211', //this process does not exist
            {failOverServers: ['localhost:11212']})
c.get('foo', console.log) //this will eventually time out
c.get('foo', console.log) //repeat 5 or 6 times to exceed the retries number
//wait until all the connection errors appear in the console
//at this point, the failover server should be in use
c.get('foo', console.log) //this still times out :(

我们可能做错什么的任何想法?

2 个答案:

答案 0 :(得分:1)

似乎故障转移功能在node-memcached中有些错误。

要启用故障转移,您必须设置remove选项:

c = new MC('localhost:11211', //this process does not exist
            {failOverServers: ['localhost:11212'],
             remove : true})

不幸的是,由于以下错误,这不起作用:

[depricated] HashRing#replaceServer is removed.
[depricated] the API has no replacement

也就是说,当尝试使用故障转移列表中的替换替换死服务器时,node-memcached会从HashRing库输出一个弃用错误(后者由节点的同一作者维护) -memcached)。恕我直言,随意打开一个错误: - )

答案 1 :(得分:-1)

当您的nodejs服务器没有从memcached获取任何会话ID时,就会出现这种情况 请在正确设置的php.ini文件中正确检查memcached

session.save =' memcache' session.path =' tcp:// localhost:11212'

相关问题