본문 바로가기

리눅스

[리눅스] mongodb(router) - 3

728x90

mongodb(router) - 3

mongodb PRIMARY

docker run -it --rm --add-host=mongodb-201:1.1.1.201 --add-host=mongodb-202:1.1.1.202 --add-host=mongodb-203:1.1.1.203 anti1346/mongo:5.0.8 bash
mongo mongodb-201:27017
# mongo mongodb-201:27017
MongoDB shell version v5.0.8
connecting to: mongodb://mongodb-201:27017/test?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("526dd9c5-f3e0-4baf-ae74-30ba015597ed") }
MongoDB server version: 5.0.8
================
Warning: the "mongo" shell has been superseded by "mongosh",
which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
an upcoming release.
For installation instructions, see
https://docs.mongodb.com/mongodb-shell/install/
================
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
	https://community.mongodb.com
mongos>
docker-compose exec router bash
sh.status()
mongos> sh.status()
--- Sharding Status ---
  sharding version: {
  	"_id" : 1,
  	"minCompatibleVersion" : 5,
  	"currentVersion" : 6,
  	"clusterId" : ObjectId("629ef0346075e6fadc5a120a")
  }
  shards:
  active mongoses:
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled: yes
        Currently running: no
        Failed balancer rounds in last 5 attempts: 0
        Migration results for the last 24 hours:
                No recent migrations
  databases:
        {  "_id" : "config",  "primary" : "config",  "partitioned" : true }
sh.addShard("rs0/mongodb-201:27011")
mongos> sh.addShard("rs0/mongodb-201:27011")
{
	"shardAdded" : "rs0",
	"ok" : 1,
	"$clusterTime" : {
		"clusterTime" : Timestamp(1654586569, 4),
		"signature" : {
			"hash" : BinData(0,"k6Ave+ICVLq/l+GyJ5cI2X0DRXY="),
			"keyId" : NumberLong("7106381368166187031")
		}
	},
	"operationTime" : Timestamp(1654586569, 4)
}
sh.status()
mongos> sh.status()
--- Sharding Status ---
  sharding version: {
  	"_id" : 1,
  	"minCompatibleVersion" : 5,
  	"currentVersion" : 6,
  	"clusterId" : ObjectId("629ef0346075e6fadc5a120a")
  }
  shards:
        {  "_id" : "rs0",  "host" : "rs0/mongodb-201:27011,mongodb-201:27012,mongodb-202:27011,mongodb-202:27012,mongodb-203:27011,mongodb-203:27012",  "state" : 1,  "topologyTime" : Timestamp(1654586569, 1) }
  active mongoses:
        "5.0.8" : 3
  autosplit:
        Currently enabled: yes
  balancer:
        Currently enabled: yes
        Currently running: no
        Failed balancer rounds in last 5 attempts: 0
        Migration results for the last 24 hours:
                No recent migrations
  databases:
        {  "_id" : "config",  "primary" : "config",  "partitioned" : true }
728x90