[CSHARP-1808] RunCommand against a --replset Connection Created: 24/Oct/16 Updated: 05/Apr/19 Resolved: 22/Jan/18 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | Operations |
| Affects Version/s: | 2.3 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Minor - P4 |
| Reporter: | Hu | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | question | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
When I create a mongod with --replset option,the admin database will not create. |
| Comments |
| Comment by Robert Stam [ 22/Jan/18 ] | |||
|
You can run any command you want against the admin database like this:
We won't be adding helper methods for things initiating a replica set because so few applications would use that and we don't want to expand the surface area of the API unnecessarily, and there is already a way to that (or run any command) using RunCommand. | |||
| Comment by Hu [ 25/Oct/16 ] | |||
|
Not only replset but also sharding command is needed. | |||
| Comment by Hu [ 25/Oct/16 ] | |||
|
Thank you for your reply. C# drive has a method db.runCommand,but some method must run as admin. | |||
| Comment by Robert Stam [ 24/Oct/16 ] | |||
|
If you're going to connect to replica set member directly before the replica set has been initiated you need to use a direct connection. Use a connection string similar to the following:
Once the replica set has been initiated you normally would no longer use direct connections. |