How to configure mongodb replicaset of 3 nodes in authentication mode












0















I had configured a mongodb replicaSet of 3 nodes. It was running fine But WHen i created a adminUser and dbuser on primary node and enabled the authorization in mongodb.conf file of all nodes then they are not connecting. Below is the output of rs.status() after enabling authorization. Kindly Help.



{
"set" : "replset1",
"date" : ISODate("2017-07-15T04:09:41.796Z"),
"myState" : 3,
"term" : NumberLong(1),
"heartbeatIntervalMillis" : NumberLong(2000),
"members" : [
{
"_id" : 1,
"name" : "10.10.8.1:27017",
"health" : 1,
"state" : 3,
"stateStr" : "RECOVERING",
"uptime" : 54841,
"optime" : {
"ts" : Timestamp(1500033801, 1),
"t" : NumberLong(1)
},
"optimeDate" : ISODate("2017-07-14T12:03:21Z"),
"infoMessage" : "could not find member to sync from",
"configVersion" : 1,
"self" : true
},
{
"_id" : 2,
"name" : "10.10.8.2:27017",
"health" : 0,
"state" : 6,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2017-07-15T04:09:37.008Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"authenticated" : false,
"configVersion" : -1
},
{
"_id" : 3,
"name" : "10.10.8.3:27017",
"health" : 0,
"state" : 6,
"stateStr" : "(not reachable/healthy)",
"uptime" : 0,
"optime" : {
"ts" : Timestamp(0, 0),
"t" : NumberLong(-1)
},
"optimeDate" : ISODate("1970-01-01T00:00:00Z"),
"lastHeartbeat" : ISODate("2017-07-15T04:09:37.136Z"),
"lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
"pingMs" : NumberLong(0),
"authenticated" : false,
"configVersion" : -1
}
],
"ok" : 1
}









share|improve this question
















