connection closing date,禁止注册帐号:127.0.0.1

memcached配置在本地,用telnet stats能够查看到:
STAT pid 1088
STAT uptime
STAT version 1.4.2
STAT pointer_size 64
STAT rusage_user 0.015600
STAT rusage_system 0.000000
STAT curr_connections 11
STAT total_connections 27
STAT connection_structures 12
STAT cmd_get 5
STAT cmd_set 5
STAT cmd_flush 0
STAT get_hits 5
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT bytes_read 227
STAT bytes_written 1475
STAT limit_maxbytes
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT bytes 75
STAT curr_items 1
STAT total_items 5
STAT evictions 0
下面是我写的一个测试例子
package org.study.memcached.
import java.io.IOE
import java.net.InetSocketA
import net.spy.memcached.MemcachedC
public class SpymemcachedTest {
* @param args
* @throws Exception
public static void main(String[] args) {
MemcachedClient client =
client = new MemcachedClient(new InetSocketAddress("localhost", 11211));
} catch (IOException e) {
System.out.println("Connect problem");
e.printStackTrace();
// Store a value (async) for one hour
client.set("someKey", 3600, "abc");
// Retrieve a value (synchronously).
Object myObject = client.get("someKey");
System.out.println("someKey : " + myObject);
jdk1.6,用的spymemcached-2.7.3.jar,连接总是报错:
java.io.IOException: Disconnected unexpected, will reconnect.
at net.spy.memcached.MemcachedConnection.handleReads(MemcachedConnection.java:493)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:418)
at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:275)
at net.spy.memcached.MemcachedClient.run(MemcachedClient.java:2030)
10:21:04.302 WARN net.spy.memcached.MemcachedConnection:
Closing, and reopening {QA sa=localhost/127.0.0.1:11211, #Rops=1, #Wops=0, #iq=0, topRop=Cmd: get Keys: someKey Exp: 0, topWop=null, toWrite=0, interested=1}, attempt 0.
10:21:04.303 WARN net.spy.memcached.protocol.ascii.AsciiMemcachedNodeImpl:
Discarding partially completed op: Cmd: get Keys: someKey Exp: 0
someKey : null
10:21:06.303 INFO net.spy.memcached.MemcachedConnection:
Reconnecting {QA sa=localhost/127.0.0.1:11211, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
10:21:06.304 INFO net.spy.memcached.MemcachedConnection:
Connection state changed for sun.nio.ch.SelectionKeyImpl@3d66aa18
谁碰到过这种问题的?
目前还没有答案
已解决问题
未解决问题不知为何总有种想笑的冲动_舰队collection吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0可签7级以上的吧50个
本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:146,400贴子:
不知为何总有种想笑的冲动收藏
[] The socket connection to the upstream proxy/gateway failed. Closing Fiddler, changing your system proxy settings, and restarting Fiddler may help. ErrorCode: 10061. 由于目标计算机积极拒绝,无法连接。 127.0.0.1:8099打开提督很忙的时候出现的,这计算机真他喵的高级,看来是我家电脑想强上结果被拒绝了。(我脑洞是不是有点大)
1楼 15:11&|
相关的贴子1627313964相关的图贴
我看到的时候也笑尿了。。积极拒绝wwwwwww
2楼 15:25&|来自
这是病,得电
3楼 15:51&|
这是什么问题啊?
4楼 22:20&|
登录百度帐号
内&&容:使用签名档&&
为兴趣而生,贴吧更懂你。&或命令行运行Hbase: Session 0x0 for server null, unexpected error_服务器应用_Linux公社-Linux系统门户网站
你好,游客
命令行运行Hbase: Session 0x0 for server null, unexpected error
来源:Linux社区&
作者:fansy1990
又重新看了下hbase的操作,以前虽说是运行过对Hbase的操作,比如直接的建表,导入数据,或者是使用MR操作Hbase,但是都是在单节点上做的,而且是用eclipse下操作的,不用担心一些包的问题。今天打算把代码拷贝到的lib下面,然后在命令行中运行,遇到的一个问题如下:
12/09/29&12:29:36&INFO&zookeeper.ZooKeeper:&Initiating&client&connection,&connectString=localhost:2181&sessionTimeout=180000&watcher=hconnection&
12/09/29&12:29:36&INFO&zookeeper.ClientCnxn:&Opening&socket&connection&to&server&/127.0.0.1:2181&
12/09/29&12:29:36&INFO&client.ZooKeeperSaslClient:&Client&will&not&SASL-authenticate&because&the&default&JAAS&configuration&section&'Client'&could&not&be&found.&If&you&are&not&using&SASL,&you&may&ignore&this.&On&the&other&hand,&if&you&expected&SASL&to&work,&please&fix&your&JAAS&configuration.&
12/09/29&12:29:36&INFO&zookeeper.RecoverableZooKeeper:&The&identifier&of&this&process&is&6479@fansyPC&
12/09/29&12:29:36&WARN&zookeeper.ClientCnxn:&Session&0x0&for&server&null,&unexpected&error,&closing&socket&connection&and&attempting&reconnect&
java.net.ConnectException:&拒绝连接&
& & at&sun.nio.ch.SocketChannelImpl.checkConnect(Native&Method)&
& & at&sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:692)&
& & at&org.apache.zookeeper.ClientCnxnSocketNIO.doTransport(ClientCnxnSocketNIO.java:286)&
& & at&org.apache.zookeeper.ClientCnxn$SendThread.run(ClientCnxn.java:1035)&
12/09/29&12:29:36&WARN&zookeeper.RecoverableZooKeeper:&Possibly&transient&ZooKeeper&exception:&org.apache.zookeeper.KeeperException$ConnectionLossException:&KeeperErrorCode&=&ConnectionLoss&for&/hbase/master&
看到这个提示,第一次感觉是不是我配置错了?怎么显示的是127.0.0.1的机子呢?应该是其他节点机或者是本机的计算机名字才对的吧,这样就好像是单机启动一样。我的配置如下:
& & & & hbase.rootdir&
& & & & hdfs://fansyPC:9000/hbase&
& & & & hbase.cluster.distributed&
& & & & true&
& & & & hbase.zookeeper.quorum&
& & & & slave1&
& & & & hbase.zookeeper.property.dataDir&
& & & & /home/fansy/zookeeper&
看来感觉还是感觉没有配置错误,所以就又去看了官方文档,上面说要的系统有点不同的,所以我就又改了下: /etc/security/limits.conf& :
添加这两句:
hadoop&-&nofile&32768&
hadoop&soft/hard&nproc&32000&
/etc/pam.d/common-session:
session required pam_limits.so&
但还是不行,然后我就想 会不会是
hbase.zookeeper.quorum&
配置 不能和slave节点机在一个上面?所以我就又改了这个值 ,全部改为 fansyPC了,同时我有看到官方文档上面说要用hbase/lib下面的hadoop-core-1.0.2.jar 去代替haoop/下面的hadoop-core-1.0.2.jar这个文件,然后我又照做了,然后就出现了说类找不到,好了,应该差不多 了。最后我把hbase/lib下面的JAR包都放在了hadoop/lib下面(重复的跳过),然后就Ok了。
相关资讯 & & &
& (02月26日)
& (12/02/:56)
& (03月05日)
& (12/25/:29)
& (11/24/:19)
图片资讯 & & &
   同意评论声明
   发表
尊重网上道德,遵守中华人民共和国的各项有关法律法规
承担一切因您的行为而直接或间接导致的民事或刑事法律责任
本站管理人员有权保留或删除其管辖留言中的任意内容
本站有权在网站内转载或引用您的评论
参与本评论即表明您已经阅读并接受上述条款[技术讨论]mongodb驱动的正确使用方法 - CNode
这家伙很懒,什么个性签名都没有留下。
发布于 2年前
10511 次浏览
mongo数据库在nodejs平台有2个常用驱动,mongodb和mongoose,mongodb接口非常接近mongo数据库原生的操作方式,是helloworld之类演示代码的首选mongo数据库连接驱动,因此成为大部分nodejs初学者最先接触的mongo数据库驱动。初学者在学会mongo连接的同时,却也可悲的被helloword这种演示性质的数据库操作习惯潜移默化了。
cat test.js
var server_options={};
var db_options={
w:-1,// 设置w=-1是mongodb 1.2后的强制要求,见官方api文档
doDebug:true,
debug:function(msg,obj){
console.log('[debug]',msg);
log:function(msg,obj){
console.log('[log]',msg);
error:function(msg,obj){
console.log('[error]',msg);
var mongodb = require(&mongodb&),
mongoserver = new mongodb.Server('localhost', 27017,server_options ),
db = new mongodb.Db('test', mongoserver, db_options);
function test_save(){
//前一个db和后一个db,是同一个对象。
db.open(function(err,db){
if(err)return console.error(err);
console.log('* mongodb connected');
db.collection('foo').save({test:1},function(err,result){
console.log(result);
db.close();
test_save();
这是个随处可见,大家非常熟悉的mongo数据库helloword代码:设置连接参数,open, 访问collection, close。 唯一不同的是为了显示代码背后的实际运作,我给db_options加上一个日志(logger)选项。
node test.js, 客户端输出信息:
[debug] opened connection
[debug] opened connection
[debug] opened connection
[debug] opened connection
[debug] opened connection
[debug] writing command to mongodb
* mongodb connected
[debug] writing command to mongodb
{ test: 1, _id: f6ad00c000001 }
[debug] closed connection
[debug] closed connection
[debug] closed connection
[debug] closed connection
[debug] closed connection
服务端mongo数据库的输出日志:
Mon May 13 12:54:33 [initandlisten] connection accepted from 127.0.0.1:2815 #51
Mon May 13 12:54:33 [initandlisten] connection accepted from 127.0.0.1:2816 #52
Mon May 13 12:54:33 [initandlisten] connection accepted from 127.0.0.1:2817 #53
Mon May 13 12:54:33 [initandlisten] connection accepted from 127.0.0.1:2818 #54
Mon May 13 12:54:33 [initandlisten] connection accepted from 127.0.0.1:2819 #55
Mon May 13 12:54:33 [conn51] end connection 127.0.0.1:2815
Mon May 13 12:54:33 [conn52] end connection 127.0.0.1:2816
Mon May 13 12:54:33 [conn53] end connection 127.0.0.1:2817
Mon May 13 12:54:33 [conn54] end connection 127.0.0.1:2818
Mon May 13 12:54:33 [conn55] end connection 127.0.0.1:2819
客户端和服务器端的日志都表明,db.open了5个连接,而并非一般同学所想象的1个连接。why?这是因为mongoserver = new mongodb.Server('localhost', 27017,server_options )的server_options有个poolSize选项,默认值是5(见)。db对象不仅扮演着与mongo数据库通讯的中间人角色,还同时是一个连接池。默认设置的情况下,helloword代码打开一个有着5个连接的连接池,然后再关闭这个连接池。作为ran and quit的演示,这个操作流程当然没问题,但如果放到http server的应用场景就成大问题了。每次http请求都打开5个数据库连接而后又关闭5个数据库连接,对性能影响可想而知,更为糟糕是open and close的操作流程会导致一个潜在的并发错误。
cat server_1.js
var server_options={};
var db_options={w:-1};
var mongodb = require(&mongodb&),
mongoserver = new mongodb.Server('localhost', 27017,server_options ),
db = new mongodb.Db('test', mongoserver, db_options);
var http=require('http');
var server=http.createServer(function(req,res){
db.open(function(err,db){
if(err)return console.error(err);
console.log('* mongodb connected');
db.collection('foo').save({test:1},function(err,result){
res.end(JSON.stringify(result,null,2));
db.close();
server.listen(8080,function(){
console.log('server listen to %d',this.address().port);
setTimeout(function(){
//http.get('http://localhost:8080',function(res){console.log('request ok')});
//http.get('http://localhost:8080',function(res){console.log('request ok')});
node server.js, 浏览器访问ok,但如果做ab类并发测试或者把倒数2、3行的注释去掉,问题就来了。
c:\nodejs\node_modules\mongodb\lib\mongodb\db.js:224
throw new Error(&db object already connecting, open cannot be called multi
Error: db object already connecting, open cannot be called multiple times
想象db对象是一扇门,open操作相当于开门,开门后才能阅读房间里面的书籍(数据)。当请求1开门后,紧随而来的请求2也想开门但是开不了,因为请求1还没关门(db.close),门还处于“打开”的状态。其实呢,请求2完全没必要再开门,直接尾随请求1进门即可。错误的根源在于我们要打开一扇已经打开的门。how to fix? easy, 从open and close 行为改为 open once and reuse anywhere。程序启动的时候db.open一次,每次http请求直接访问数据库,扔掉db.open/db.close这2个多余的操作。
cat server_2.js
var server_options={'auto_reconnect':true,poolSize:5};
var db_options={w:-1};
var mongodb = require(&mongodb&),
mongoserver = new mongodb.Server('localhost', 27017,server_options ),
db = new mongodb.Db('test', mongoserver, db_options);
db.open(function(err,db){
('mongodb connected');
var http=require('http');
var server=http.createServer(function(req,res){
db.collection('foo').save({test:1},function(err,result){
res.end(JSON.stringify(result,null,2));
server.listen(8080,function(){
console.log('server listen to %d',this.address().port);
setTimeout(function(){
http.get('http://localhost:8080',function(res){console.log('request ok')});
http.get('http://localhost:8080',function(res){console.log('request ok')});
这样改后,虽然没报错了,却引入另一个潜在的问题:当并发访问&5时,因为同时可用的底层数据库连接只有5,从而导致了阻塞。
===================================我是分隔线=====================================
实际应用场景中,直接引用db对象并不是一个好主意。默认情况下,db的poolSize=5,意味着并发只有5, 要提高并发的话,把poolSize拉到10? 20? 50? 100? NO,我们需要的是能动态调整连接数的连接池,既能满足高峰期的连接数要求,也能在空闲期释放闲置的连接,而不是象mongodb的内置连接池那样保持固定连接数。怎么办?重新发明轮子吗?不,重用已有的连接池模块generic_pool。
cat server_3.js
var http=require('http'),
mongodb = require(&mongodb&),
poolModule = require('generic-pool');
var pool = poolModule.Pool({
: 'mongodb',
: function(callback) {
var server_options={'auto_reconnect':false,poolSize:1};
var db_options={w:-1};
var mongoserver = new mongodb.Server('localhost', 27017,server_options );
var db=new mongodb.Db('test', mongoserver, db_options);
db.open(function(err,db){
if(err)return callback(err);
callback(null,db);
: function(db) { db.close(); },
: 10,//根据应用的可能最高并发数设置
idleTimeoutMillis : 30000,
log : false
var server=http.createServer(function(req,res){
pool.acquire(function(err, db) {
if (err) {
res.statusCode=500;
res.end(JSON.stringify(err,null,2));
db.collection('foo').save({test:1},function(err,result){
res.end(JSON.stringify(result,null,2));
pool.release(db);
server.listen(8080,function(){
console.log('server listen to %d',this.address().port);
setTimeout(function(){
http.get('http://localhost:8080',function(res){console.log('request ok')});
http.get('http://localhost:8080',function(res){console.log('request ok')});
将poolSize设为1,一个db对象只负责一个底层的数据库连接,generic_pool通过控制db对象的数目,间接控制实际的数据库连接数目。如果poolSize还采取默认值5,1db=5连接,由于每次http请求期间我们实际使用到的只是1个连接,其他4个连接根本用不上,处于闲置状态,其结果是浪费资源,拖慢响应速度。
备注1:本文mongo数据库设置均采用本机安装的默认设置。
备注2:当需建模的业务对象较多时,使用mongoose驱动是个好主意,它自带的连接池比mongodb实用性强。
备注3:mongodb自1.2以后,官方推荐的连接方式改为MongoClient,将参数设置简化为一个URL(详细见)。目前monodb的版本已经1.3,大家也该是时候转变了吧。
以上文generic_pool连接池的初始化为例,看看新旧连接的对比:
旧连接方法
var pool = poolModule.Pool({
: 'mongodb',
: function(callback) {
var server_options={'auto_reconnect':false,poolSize:1};
var db_options={w:-1};
var mongoserver = new mongodb.Server('localhost', 27017,server_options );
var db=new mongodb.Db('test', mongoserver, db_options);
db.open(function(err,db){
if(err)return callback(err);
callback(null,db);
//......more code here
新连接方法
var pool = poolModule.Pool({
: 'mongodb',
: function(callback) {
mongodb.MongoClient.connect('mongodb://localhost/test', {
server:{poolSize:1}
}, function(err,db){
callback(err,db);
//more code here
好文,收藏。尤其连接池方面,很多人在论坛问。
绝对的好东西啊,收藏了。
前段时间在做项目的时候发现这个问题了,我就自己造轮子了,自己写了一个对象池。不过也就几行代码
不错,高质量的好文啊~
一样的,就是opiton里的create函数换一下就可以啦, 可以看一下我写的另外一篇文章,
在用poolModule包装感觉有点多此一举了,就多了个idleTimeoutMillis参数,无形中增加了复杂度
有一个叫的库~
好文一篇,对于我这种菜鸟很适合!呵呵
好文啊,感谢楼上让它浮上来
T17:13:40.171+0800 [clientcursormon]
connections:15
T17:16:48.734+0800 [initandlisten] connection accepted from 127.0.0.1:
connections now open)
T17:16:50.453+0800 [initandlisten] connection accepted from 127.0.0.1:
connections now open)
T17:16:52.078+0800 [initandlisten] connection accepted from 127.0.0.1:
connections now open)
我想问的问题是,这种方式连接数一直增长到最高并发数吗?什么时候关闭连接?新手求解答!
使用你给的方法,测试了一性能问题。发现了一个大的疑问!
当连接池poolSize设为10时,插入100万条数据,用时78472毫秒。当连接池poolSize设为1时,插入100万条数据,用时53454毫秒。
也就是说当连接数为1时,反而比连接数为10时用时更少!那要连接池还有什么用呢????
一下是测试代码,在Linux下运行
var server_options={’auto_reconnect’:true,poolSize:1};
console.log(&poolSize:&+server_options.poolSize);
var db_options={w:-1};
var mongodb = require(“mongodb”),
mongoserver = new mongodb.Server('localhost’, 27017,server_options ),
db = new mongodb.Db('test’, mongoserver, db_options);
db.open(function(err,db){
(‘mongodb connected’);
function a(x){
db.collection(‘foo’).save({test:1},function(err,result){
if(x==1000000){
var now1=new Date();
var time_end=now1.getTime();
('diff:’+(time_end-time_start));
setTimeout(function(){
var now=new Date();
time_start=now.getTime();
for(var i=1;i&=1000000;i++)
还有一个问题,多个JS怎么共用一个链接?
今天遇到了这个问题,在使用generic-pool的时候用了第一种写法,即是在使用时创建mongo,结果在达到连接池的min数量后出现 Error: db object already connecting, open cannot be called multiple times,如果达到了连接池的最小连接数,再往上不会自动调用create返回一个新的连接吗?而出现的错误似乎是表明我们重复引用了同一个数据库连接,望解答 T_T
mongodb 自己已经有pool了。既然是pool,就不要反复的去open close。
今天刚想通是为什么,tks
官网的doc好像都用MongoClient了 貌似不用用pool 了?
服务器搭建在
,存储赞助商为Ubuntu下RMI Server 抛出java.rmi.ConnectException: Connection refused to host: 127.0.0.1解决办法 - ppby2002的专栏
- 博客频道 - CSDN.NET
2514人阅读
需要启动rmiregistry参见The actual reason is the rmiregistry service on your machine is not running......u hav two ways to solve it......1) start terminal, type &rmiregistry& (without quotes) & hit enter. it will look like something has hanged up....but the service has been started........run your code now & things will work (only till the terminal looks in hanging state). closing the terminal or stopping the rmiregistry by ctrl+c will stop it.2) second way is to add following snippet in your code -static
LocateRegistry.createRegistry(1099);
catch (RemoteException e)
e.printStackTrace();
}this will start the service till your code is running (on the default port 1099).
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:234426次
积分:3547
积分:3547
排名:第3876名
原创:70篇
转载:206篇
评论:22条
(1)(3)(1)(2)(5)(18)(7)(5)(6)(5)(24)(22)(2)(7)(8)(2)(1)(2)(1)(1)(3)(1)(1)(4)(2)(18)(13)(16)(8)(10)(14)(29)(19)(5)(6)(6)(12)(21)(20)}

我要回帖

更多关于 closing date 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信