replset = pictureWorks
执行:mongo --port 1008 (查看1008是否是住数据库)
rs.status()
执行:
onfig={"_id":"pictureWorks","members":[{"_id":0,"host":"172.10.9.187:1008","priority":5},{"_id":2,"host":"172.10.9.187:1009","priority":3},{"_id":3,"host":"172.10.9.187:1010","priority":1}]}
{
"_id" : "pictureWorks",
"members" : [
{
"_id" : 0,
"host" : "172.10.9.187:1008",
"priority" : 5
},
{
"_id" : 2,
"host" : "172.10.9.187:1009",
"priority" : 3
},
{
"_id" : 3,
"host" : "172.10.9.187:1010",
"priority" : 1
}
]
}
执行: rs.reconfig(config, {force:true});
mongodb: {
url: 'mongodb://172.10.9.187:1008,172.10.9.187:1009,172.10.9.187:1010/pictureAir',
opt: {
"server": {
"user": '',
"pass": '',
"native_parser": true,
"poolSize": 10,
"auto_reconnect": true,
"socketOptions": {
"keepAlive": 600,
'connectTimeoutMS': 10000,
'socketTimeoutMS': 10000
},
"reconnectTries": 30,
"haInterval": 1000
},
"db": {
"native_parser": true,
"strategy": "ping",
"readPreference": "primaryPreferred",
"bufferMaxEntries": 5
},
"replset": {
"rs_name": "pictureWorks",
"readPreference": "primaryPreferred",
"strategy": "ping",
"poolSize": 10,
"connectWithNoPrimary": false,
"haInterval": 1000,
"socketOptions": {
"keepAlive": 600
}
}
}
}
更多副本集搭建,请查看
https://blog.csdn.net/luonanqin/article/details/8497860
mongodb配置文件:
#https://docs.mongodb.org/manual/reference/configuration-options/
systemLog:
verbosity: 0
quiet: true
traceAllExceptions: true
logRotate: "rename"
destination: file
path: "/db/data/mongodb/logs/mongodb.log"
logAppend: true
timeStampFormat: "iso8601-local"
component:
accessControl:
verbosity: 0
command:
verbosity: 0
control:
verbosity: 0
geo:
verbosity: 0
index:
verbosity: 0
network:
verbosity: 0
query:
verbosity: 0
replication:
verbosity: 0
sharding:
verbosity: 0
storage:
verbosity: 0
processManagement:
fork: true
net:
port: 1008
bindIp: 172.10.9.187
# maxIncomingConnections: 1000
wireObjectCheck: true
ipv6: false
http:
enabled: true
JSONPEnabled: true
RESTInterfaceEnabled: true
security:
authorization: disabled # enabled disabled
#clusterAuthMode: keyFile
#keyFile: "/db/data/mongodb/mongodb.key"
javascriptEnabled: true
setParameter:
enableLocalhostAuthBypass: false
storage:
dbPath: "/db/data/mongodb/data"
indexBuildRetry: true
repairPath: "/db/data/mongodb/repairdata"
journal:
enabled: false #true on 64-bit systems, false on 32-bit systems
commitIntervalMs: 200
directoryPerDB: true
syncPeriodSecs: 60
engine: "wiredTiger"
mmapv1:
nsSize: 16
quota:
enforced: false
maxFilesPerDB: 8
smallFiles: false
journal:
debugFlags: 0
wiredTiger:
engineConfig:
cacheSizeGB: 4
statisticsLogDelaySecs: 0
journalCompressor: "snappy" #none snappy zlib
directoryForIndexes: false
collectionConfig:
blockCompressor: "snappy"
indexConfig:
prefixCompression: true
operationProfiling:
slowOpThresholdMs: 100
mode: "off"
replication:
oplogSizeMB: 1024000
replSetName: "pictureWorks"
secondaryIndexPrefetch: "all"
enableMajorityReadConcern: false
sharding:
archiveMovedChunks: false