Increased fragmentation of 7.1.4 mongodb4.x

Used elasticsearch people should know, es dynamic fragmentation is very powerful, look at the chart, data backup node is managed by yourself es
1
my first 7.1.1Spring operation mongodb of mongodb4.x Cluster Setup reference in MongoDB4. 0.2 patch + build a replica set cluster , does mongodb slice must manually specify it?
Take a look at 10 minutes to complete MongoDB capacity planning and hardware configuration
in accordance with one Lord, one from a mode of arbitration, each new node is it not a multiple of 3?
We do not need to create config server, so the new node in the following directory is created, in which mongos.confthe content without changing

mkdir -p /application/data/mongodb/mongos/log
mkdir -p /application/data/mongodb/shard4/data
mkdir -p /application/data/mongodb/shard4/log
mkdir -p /application/data/mongodb/shard5/data
mkdir -p /application/data/mongodb/shard5/log
mkdir -p /application/data/mongodb/shard6/data
mkdir -p /application/data/mongodb/shard6/log
# shared4.conf
systemLog:
  destination: file
  logAppend: true
  path: /application/data/mongodb/shard4/log/shared4.log
 
# Where and how to store data.
storage:
  dbPath: /application/data/mongodb/shard4/data
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true
  pidFilePath: /application/data/mongodb/shard4/log/shard4.pid
 
# network interfaces
net:
  port: 27004
  bindIp: 0.0.0.0
 
#operationProfiling:
replication:
    replSetName: shard4     

sharding:
    clusterRole: shardsvr
systemLog:
  destination: file
  logAppend: true
  path: /application/data/mongodb/shard5/log/shared5.log
 
# Where and how to store data.
storage:
  dbPath: /application/data/mongodb/shard5/data
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true
  pidFilePath: /application/data/mongodb/shard5/log/shard5.pid
 
# network interfaces
net:
  port: 27005
  bindIp: 0.0.0.0
 
#operationProfiling:
replication:
    replSetName: shard5     

sharding:
    clusterRole: shardsvr
systemLog:
  destination: file
  logAppend: true
  path: /application/data/mongodb/shard6/log/shared6.log
 
# Where and how to store data.
storage:
  dbPath: /application/data/mongodb/shard6/data
  journal:
    enabled: true

# how the process runs
processManagement:
  fork: true
  pidFilePath: /application/data/mongodb/shard1/log/shard6.pid
 
# network interfaces
net:
  port: 27006
  bindIp: 0.0.0.0
 
#operationProfiling:
replication:
    replSetName: shard6     

sharding:
    clusterRole: shardsvr

Execute the following command to start shard

mongod -f /application/data/mongodb/config/shard4.conf
mongod -f /application/data/mongodb/config/shard5.conf
mongod -f /application/data/mongodb/config/shard6.conf

And then the slice configuration

mongo --port 27004

config = {
    _id : "shard4",
     members : [
         {_id : 0, host : "bwhs163:27004", priority : 2 },
         {_id : 1, host : "bwhs164:27004" , arbiterOnly :true},
         {_id : 2, host : "bwhs165:27004", priority : 1 }
     ]
}
rs.initiate(config)


mongo --port 27005

config = {
    _id : "shard5",
     members : [
         {_id : 0, host : "bwhs163:27005", priority : 1 },
         {_id : 1, host : "bwhs164:27005" , priority :2},
         {_id : 2, host : "bwhs165:27005", arbiterOnly :true }
     ]
}
rs.initiate(config)

mongo --port 27006
config = {
    _id : "shard6",
     members : [
         {_id : 0, host : "bwhs163:27006", arbiterOnly :true },
         {_id : 1, host : "bwhs164:27006" , priority :2},
         {_id : 2, host : "bwhs165:27006", priority : 2 }
     ]
}
rs.initiate(config)

Run mongos -f /application/data/mongodb/config/mongos.conf, followed by slicing it

mongo --port 20000
use admin
sh.addShard("shard4/bwhs163:27004,bwhs164:27004,bwhs164:27004")
sh.addShard("shard5/bwhs163:27005,bwhs164:27005,bwhs164:27005")
sh.addShard("shard6/bwhs163:27006,bwhs164:27006,bwhs164:27006")

Execution db.stats()can see which slice in the corresponding database.
1

Published 317 original articles · won praise 168 · Views 460,000 +

Guess you like

Origin blog.csdn.net/warrah/article/details/89308150