ยง2023-07-26
- MongoDB Sharding: 6 Easy Steps Tutorial
- using orgpiJammy.yushei.net as config server
Step 1) Create a separate database for the config server.
- orgpi5Jammy.yushei.net
- /etc/mongodb.conf
# will not allow you to setup config server not on a replicationSet replication: replSetName: MunetakaShardingConfigServer sharding: clusterRole: configsvr
sudo systemctl restart mongodb
and check mongod.log
$ sudo grep SHARDING /opt/xfs/mongodb/log/mongod.log {"t":{"$date":"2023-07-26T15:27:14.673+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:27:14.673+08:00"},"s":"W", "c":"SHARDING", "id":7445900, "ctx":"initandlisten","msg":"Started with ShardServer role, but no shardIdentity document was found on disk.","attr":{"namespace":"admin.system.version"}} {"t":{"$date":"2023-07-26T15:27:44.674+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:28:14.675+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:28:44.676+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:29:14.679+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:29:44.680+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:30:14.681+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:30:44.683+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:31:14.685+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:31:44.686+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:32:14.686+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} {"t":{"$date":"2023-07-26T15:32:44.687+08:00"},"s":"I", "c":"SHARDING", "id":22727, "ctx":"ShardRegistryUpdater","msg":"Error running periodic reload of shard registry","attr":{"error":"NotYetInitialized: Config shard has not been set up yet","shardRegistryReloadIntervalSeconds":30}} $ sudo grep REPL /opt/xfs/mongodb/log/mongod.log {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ReshardingCoordinatorService","namespace":"config.reshardingOperations"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ConfigsvrCoordinatorService","namespace":"config.sharding_configsvr_coordinators"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"RenameCollectionParticipantService","namespace":"config.localRenameParticipants"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardingDDLCoordinator","namespace":"config.system.sharding_ddl_coordinators"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ReshardingDonorService","namespace":"config.localReshardingOperations.donor"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ReshardingRecipientService","namespace":"config.localReshardingOperations.recipient"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}} {"t":{"$date":"2023-07-26T15:27:13.755+08:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"main","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}} {"t":{"$date":"2023-07-26T15:27:14.649+08:00"},"s":"I", "c":"REPL", "id":5853300, "ctx":"initandlisten","msg":"current featureCompatibilityVersion value","attr":{"featureCompatibilityVersion":"unset","context":"startup"}} {"t":{"$date":"2023-07-26T15:27:14.655+08:00"},"s":"I", "c":"REPL", "id":40440, "ctx":"initandlisten","msg":"Starting the TopologyVersionObserver"} {"t":{"$date":"2023-07-26T15:27:14.655+08:00"},"s":"I", "c":"REPL", "id":40445, "ctx":"TopologyVersionObserver","msg":"Started TopologyVersionObserver"} {"t":{"$date":"2023-07-26T15:27:14.673+08:00"},"s":"I", "c":"REPL", "id":6015317, "ctx":"initandlisten","msg":"Setting new configuration state","attr":{"newState":"ConfigStartingUp","oldState":"ConfigPreStart"}} {"t":{"$date":"2023-07-26T15:27:14.674+08:00"},"s":"I", "c":"REPL", "id":6005300, "ctx":"initandlisten","msg":"Starting up replica set aware services"} {"t":{"$date":"2023-07-26T15:27:14.679+08:00"},"s":"I", "c":"REPL", "id":4280500, "ctx":"initandlisten","msg":"Attempting to create internal replication collections"} {"t":{"$date":"2023-07-26T15:27:14.698+08:00"},"s":"I", "c":"REPL", "id":7360102, "ctx":"initandlisten","msg":"Added oplog entry for create to transaction","attr":{"namespace":"local.$cmd","uuid":{"uuid":{"$uuid":"be10df3e-2488-48cd-81d9-e885b92553f4"}},"object":{"create":"replset.oplogTruncateAfterPoint","idIndex":{"v":2,"key":{"_id":1},"name":"_id_"}}}} {"t":{"$date":"2023-07-26T15:27:14.721+08:00"},"s":"I", "c":"REPL", "id":7360102, "ctx":"initandlisten","msg":"Added oplog entry for create to transaction","attr":{"namespace":"local.$cmd","uuid":{"uuid":{"$uuid":"6cacc027-8e95-404c-96b0-edda712ae3fb"}},"object":{"create":"replset.minvalid","idIndex":{"v":2,"key":{"_id":1},"name":"_id_"}}}} {"t":{"$date":"2023-07-26T15:27:14.731+08:00"},"s":"I", "c":"REPL", "id":7360102, "ctx":"initandlisten","msg":"Added oplog entry for create to transaction","attr":{"namespace":"local.$cmd","uuid":{"uuid":{"$uuid":"8ba3e7ce-fed9-4483-a34a-79371893bf73"}},"object":{"create":"replset.election","idIndex":{"v":2,"key":{"_id":1},"name":"_id_"}}}} {"t":{"$date":"2023-07-26T15:27:14.732+08:00"},"s":"I", "c":"REPL", "id":4280501, "ctx":"initandlisten","msg":"Attempting to load local voted for document"} {"t":{"$date":"2023-07-26T15:27:14.732+08:00"},"s":"I", "c":"REPL", "id":21311, "ctx":"initandlisten","msg":"Did not find local initialized voted for document at startup"} {"t":{"$date":"2023-07-26T15:27:14.732+08:00"},"s":"I", "c":"REPL", "id":4280502, "ctx":"initandlisten","msg":"Searching for local Rollback ID document"} {"t":{"$date":"2023-07-26T15:27:14.732+08:00"},"s":"I", "c":"REPL", "id":21312, "ctx":"initandlisten","msg":"Did not find local Rollback ID document at startup. Creating one"} {"t":{"$date":"2023-07-26T15:27:14.743+08:00"},"s":"I", "c":"REPL", "id":7360102, "ctx":"initandlisten","msg":"Added oplog entry for create to transaction","attr":{"namespace":"local.$cmd","uuid":{"uuid":{"$uuid":"05c9a786-4c7d-48df-a0ef-a88327cafbfc"}},"object":{"create":"system.rollback.id","idIndex":{"v":2,"key":{"_id":1},"name":"_id_"}}}} {"t":{"$date":"2023-07-26T15:27:14.743+08:00"},"s":"I", "c":"REPL", "id":21531, "ctx":"initandlisten","msg":"Initialized the rollback ID","attr":{"rbid":1}} {"t":{"$date":"2023-07-26T15:27:14.743+08:00"},"s":"I", "c":"REPL", "id":21313, "ctx":"initandlisten","msg":"Did not find local replica set configuration document at startup","attr":{"error":{"code":47,"codeName":"NoMatchingDocument","errmsg":"Did not find replica set configuration document in local.system.replset"}}} {"t":{"$date":"2023-07-26T15:27:14.743+08:00"},"s":"I", "c":"REPL", "id":6015317, "ctx":"initandlisten","msg":"Setting new configuration state","attr":{"newState":"ConfigUninitialized","oldState":"ConfigStartingUp"}} {"t":{"$date":"2023-07-26T15:27:14.753+08:00"},"s":"I", "c":"REPL", "id":7360102, "ctx":"initandlisten","msg":"Added oplog entry for create to transaction","attr":{"namespace":"local.$cmd","uuid":{"uuid":{"$uuid":"4a2c7a68-6c0e-46c9-88d8-18f2cdb4c38f"}},"object":{"create":"system.views","idIndex":{"v":2,"key":{"_id":1},"name":"_id_"}}}}