2

I have a simple node.js application that makes a single call connection call to my ReplicaSet. Things were actually working fine earlier today and nothing was changed in the application, now my connection is failing (silently) and I'm seeing the following in my mongod logs.

Thu Apr 18 17:16:56 [conn1782026] end connection 10.x.x.x:50720 (40 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50721 #1782027 (41 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50722 #1782028 (42 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50723 #1782029 (43 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50724 #1782030 (44 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50725 #1782031 (45 connections now open)
Thu Apr 18 17:16:57 [initandlisten] connection accepted from 10.x.x.x:50736 #1782032 (46 connections now open)
[conn1782028] SocketException handling request, closing client connection: 9001 socket exception [2] server [10.x.x.x:50722]

I haven't been able to track down what causes this or how to fix it.

Here's my connection code:

var _ = require("underscore");
var db_options = {
    db:{
            w:1,
            native_parser: false
        },
    server:{
        auto_reconnect:true,
        socketOptions: {}
    },
    replSet:{
        rs_name: "my_replset_name",
        readPreference: "secondary"
    },
    mongos: {}
};
db.client.connect("mongodb://server1:27017,server2:27017,server3:27017/my_database", db_options, function(err, _db){
    if(err){
        console.log(err);
    }else{
        _db.collection("my_collection", function(err, collection){
            collection.find({q:1}).toArray(function(err,item){
                if(err){
                    console.log(err);
                }else{
                    _.each(item, function(r){
                        if(!_.isEmpty(r)){
                            // do something with this item!
                            console.log(r._id);
                        }
                    });
                    console.log("Finished.");
                }
            });
        });
    }
});

I'm running my ReplicaSet on EC2 and everything can successfully connect to each otherhave a simple node.js application that makes a single call connection call to my ReplicaSet - like I said, this worked and then stopped working without notice.

Does anyone have any insights into this? What causes it? How to prevent it? How to fix it?

4

1 回答 1

0

如果您的操作系统是rhel5.x,则默认系统参数
net.ipv4.tcp_mem=196608 262144 393216
将其更改为:
net.ipv4.tcp_mem=786432 1048576 1572864

4k(perpage) * 1572864(page)=6G(最大tcp内存),默认1.5G

于 2015-06-04T15:51:53.953 回答