Skip to content

Instantly share code, notes, and snippets.

@freyes
Created September 27, 2017 12:04
Show Gist options
  • Select an option

  • Save freyes/d62db77be1b9fff3ef5f3b91bcd18474 to your computer and use it in GitHub Desktop.

Select an option

Save freyes/d62db77be1b9fff3ef5f3b91bcd18474 to your computer and use it in GitHub Desktop.
reconfigure mongodb to a single node
> rs.status()
{
"startupStatus" : 1,
"ok" : 0,
"errmsg" : "loading local.system.replset config (LOADINGCONFIG)"
}
> rs.config()
{
"_id" : "juju",
"version" : 109633,
"members" : [
{
"_id" : 0,
"host" : "192.168.1.10:37017"
},
{
"_id" : 1,
"host" : "192.168.1.11:37017"
}
]
}
> var cfg = rs.config()
> cfg.members = [{"_id" : 3, "host" : "192.168.1.11:37017"}]
[ { "_id" : 3, "host" : "192.168.1.11:37017" } ]
> rs.reconfig(cfg , {force : true})
{
"msg" : "will try this config momentarily, try running rs.conf() again in a few seconds",
"ok" : 1
}
> rs.conf()
{
"_id" : "juju",
"version" : 109633,
"members" : [
{
"_id" : 3,
"host" : "192.168.1.11:37017"
}
]
}
$ sudo service juju-db restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment