Mongodb副本集使用Spring Data Framework附加“/”

时间:2014-04-03 04:57:52

标签: linux mongodb spring-data-mongodb

我的resplica set配置是这样的:

rs.glu:SECONDARY> rs.status()
{
    "set" : "rs.glu",
    "date" : ISODate("2014-04-03T04:34:35Z"),
    "myState" : 2,
    "syncingTo" : "10.13.96.13:27017",
    "members" : [
            {
                    "_id" : 2,
                    "name" : "10.13.98.14:27017",
                    "health" : 1,
                    "state" : 1,
                    "stateStr" : "PRIMARY",
                    "uptime" : 51453,
                    "optime" : Timestamp(1396448528, 1),
                    "optimeDate" : ISODate("2014-04-02T14:22:08Z"),
                    "lastHeartbeat" : ISODate("2014-04-03T04:34:33Z"),
                    "lastHeartbeatRecv" : ISODate("2014-04-03T04:34:33Z"),
                    "pingMs" : 1
            },
            {
                    "_id" : 3,
                    "name" : "10.13.98.13:27017",
                    "health" : 1,
                    "state" : 7,
                    "stateStr" : "ARBITER",
                    "uptime" : 51453,
                    "lastHeartbeat" : ISODate("2014-04-03T04:34:33Z"),
                    "lastHeartbeatRecv" : ISODate("2014-04-03T04:34:33Z"),
                    "pingMs" : 1
            },
            {
                    "_id" : 4,
                    "name" : "10.13.96.13:27017",
                    "health" : 1,
                    "state" : 2,
                    "stateStr" : "SECONDARY",
                    "uptime" : 51453,
                    "optime" : Timestamp(1396448528, 1),
                    "optimeDate" : ISODate("2014-04-02T14:22:08Z"),
                    "lastHeartbeat" : ISODate("2014-04-03T04:34:34Z"),
                    "lastHeartbeatRecv" : ISODate("2014-04-03T04:34:34Z"),
                    "pingMs" : 0,
                    "syncingTo" : "10.13.98.14:27017"
            },
            {
                    "_id" : 5,
                    "name" : "10.13.96.12:27017",
                    "health" : 1,
                    "state" : 2,
                    "stateStr" : "SECONDARY",
                    "uptime" : 51533,
                    "optime" : Timestamp(1396448528, 1),
                    "optimeDate" : ISODate("2014-04-02T14:22:08Z"),
                    "self" : true
            }
    ],
    "ok" : 1
}

现在我的连接器代码是这样的:

List<ServerAddress> listOfServers = new ArrayList<ServerAddress>();
listOfServers.add(new ServerAddress(properties.getProperty("mongo.host1"), Integer.valueOf(properties.getProperty("mongo.port1"))));
listOfServers.add(new ServerAddress(properties.getProperty("mongo.host2"), Integer.valueOf(properties.getProperty("mongo.port2"))));
listOfServers.add(new ServerAddress(properties.getProperty("mongo.host3"), Integer.valueOf(properties.getProperty("mongo.port3"))));
MongoClient mongoClient = new MongoClient(listOfServers);
mongoClient.setWriteConcern(WriteConcern.ACKNOWLEDGED);

MongoDbFactory gameDbFactory = new SimpleMongoDbFactory(mongoClient, properties.getProperty("adminportal.db"));

MongoTemplate gameMongoTemplate =新的MongoTemplate(gameDbFactory);

这是我的属性文件:

mongo.host1=10.13.96.12 
mongo.port1=27017

mongo.host2=10.13.96.13
mongo.port2=27017

mongo.host3=10.13.98.14
mongo.port3=27017

但是当我尝试连接我的代码时,我得到了这个例外,

WARNING: Server seen down: /10.13.96.12:27017 - java.io.IOException - message: Read  timed out
Apr 03, 2014 12:36:26 AM com.mongodb.ConnectionStatus$UpdatableNode update
WARNING: Server seen down: /10.13.96.13:27017 - java.io.IOException - message: Read timed out
Apr 03, 2014 12:36:46 AM com.mongodb.ConnectionStatus$UpdatableNode update 
WARNING: Server seen down: /10.13.98.14:27017 - java.io.IOException - message: Read timed out
Apr 03, 2014 12:38:14 AM com.mongodb.ConnectionStatus$UpdatableNode update
  1. 为什么会发生这种情况,为什么ip之前会出现斜线?
  2. 我的代码中没有附加“/”的地方?
  3. 我是否认为这是问题的原因?

    由于 ANKUR

1 个答案:

答案 0 :(得分:1)

这似乎是记录器配置的问题,而不是错误。

有关mongoDB的记录器配置,请参阅https://groups.google.com/forum/#!topic/mongodb-user/eAV7erPoZGUConfigure logging for the MongoDB Java driver