How to reconfig config server connection setting from shard cluster?












0















I have a mongo cluster which includes



one "mongos"



one "config" (rscfg/a.a.a.a:27019)



two "shard"



Here is the situation, I added a new rs on config server and remove the old one



rs.add("b.b.b.b:27019")


and that's OK , when I look rs config it shows



rscfg/a.a.a.a:27019,b.b.b.b:27019


and than I remove the old machine (because the server needs to be upgraded)



rs.remove("a.a.a.a:27019")


also it's OK. and the production service without any connection issue.



I think the shard cluster connect to the new configdb server successfully.



then, I restarted shard cluster , and something goes wrong.



the shard server log says it cannot connect to "rscfg/c.c.c.c:27019" which is no longer exists.



It's old setting . even I add a.a.a.a:27019 back, doesn't help.....



It connected to a server(c.c.c.c) which is removed long time ago...



I have two questions.



1.How to change the configDB list in shard cluster directly?



2.How to list all configDB which shard cluster "really use"?



I've used db.runCommand("getShardMap")
it shows



"rscfg/b.b.b.b:27019"


and it connect to "rscfg/c.c.c.c:27019" What the hell?????





BTW, I used iptable to walkaround this problem.



iptables -t nat -A OUTPUT -p tcp -d c.c.c.c --dport 27019 -j DNAT --to-destination b.b.b.b:27019









share|improve this question
















