Skip to content

Instantly share code, notes, and snippets.

@phainamikaze
Created June 12, 2020 11:33
Show Gist options
  • Save phainamikaze/e2f5d5dbde1f999b5733baacd75467f6 to your computer and use it in GitHub Desktop.
Save phainamikaze/e2f5d5dbde1f999b5733baacd75467f6 to your computer and use it in GitHub Desktop.
mongodb replica
openssl rand -base64 741 > mongodb-keyfile
rs.initiate(
{
_id : "rs0",
members: [
{ _id : 0, host : "acs-server-9:27018" },
{ _id : 1, host : "acs-server-9:27019" }
]
}
)
rs.status()
use admin
db.createUser(
{
user: "admin",
pwd: "xxx",
roles: [ { role: "userAdminAnyDatabase", db: "admin" }, "readWriteAnyDatabase" ]
}
)
db.createUser( {
user: "root",
pwd: "xxx",
roles: [ { role: "root", db: "admin" } ]
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment