MongoDB REPL Set Permissions authentication configuration steps

Source: Internet
Author: User
Tags openssl

Replica setAuthority authentication

A keyfile file is to be used for authentication of permissions between nodes.

    1. Mkdir-p/mnt/mongodb/rs/config

    2. Cd/mnt/mongodb/rs/config

    3. OpenSSL rand-base64 741 > Mongodb-keyfile

    4. chmod mongodb-keyfile

official online is a , must be changed to a, if not, will be at the start of the mongodb.log Write permission is too open cause of the start MongoDB failed! (Make sure you've installed OpenSSL here , and if it's not, Yum installs OpenSSL)

Copy the Mongodb-keyfile to each node corresponding to the directory, if before the start of MongoDB, with MONGO into the terminal, First look at that node is the primary node,rs.status (); go to the main node to execute:

    1. Use admin # Select the data you want to certify

    2. Db.adduser (' name ', ' Password ');

Of course, you can also have a self-built library for permission authentication

    1. Use Test1

    2. Db.adduser (' Test ', ' 123456 ');

prompt to add success, all stop, each node executes db.shutdownserver (); Then add the following two lines to the mongod.conf file:

    1. Auth=true

    2. Keyfile=/mnt/mongodb/rs/confile/mongodb-keyfile

All the last reboots!

Enter the main node terminal

Db.runcommand ({getlasterror:1, w:n});

if not n 2 N equals 2 n local.slaves

when specified "W" option, you can also use " Wtimeout " getlasterror can be copied to N ( The command is not timed out by default )

Blocking replication can cause write operations to become noticeably slower, especially if "W" 2 3


MongoDB REPL Set Permissions authentication configuration steps

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.