bumped to the homepage by Community 5 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 have a mongo cluster which includes



    one "mongos"



    one "config" (rscfg/a.a.a.a:27019)



    two "shard"



    Here is the situation, I added a new rs on config server and remove the old one



    rs.add("b.b.b.b:27019")


    and that's OK , when I look rs config it shows



    rscfg/a.a.a.a:27019,b.b.b.b:27019


    and than I remove the old machine (because the server needs to be upgraded)



    rs.remove("a.a.a.a:27019")


    also it's OK. and the production service without any connection issue.



    I think the shard cluster connect to the new configdb server successfully.



    then, I restarted shard cluster , and something goes wrong.



    the shard server log says it cannot connect to "rscfg/c.c.c.c:27019" which is no longer exists.



    It's old setting . even I add a.a.a.a:27019 back, doesn't help.....



    It connected to a server(c.c.c.c) which is removed long time ago...



    I have two questions.



    1.How to change the configDB list in shard cluster directly?



    2.How to list all configDB which shard cluster "really use"?



    I've used db.runCommand("getShardMap")
    it shows



    "rscfg/b.b.b.b:27019"


    and it connect to "rscfg/c.c.c.c:27019" What the hell?????





    BTW, I used iptable to walkaround this problem.



    iptables -t nat -A OUTPUT -p tcp -d c.c.c.c --dport 27019 -j DNAT --to-destination b.b.b.b:27019









    share|improve this question
















    bumped to the homepage by Community 5 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 have a mongo cluster which includes



      one "mongos"



      one "config" (rscfg/a.a.a.a:27019)



      two "shard"



      Here is the situation, I added a new rs on config server and remove the old one



      rs.add("b.b.b.b:27019")


      and that's OK , when I look rs config it shows



      rscfg/a.a.a.a:27019,b.b.b.b:27019


      and than I remove the old machine (because the server needs to be upgraded)



      rs.remove("a.a.a.a:27019")


      also it's OK. and the production service without any connection issue.



      I think the shard cluster connect to the new configdb server successfully.



      then, I restarted shard cluster , and something goes wrong.



      the shard server log says it cannot connect to "rscfg/c.c.c.c:27019" which is no longer exists.



      It's old setting . even I add a.a.a.a:27019 back, doesn't help.....



      It connected to a server(c.c.c.c) which is removed long time ago...



      I have two questions.



      1.How to change the configDB list in shard cluster directly?



      2.How to list all configDB which shard cluster "really use"?



      I've used db.runCommand("getShardMap")
      it shows



      "rscfg/b.b.b.b:27019"


      and it connect to "rscfg/c.c.c.c:27019" What the hell?????





      BTW, I used iptable to walkaround this problem.



      iptables -t nat -A OUTPUT -p tcp -d c.c.c.c --dport 27019 -j DNAT --to-destination b.b.b.b:27019









      share|improve this question
















      I have a mongo cluster which includes



      one "mongos"



      one "config" (rscfg/a.a.a.a:27019)



      two "shard"



      Here is the situation, I added a new rs on config server and remove the old one



      rs.add("b.b.b.b:27019")


      and that's OK , when I look rs config it shows



      rscfg/a.a.a.a:27019,b.b.b.b:27019


      and than I remove the old machine (because the server needs to be upgraded)



      rs.remove("a.a.a.a:27019")


      also it's OK. and the production service without any connection issue.



      I think the shard cluster connect to the new configdb server successfully.



      then, I restarted shard cluster , and something goes wrong.



      the shard server log says it cannot connect to "rscfg/c.c.c.c:27019" which is no longer exists.



      It's old setting . even I add a.a.a.a:27019 back, doesn't help.....



      It connected to a server(c.c.c.c) which is removed long time ago...



      I have two questions.



      1.How to change the configDB list in shard cluster directly?



      2.How to list all configDB which shard cluster "really use"?



      I've used db.runCommand("getShardMap")
      it shows



      "rscfg/b.b.b.b:27019"


      and it connect to "rscfg/c.c.c.c:27019" What the hell?????





      BTW, I used iptable to walkaround this problem.



      iptables -t nat -A OUTPUT -p tcp -d c.c.c.c --dport 27019 -j DNAT --to-destination b.b.b.b:27019






      sharding mongodb-3.6






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Apr 24 '18 at 4:30









      Md Haidar Ali Khan

      3,62862341




      3,62862341










      asked Apr 24 '18 at 2:28









      Casper LiaoCasper Liao

      11




      11





      bumped to the homepage by Community 5 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 5 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















          How to reconfig config server connection setting from shard cluster?




          As per MongoDB BOL documentation here you shall find the steps to Replace a Config Server.



          Start the replacement config server



          mongod --configsvr --replSet <replicaSetName> --bind_ip localhost,<ip address of the mongod host>


          Add the new config server to the replica set



          rs.add( { host: "<hostnameNew>:<portNew>", priority: 0, votes: 0 } )


          Update the newly added config server’s votes and priority settings



          Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status():



           rs.status()


          Reconfigure the replica set to update the votes and priority of the new member:



          var cfg = rs.conf();

          cfg.members[n].priority = 1; // Substitute the correct array index for the new member
          cfg.members[n].votes = 1; // Substitute the correct array index for the new member

          rs.reconfig(cfg)


          Shut down the member to replace



          If replacing the primary member, step down the primary first before shutting down.



          Remove the member to replace from the config server replica set



          rs.remove("<hostnameOld>:<portOld>")


          If necessary, update mongos configuration or DNS entry



          With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.



          a mongos instance specified the removed member in the --configdb or configDB setting, either:




          • Update the setting for the next time you restart the mongos, or


          • Modify the DNS entry that points to the system that provided the old
            config server, so that the same hostname points to the new config

            server.




          How to change the configDB list in shard cluster directly?




          Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.



          sharding:
          configDB: <configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...



          How to list all configDB which shard cluster "really use"?




          To list the databases that have sharding enabled, query the databases collection in the Config Database. A database has sharding enabled if the value of the partitioned field is true. Connect to a mongos instance with a mongo shell, and run the following operation to get a full list of databases with sharding enabled:



          use config
          db.databases.find( { "partitioned": true } )


          Example



          You can use the following sequence of commands to return a list of all databases in the cluster:



          use config
          db.databases.find()



          { "_id" : "test", "primary" : "shardB", "partitioned" : false }
          { "_id" : "animals", "primary" : "shardA", "partitioned" : true }
          { "_id" : "farms", "primary" : "shardA", "partitioned" : false }


          Then sharding is only enabled for the animals database.






          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%2f204746%2fhow-to-reconfig-config-server-connection-setting-from-shard-cluster%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















            How to reconfig config server connection setting from shard cluster?




            As per MongoDB BOL documentation here you shall find the steps to Replace a Config Server.



            Start the replacement config server



            mongod --configsvr --replSet <replicaSetName> --bind_ip localhost,<ip address of the mongod host>


            Add the new config server to the replica set



            rs.add( { host: "<hostnameNew>:<portNew>", priority: 0, votes: 0 } )


            Update the newly added config server’s votes and priority settings



            Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status():



             rs.status()


            Reconfigure the replica set to update the votes and priority of the new member:



            var cfg = rs.conf();

            cfg.members[n].priority = 1; // Substitute the correct array index for the new member
            cfg.members[n].votes = 1; // Substitute the correct array index for the new member

            rs.reconfig(cfg)


            Shut down the member to replace



            If replacing the primary member, step down the primary first before shutting down.



            Remove the member to replace from the config server replica set



            rs.remove("<hostnameOld>:<portOld>")


            If necessary, update mongos configuration or DNS entry



            With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.



            a mongos instance specified the removed member in the --configdb or configDB setting, either:




            • Update the setting for the next time you restart the mongos, or


            • Modify the DNS entry that points to the system that provided the old
              config server, so that the same hostname points to the new config

              server.




            How to change the configDB list in shard cluster directly?




            Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.



            sharding:
            configDB: <configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...



            How to list all configDB which shard cluster "really use"?




            To list the databases that have sharding enabled, query the databases collection in the Config Database. A database has sharding enabled if the value of the partitioned field is true. Connect to a mongos instance with a mongo shell, and run the following operation to get a full list of databases with sharding enabled:



            use config
            db.databases.find( { "partitioned": true } )


            Example



            You can use the following sequence of commands to return a list of all databases in the cluster:



            use config
            db.databases.find()



            { "_id" : "test", "primary" : "shardB", "partitioned" : false }
            { "_id" : "animals", "primary" : "shardA", "partitioned" : true }
            { "_id" : "farms", "primary" : "shardA", "partitioned" : false }


            Then sharding is only enabled for the animals database.






            share|improve this answer




























              0















              How to reconfig config server connection setting from shard cluster?




              As per MongoDB BOL documentation here you shall find the steps to Replace a Config Server.



              Start the replacement config server



              mongod --configsvr --replSet <replicaSetName> --bind_ip localhost,<ip address of the mongod host>


              Add the new config server to the replica set



              rs.add( { host: "<hostnameNew>:<portNew>", priority: 0, votes: 0 } )


              Update the newly added config server’s votes and priority settings



              Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status():



               rs.status()


              Reconfigure the replica set to update the votes and priority of the new member:



              var cfg = rs.conf();

              cfg.members[n].priority = 1; // Substitute the correct array index for the new member
              cfg.members[n].votes = 1; // Substitute the correct array index for the new member

              rs.reconfig(cfg)


              Shut down the member to replace



              If replacing the primary member, step down the primary first before shutting down.



              Remove the member to replace from the config server replica set



              rs.remove("<hostnameOld>:<portOld>")


              If necessary, update mongos configuration or DNS entry



              With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.



              a mongos instance specified the removed member in the --configdb or configDB setting, either:




              • Update the setting for the next time you restart the mongos, or


              • Modify the DNS entry that points to the system that provided the old
                config server, so that the same hostname points to the new config

                server.




              How to change the configDB list in shard cluster directly?




              Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.



              sharding:
              configDB: <configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...



              How to list all configDB which shard cluster "really use"?




              To list the databases that have sharding enabled, query the databases collection in the Config Database. A database has sharding enabled if the value of the partitioned field is true. Connect to a mongos instance with a mongo shell, and run the following operation to get a full list of databases with sharding enabled:



              use config
              db.databases.find( { "partitioned": true } )


              Example



              You can use the following sequence of commands to return a list of all databases in the cluster:



              use config
              db.databases.find()



              { "_id" : "test", "primary" : "shardB", "partitioned" : false }
              { "_id" : "animals", "primary" : "shardA", "partitioned" : true }
              { "_id" : "farms", "primary" : "shardA", "partitioned" : false }


              Then sharding is only enabled for the animals database.






              share|improve this answer


























                0












                0








                0








                How to reconfig config server connection setting from shard cluster?




                As per MongoDB BOL documentation here you shall find the steps to Replace a Config Server.



                Start the replacement config server



                mongod --configsvr --replSet <replicaSetName> --bind_ip localhost,<ip address of the mongod host>


                Add the new config server to the replica set



                rs.add( { host: "<hostnameNew>:<portNew>", priority: 0, votes: 0 } )


                Update the newly added config server’s votes and priority settings



                Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status():



                 rs.status()


                Reconfigure the replica set to update the votes and priority of the new member:



                var cfg = rs.conf();

                cfg.members[n].priority = 1; // Substitute the correct array index for the new member
                cfg.members[n].votes = 1; // Substitute the correct array index for the new member

                rs.reconfig(cfg)


                Shut down the member to replace



                If replacing the primary member, step down the primary first before shutting down.



                Remove the member to replace from the config server replica set



                rs.remove("<hostnameOld>:<portOld>")


                If necessary, update mongos configuration or DNS entry



                With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.



                a mongos instance specified the removed member in the --configdb or configDB setting, either:




                • Update the setting for the next time you restart the mongos, or


                • Modify the DNS entry that points to the system that provided the old
                  config server, so that the same hostname points to the new config

                  server.




                How to change the configDB list in shard cluster directly?




                Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.



                sharding:
                configDB: <configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...



                How to list all configDB which shard cluster "really use"?




                To list the databases that have sharding enabled, query the databases collection in the Config Database. A database has sharding enabled if the value of the partitioned field is true. Connect to a mongos instance with a mongo shell, and run the following operation to get a full list of databases with sharding enabled:



                use config
                db.databases.find( { "partitioned": true } )


                Example



                You can use the following sequence of commands to return a list of all databases in the cluster:



                use config
                db.databases.find()



                { "_id" : "test", "primary" : "shardB", "partitioned" : false }
                { "_id" : "animals", "primary" : "shardA", "partitioned" : true }
                { "_id" : "farms", "primary" : "shardA", "partitioned" : false }


                Then sharding is only enabled for the animals database.






                share|improve this answer














                How to reconfig config server connection setting from shard cluster?




                As per MongoDB BOL documentation here you shall find the steps to Replace a Config Server.



                Start the replacement config server



                mongod --configsvr --replSet <replicaSetName> --bind_ip localhost,<ip address of the mongod host>


                Add the new config server to the replica set



                rs.add( { host: "<hostnameNew>:<portNew>", priority: 0, votes: 0 } )


                Update the newly added config server’s votes and priority settings



                Ensure that the new member has reached SECONDARY state. To check the state of the replica set members, run rs.status():



                 rs.status()


                Reconfigure the replica set to update the votes and priority of the new member:



                var cfg = rs.conf();

                cfg.members[n].priority = 1; // Substitute the correct array index for the new member
                cfg.members[n].votes = 1; // Substitute the correct array index for the new member

                rs.reconfig(cfg)


                Shut down the member to replace



                If replacing the primary member, step down the primary first before shutting down.



                Remove the member to replace from the config server replica set



                rs.remove("<hostnameOld>:<portOld>")


                If necessary, update mongos configuration or DNS entry



                With replica set config servers, the mongos instances specify in the --configdb or sharding.configDB setting the config server replica set name and at least one of the replica set members.



                a mongos instance specified the removed member in the --configdb or configDB setting, either:




                • Update the setting for the next time you restart the mongos, or


                • Modify the DNS entry that points to the system that provided the old
                  config server, so that the same hostname points to the new config

                  server.




                How to change the configDB list in shard cluster directly?




                Specify the config server replica set name and the hostname and port of at least one of the members of the config server replica set.



                sharding:
                configDB: <configReplSetName>/cfg1.example.net:27017, cfg2.example.net:27017,...



                How to list all configDB which shard cluster "really use"?




                To list the databases that have sharding enabled, query the databases collection in the Config Database. A database has sharding enabled if the value of the partitioned field is true. Connect to a mongos instance with a mongo shell, and run the following operation to get a full list of databases with sharding enabled:



                use config
                db.databases.find( { "partitioned": true } )


                Example



                You can use the following sequence of commands to return a list of all databases in the cluster:



                use config
                db.databases.find()



                { "_id" : "test", "primary" : "shardB", "partitioned" : false }
                { "_id" : "animals", "primary" : "shardA", "partitioned" : true }
                { "_id" : "farms", "primary" : "shardA", "partitioned" : false }


                Then sharding is only enabled for the animals database.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Apr 24 '18 at 8:13









                Md Haidar Ali KhanMd Haidar Ali Khan

                3,62862341




                3,62862341






























                    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%2f204746%2fhow-to-reconfig-config-server-connection-setting-from-shard-cluster%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

                    Liste der Baudenkmale in Friedland (Mecklenburg)

                    Single-Malt-Whisky

                    Czorneboh