An error occurred while adding users to Mongodb cluster startup with security authentication

Source: Internet
Author: User
Tags mongodb

After use admin. When you add the user db. addUser ("admin", "123456"), because other nodes do not have the admin user and use the-keyFile parameter, permission authentication is required. The first time a user cannot be created.

Symptoms:

The code is as follows: Copy code

Switched to db admin
{
"User": "admin ",
"ReadOnly": false,
"Pwd": "dfb2b4f665d248c6887cfba7b1f0c9fc ",
"_ Id": ObjectId ("50b41bb41e7bf4084c43a793 ")
}
Tue Nov 27 09:47:32 uncaught exception: couldn't add user: SyncClusterConnection: insert prepare failed: 10.200.7.106: 10021: {errmsg: "need to login", OK: 0.0} 10.200.7.221: 10021: {errmsg: "need to login", OK: 0.0} 10.200.7.226: 10021: {errmsg: "need to login", OK: 0.0}

 

Solution.Do not add the-keyFile parameter during the first startup. Create an admin user after startup. Then stop all nodes.

Add the-keyFile parameter. Restart the cluster. You can.

The code is as follows: Copy code

. /Bin/mongod-shardsvr-replSet shard1-port 10020-dbpath data/shard1a-keyFile/data/support/mongodb-2.2.1/primary key-oplogSize 100-logpath logs/shard1a. log-logappend-fork-rest -- nojournal

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.