bumped to the homepage by Community 11 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.




















    0















    I had configured a mongodb replicaSet of 3 nodes. It was running fine But WHen i created a adminUser and dbuser on primary node and enabled the authorization in mongodb.conf file of all nodes then they are not connecting. Below is the output of rs.status() after enabling authorization. Kindly Help.



    {
    "set" : "replset1",
    "date" : ISODate("2017-07-15T04:09:41.796Z"),
    "myState" : 3,
    "term" : NumberLong(1),
    "heartbeatIntervalMillis" : NumberLong(2000),
    "members" : [
    {
    "_id" : 1,
    "name" : "10.10.8.1:27017",
    "health" : 1,
    "state" : 3,
    "stateStr" : "RECOVERING",
    "uptime" : 54841,
    "optime" : {
    "ts" : Timestamp(1500033801, 1),
    "t" : NumberLong(1)
    },
    "optimeDate" : ISODate("2017-07-14T12:03:21Z"),
    "infoMessage" : "could not find member to sync from",
    "configVersion" : 1,
    "self" : true
    },
    {
    "_id" : 2,
    "name" : "10.10.8.2:27017",
    "health" : 0,
    "state" : 6,
    "stateStr" : "(not reachable/healthy)",
    "uptime" : 0,
    "optime" : {
    "ts" : Timestamp(0, 0),
    "t" : NumberLong(-1)
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "lastHeartbeat" : ISODate("2017-07-15T04:09:37.008Z"),
    "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
    "pingMs" : NumberLong(0),
    "authenticated" : false,
    "configVersion" : -1
    },
    {
    "_id" : 3,
    "name" : "10.10.8.3:27017",
    "health" : 0,
    "state" : 6,
    "stateStr" : "(not reachable/healthy)",
    "uptime" : 0,
    "optime" : {
    "ts" : Timestamp(0, 0),
    "t" : NumberLong(-1)
    },
    "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
    "lastHeartbeat" : ISODate("2017-07-15T04:09:37.136Z"),
    "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
    "pingMs" : NumberLong(0),
    "authenticated" : false,
    "configVersion" : -1
    }
    ],
    "ok" : 1
    }









    share|improve this question
















    bumped to the homepage by Community 11 mins ago


    This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.


















      0












      0








      0








      I had configured a mongodb replicaSet of 3 nodes. It was running fine But WHen i created a adminUser and dbuser on primary node and enabled the authorization in mongodb.conf file of all nodes then they are not connecting. Below is the output of rs.status() after enabling authorization. Kindly Help.



      {
      "set" : "replset1",
      "date" : ISODate("2017-07-15T04:09:41.796Z"),
      "myState" : 3,
      "term" : NumberLong(1),
      "heartbeatIntervalMillis" : NumberLong(2000),
      "members" : [
      {
      "_id" : 1,
      "name" : "10.10.8.1:27017",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 54841,
      "optime" : {
      "ts" : Timestamp(1500033801, 1),
      "t" : NumberLong(1)
      },
      "optimeDate" : ISODate("2017-07-14T12:03:21Z"),
      "infoMessage" : "could not find member to sync from",
      "configVersion" : 1,
      "self" : true
      },
      {
      "_id" : 2,
      "name" : "10.10.8.2:27017",
      "health" : 0,
      "state" : 6,
      "stateStr" : "(not reachable/healthy)",
      "uptime" : 0,
      "optime" : {
      "ts" : Timestamp(0, 0),
      "t" : NumberLong(-1)
      },
      "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      "lastHeartbeat" : ISODate("2017-07-15T04:09:37.008Z"),
      "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
      "pingMs" : NumberLong(0),
      "authenticated" : false,
      "configVersion" : -1
      },
      {
      "_id" : 3,
      "name" : "10.10.8.3:27017",
      "health" : 0,
      "state" : 6,
      "stateStr" : "(not reachable/healthy)",
      "uptime" : 0,
      "optime" : {
      "ts" : Timestamp(0, 0),
      "t" : NumberLong(-1)
      },
      "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      "lastHeartbeat" : ISODate("2017-07-15T04:09:37.136Z"),
      "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
      "pingMs" : NumberLong(0),
      "authenticated" : false,
      "configVersion" : -1
      }
      ],
      "ok" : 1
      }









      share|improve this question
















      I had configured a mongodb replicaSet of 3 nodes. It was running fine But WHen i created a adminUser and dbuser on primary node and enabled the authorization in mongodb.conf file of all nodes then they are not connecting. Below is the output of rs.status() after enabling authorization. Kindly Help.



      {
      "set" : "replset1",
      "date" : ISODate("2017-07-15T04:09:41.796Z"),
      "myState" : 3,
      "term" : NumberLong(1),
      "heartbeatIntervalMillis" : NumberLong(2000),
      "members" : [
      {
      "_id" : 1,
      "name" : "10.10.8.1:27017",
      "health" : 1,
      "state" : 3,
      "stateStr" : "RECOVERING",
      "uptime" : 54841,
      "optime" : {
      "ts" : Timestamp(1500033801, 1),
      "t" : NumberLong(1)
      },
      "optimeDate" : ISODate("2017-07-14T12:03:21Z"),
      "infoMessage" : "could not find member to sync from",
      "configVersion" : 1,
      "self" : true
      },
      {
      "_id" : 2,
      "name" : "10.10.8.2:27017",
      "health" : 0,
      "state" : 6,
      "stateStr" : "(not reachable/healthy)",
      "uptime" : 0,
      "optime" : {
      "ts" : Timestamp(0, 0),
      "t" : NumberLong(-1)
      },
      "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      "lastHeartbeat" : ISODate("2017-07-15T04:09:37.008Z"),
      "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
      "pingMs" : NumberLong(0),
      "authenticated" : false,
      "configVersion" : -1
      },
      {
      "_id" : 3,
      "name" : "10.10.8.3:27017",
      "health" : 0,
      "state" : 6,
      "stateStr" : "(not reachable/healthy)",
      "uptime" : 0,
      "optime" : {
      "ts" : Timestamp(0, 0),
      "t" : NumberLong(-1)
      },
      "optimeDate" : ISODate("1970-01-01T00:00:00Z"),
      "lastHeartbeat" : ISODate("2017-07-15T04:09:37.136Z"),
      "lastHeartbeatRecv" : ISODate("1970-01-01T00:00:00Z"),
      "pingMs" : NumberLong(0),
      "authenticated" : false,
      "configVersion" : -1
      }
      ],
      "ok" : 1
      }






      replication mongodb errors






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 15 '17 at 8:17









      joanolo

      9,65842051




      9,65842051










      asked Jul 15 '17 at 5:03









      Vijay GargVijay Garg

      1




      1





      bumped to the homepage by Community 11 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







      bumped to the homepage by Community 11 mins ago


      This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          You made things in wrong order.
          At start you have "open" replica set. You put authorization on and you have so called "localhost exception" what means that you (still) can connect primary directly without authorization. On that connection you MUST first create "root" (super user) user



          use admin
          db.createUser(
          {
          user: "root",
          pwd: "toor",
          roles: [ "root" ]
          })


          Now, your "localhost exception" is gone! You must authenticate your self. You can logout and then login again OR just give command



          db.auth("root","toor")



          And start creating other (normal) users.






          share|improve this answer























            Your Answer








            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "182"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: false,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f179902%2fhow-to-configure-mongodb-replicaset-of-3-nodes-in-authentication-mode%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            You made things in wrong order.
            At start you have "open" replica set. You put authorization on and you have so called "localhost exception" what means that you (still) can connect primary directly without authorization. On that connection you MUST first create "root" (super user) user



            use admin
            db.createUser(
            {
            user: "root",
            pwd: "toor",
            roles: [ "root" ]
            })


            Now, your "localhost exception" is gone! You must authenticate your self. You can logout and then login again OR just give command



            db.auth("root","toor")



            And start creating other (normal) users.






            share|improve this answer




























              0














              You made things in wrong order.
              At start you have "open" replica set. You put authorization on and you have so called "localhost exception" what means that you (still) can connect primary directly without authorization. On that connection you MUST first create "root" (super user) user



              use admin
              db.createUser(
              {
              user: "root",
              pwd: "toor",
              roles: [ "root" ]
              })


              Now, your "localhost exception" is gone! You must authenticate your self. You can logout and then login again OR just give command



              db.auth("root","toor")



              And start creating other (normal) users.






              share|improve this answer


























                0












                0








                0







                You made things in wrong order.
                At start you have "open" replica set. You put authorization on and you have so called "localhost exception" what means that you (still) can connect primary directly without authorization. On that connection you MUST first create "root" (super user) user



                use admin
                db.createUser(
                {
                user: "root",
                pwd: "toor",
                roles: [ "root" ]
                })


                Now, your "localhost exception" is gone! You must authenticate your self. You can logout and then login again OR just give command



                db.auth("root","toor")



                And start creating other (normal) users.






                share|improve this answer













                You made things in wrong order.
                At start you have "open" replica set. You put authorization on and you have so called "localhost exception" what means that you (still) can connect primary directly without authorization. On that connection you MUST first create "root" (super user) user



                use admin
                db.createUser(
                {
                user: "root",
                pwd: "toor",
                roles: [ "root" ]
                })


                Now, your "localhost exception" is gone! You must authenticate your self. You can logout and then login again OR just give command



                db.auth("root","toor")



                And start creating other (normal) users.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 15 '17 at 7:11









                JJussiJJussi

                3,0441314




                3,0441314






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Database Administrators Stack Exchange!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f179902%2fhow-to-configure-mongodb-replicaset-of-3-nodes-in-authentication-mode%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    SQL Server 17 - Attemping to backup to remote NAS but Access is denied

                    Always On Availability groups resolving state after failover - Remote harden of transaction...

                    Restoring from pg_dump with foreign key constraints