您的位置:首页 > 数据库 > Mongodb

spring mongodb 配置主从复制读写分离

2018-03-13 18:13 393 查看
XML配置文件 :mongo:mongo-client replica-set="${mongo.host}">
        <mongo:client-options write-concern="SAFE"
           connections-per-host="${mongo.connectionsPerHost}"
           threads-allowed-to-block-for-connection-multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"
           connect-timeout="${mongo.connectTimeout}"
           max-wait-time="${mongo.maxWaitTime}"
           socket-keep-alive="${mongo.socketKeepAlive}"
           socket-timeout="${mongo.socketTimeout}"
           read-preference="SECONDARY_PREFERRED"/>
    </mongo:mongo-client>

properties配置文件 :mongo.host=192.168.249.128:27017,192.168.249.129:27017,192.168.249.130:27017
mongo.connectionsPerHost=8
mongo.threadsAllowedToBlockForConnectionMultiplier=4
mongo.connectTimeout=1000
mongo.maxWaitTime=1500
mongo.autoConnectRetry=true
mongo.socketKeepAlive=true
mongo.socketTimeout=1500
mongo.slaveOk=true
mongo.dbname=test
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: