2014-10-06 55 views
0

使用memcached的故障轉移服務器,我試圖建立一個強大的memcached的配置與node-memcached驅動程序的應用程序的NodeJS,但它似乎沒有一臺服務器去世使用指定的故障轉移服務器。在應用程序的NodeJS

我的本地試驗進展如下:

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 :(

什麼可能我們做錯了任何想法?

回答

-1

這是來當你的服務器的NodeJS不是從memcached的 得到任何會話ID請php.ini文件正確地檢查你是否正確或不設置memcached的

session.save =「內存緩存」 session.path ='tcp:// localhost:11212'

+0

php.ini?你在說什麼? : - | – fortran 2014-10-07 15:41:13

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庫(反過來,由node-memcached的同一作者維護)中輸出一個棄用錯誤。恕我直言,隨時打開一個錯誤:-)

+0

是的,我們也試過這個選項,但也沒有工作:( – fortran 2014-10-07 14:47:19