<!-- 
RSS generated by JIRA (9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66) at Thu Feb 08 08:52:30 UTC 2024

It is possible to restrict the fields that are returned in this document by specifying the 'field' parameter in your request.
For example, to request only the issue key and summary append 'field=key&field=summary' to the URL of your request.
-->
<rss version="0.92" >
<channel>
    <title>MongoDB Jira</title>
    <link>https://jira.mongodb.org</link>
    <description>This file is an XML representation of an issue</description>
    <language>en-us</language>    <build-info>
        <version>9.7.1</version>
        <build-number>970001</build-number>
        <build-date>13-04-2023</build-date>
    </build-info>


<item>
            <title>[JAVA-523] Can&apos;t get serverStatus from a mongod server in sharded cluster with authentication enabled</title>
                <link>https://jira.mongodb.org/browse/JAVA-523</link>
                <project id="10006" key="JAVA">Java Driver</project>
                    <description>&lt;p&gt; I set up a sharded cluster with every mongod process started with &quot;--keyFile&quot; option.&lt;/p&gt;

&lt;p&gt;mongos:                        port 27017&lt;br/&gt;
config:                        port 27019&lt;br/&gt;
mongod:    shard1  primary     port 27200&lt;br/&gt;
mongod:    shard1  secondary   port 27201&lt;br/&gt;
mongod:    shard2  primary     port 27202&lt;br/&gt;
mongod:    shard2  secondary   port 27203&lt;/p&gt;

&lt;p&gt;then, I found I can&apos;t connect to mongod and get the serverStatus via java-driver.&lt;/p&gt;

&lt;p&gt;my code is like this:&lt;/p&gt;

&lt;p&gt;Mongo mongo = new Mongo(&quot;localhost&quot;, 27200);&lt;br/&gt;
DB testDB = mongo.getDB(&quot;test&quot;);&lt;br/&gt;
CommandResult resp = testDB.command(&quot;serverStatus&quot;);&lt;br/&gt;
System.out.println(resp);&lt;/p&gt;

&lt;p&gt;the result is :&lt;/p&gt;

{ &quot;serverUsed&quot; : &quot;localhost:27200&quot; , &quot;errmsg&quot; : &quot;need to login&quot; , &quot;ok&quot; : 0.0}


&lt;p&gt;but if I run &apos;mongo&apos; in my console to connect to localhost:27200, I can get the serverStatus result without authentication.&lt;/p&gt;</description>
                <environment>Mac OS 10.7.3&lt;br/&gt;
mongodb 2.0.2&lt;br/&gt;
java-driver 2.7.3</environment>
        <key id="30766">JAVA-523</key>
            <summary>Can&apos;t get serverStatus from a mongod server in sharded cluster with authentication enabled</summary>
                <type id="1" iconUrl="https://jira.mongodb.org/secure/viewavatar?size=xsmall&amp;avatarId=14703&amp;avatarType=issuetype">Bug</type>
                                            <priority id="3" iconUrl="https://jira.mongodb.org/images/icons/priorities/major.svg">Major - P3</priority>
                        <status id="6" iconUrl="https://jira.mongodb.org/images/icons/statuses/closed.png" description="The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.">Closed</status>
                    <statusCategory id="3" key="done" colorName="success"/>
                                    <resolution id="9">Done</resolution>
                                        <assignee username="jeff.yemin@mongodb.com">Jeffrey Yemin</assignee>
                                    <reporter username="tianyi">Yi Tian</reporter>
                        <labels>
                            <label>authentication</label>
                            <label>cluster</label>
                            <label>sharding</label>
                    </labels>
                <created>Thu, 16 Feb 2012 02:26:22 +0000</created>
                <updated>Wed, 7 Mar 2012 13:03:04 +0000</updated>
                            <resolved>Thu, 1 Mar 2012 02:31:54 +0000</resolved>
                                    <version>2.7.3</version>
                                                    <component>Cluster Management</component>
                                        <votes>0</votes>
                                    <watches>0</watches>
                                                                                                                <comments>
                            <comment id="94014" author="tianyi" created="Thu, 1 Mar 2012 02:23:57 +0000"  >&lt;p&gt;Sorry, I make a mistake, I forgot to set test database sharding enabled and create user in test database.&lt;br/&gt;
Please close this issue, and sorry for wasting your time.&lt;/p&gt;</comment>
                            <comment id="93239" author="tianyi" created="Tue, 28 Feb 2012 06:39:43 +0000"  >&lt;p&gt;Here is how to reproduce this issue.&lt;br/&gt;
First, set up the cluster with authentication disabled.(set up data and log folder first)&lt;br/&gt;
~/mongodb/bin/mongod --shardsvr --replSet shard1 --dbpath ~/mongodb/data/shard11 --oplogSize 100 --logpath ~/mongodb/log/mongod11.log --logappend --fork --port 27200&lt;br/&gt;
~/mongodb/bin/mongod --shardsvr --replSet shard1 --dbpath ~/mongodb/data/shard12 --oplogSize 100 --logpath ~/mongodb/log/mongod12.log --logappend --fork --port 27201&lt;br/&gt;
~/mongodb/bin/mongod --shardsvr --replSet shard2 --dbpath ~/mongodb/data/shard21 --oplogSize 100 --logpath ~/mongodb/log/mongod21.log --logappend --fork --port 27202&lt;br/&gt;
~/mongodb/bin/mongod --shardsvr --replSet shard2 --dbpath ~/mongodb/data/shard22 --oplogSize 100 --logpath ~/mongodb/log/mongod22.log --logappend --fork --port 27203&lt;br/&gt;
~/mongodb/bin/mongod --configsvr --dbpath ~/mongodb/data/config --logpath ~/mongodb/log/config.log --logappend --fork&lt;br/&gt;
sleep 15&lt;br/&gt;
~/mongodb/bin/mongo localhost:27200 --quiet --eval &quot;printjson(config={_id:&apos;shard1&apos;,members:&lt;span class=&quot;error&quot;&gt;&amp;#91;{_id:0,host:&amp;#39;localhost:27200&amp;#39;},{_id: 1, host:&amp;#39;localhost:27201&amp;#39;}&amp;#93;&lt;/span&gt;});printjson(rs.initiate(config));&quot; &lt;br/&gt;
~/mongodb/bin/mongo localhost:27202 --quiet --eval &quot;printjson(config={_id:&apos;shard2&apos;,members:&lt;span class=&quot;error&quot;&gt;&amp;#91;{_id:0,host:&amp;#39;localhost:27202&amp;#39;},{_id: 1, host:&amp;#39;localhost:27203&amp;#39;}&amp;#93;&lt;/span&gt;});printjson(rs.initiate(config));&quot; &lt;br/&gt;
sleep 15&lt;br/&gt;
~/mongodb/bin/mongos --configdb localhost:27019 --logpath ~/mongodb/log/mongos.log --logappend --fork&lt;br/&gt;
sleep 15&lt;br/&gt;
~/mongodb/bin/mongo localhost:27017/admin --eval &quot;printjson(db.runCommand(&lt;/p&gt;
{addshard:\&quot;shard1/localhost:27200,localhost:27201\&quot;,name:\&quot;s1\&quot;}
&lt;p&gt;))&quot;&lt;br/&gt;
~/mongodb/bin/mongo localhost:27017/admin --eval &quot;printjson(db.runCommand(&lt;/p&gt;
{addshard:\&quot;shard2/localhost:27202,localhost:27203\&quot;,name:\&quot;s2\&quot;}
&lt;p&gt;))&quot;&lt;br/&gt;
~/mongodb/bin/mongo localhost:27017/admin --eval &quot;printjson(db.addUser(\&quot;admin\&quot;,\&quot;admin\&quot;))&quot;&lt;/p&gt;

&lt;p&gt;Secondly, stop all processes, and restart them with authentication enabled.&lt;/p&gt;


&lt;p&gt;~/mongodb/bin/mongod --keyFile ~/mongodb/bin/key --shardsvr --replSet shard1 --dbpath ~/mongodb/data/shard11 --oplogSize 100 --logpath ~/mongodb/log/mongod11.log --logappend --fork --port 27200&lt;br/&gt;
~/mongodb/bin/mongod --keyFile ~/mongodb/bin/key --shardsvr --replSet shard1 --dbpath ~/mongodb/data/shard12 --oplogSize 100 --logpath ~/mongodb/log/mongod12.log --logappend --fork --port 27201&lt;br/&gt;
~/mongodb/bin/mongod --keyFile ~/mongodb/bin/key --shardsvr --replSet shard2 --dbpath ~/mongodb/data/shard21 --oplogSize 100 --logpath ~/mongodb/log/mongod21.log --logappend --fork --port 27202&lt;br/&gt;
~/mongodb/bin/mongod --keyFile ~/mongodb/bin/key --shardsvr --replSet shard2 --dbpath ~/mongodb/data/shard22 --oplogSize 100 --logpath ~/mongodb/log/mongod22.log --logappend --fork --port 27203&lt;br/&gt;
~/mongodb/bin/mongod --keyFile ~/mongodb/bin/key --configsvr --dbpath ~/mongodb/data/config --logpath ~/mongodb/log/config.log --logappend --fork&lt;br/&gt;
sleep 15&lt;br/&gt;
~/mongodb/bin/mongos --keyFile ~/mongodb/bin/key --configdb localhost:27019 --logpath ~/mongodb/log/mongos.log --logappend --fork&lt;/p&gt;

&lt;p&gt;Then run the java code i mentioned. you will get &lt;/p&gt;
{ &quot;serverUsed&quot; : &quot;localhost:27200&quot; , &quot;errmsg&quot; : &quot;need to login&quot; , &quot;ok&quot; : 0.0}

&lt;p&gt;but when you excute &quot;mongo localhost:27200 --eval &apos;printjson(db.serverStatus())&apos;&quot; in your console, you will get the correct result.&lt;/p&gt;

&lt;p&gt;Finally, Here is the result you asked:&lt;br/&gt;
dentakeshimatoMacBook-Pro:bin tianyi$ ./mongo localhost:27200&lt;br/&gt;
MongoDB shell version: 2.0.2&lt;br/&gt;
connecting to: localhost:27200/test&lt;br/&gt;
PRIMARY&amp;gt; db.isMaster()&lt;br/&gt;
{&lt;br/&gt;
	&quot;setName&quot; : &quot;shard1&quot;,&lt;br/&gt;
	&quot;ismaster&quot; : true,&lt;br/&gt;
	&quot;secondary&quot; : false,&lt;br/&gt;
	&quot;hosts&quot; : [&lt;br/&gt;
		&quot;localhost:27200&quot;,&lt;br/&gt;
		&quot;localhost:27201&quot;&lt;br/&gt;
	],&lt;br/&gt;
	&quot;primary&quot; : &quot;localhost:27200&quot;,&lt;br/&gt;
	&quot;me&quot; : &quot;localhost:27200&quot;,&lt;br/&gt;
	&quot;maxBsonObjectSize&quot; : 16777216,&lt;br/&gt;
	&quot;ok&quot; : 1&lt;br/&gt;
}&lt;br/&gt;
PRIMARY&amp;gt; db.adminCommand(&quot;getCmdLineOpts&quot;)&lt;br/&gt;
{&lt;br/&gt;
	&quot;argv&quot; : [&lt;br/&gt;
		&quot;/Users/tianyi/mongodb/bin/mongod&quot;,&lt;br/&gt;
		&quot;--keyFile&quot;,&lt;br/&gt;
		&quot;/Users/tianyi/mongodb/bin/key&quot;,&lt;br/&gt;
		&quot;--shardsvr&quot;,&lt;br/&gt;
		&quot;--replSet&quot;,&lt;br/&gt;
		&quot;shard1&quot;,&lt;br/&gt;
		&quot;--dbpath&quot;,&lt;br/&gt;
		&quot;/Users/tianyi/mongodb/data/shard11&quot;,&lt;br/&gt;
		&quot;--oplogSize&quot;,&lt;br/&gt;
		&quot;100&quot;,&lt;br/&gt;
		&quot;--logpath&quot;,&lt;br/&gt;
		&quot;/Users/tianyi/mongodb/log/mongod11.log&quot;,&lt;br/&gt;
		&quot;--logappend&quot;,&lt;br/&gt;
		&quot;--fork&quot;,&lt;br/&gt;
		&quot;--port&quot;,&lt;br/&gt;
		&quot;27200&quot;&lt;br/&gt;
	],&lt;br/&gt;
	&quot;parsed&quot; : &lt;/p&gt;
{
		&quot;dbpath&quot; : &quot;/Users/tianyi/mongodb/data/shard11&quot;,
		&quot;fork&quot; : true,
		&quot;keyFile&quot; : &quot;/Users/tianyi/mongodb/bin/key&quot;,
		&quot;logappend&quot; : true,
		&quot;logpath&quot; : &quot;/Users/tianyi/mongodb/log/mongod11.log&quot;,
		&quot;oplogSize&quot; : 100,
		&quot;port&quot; : 27200,
		&quot;replSet&quot; : &quot;shard1&quot;,
		&quot;shardsvr&quot; : true
	}
&lt;p&gt;,&lt;br/&gt;
	&quot;ok&quot; : 1&lt;br/&gt;
}&lt;/p&gt;</comment>
                            <comment id="92905" author="scotthernandez" created="Mon, 27 Feb 2012 17:22:37 +0000"  >&lt;p&gt;This doesn&apos;t sound correct; I can&apos;t reproduce this. Can you run db.isMaster() and db.adminCommand(&quot;getCmdLineOpts&quot;) on the primary?&lt;/p&gt;</comment>
                    </comments>
                    <attachments>
                    </attachments>
                <subtasks>
                    </subtasks>
                <customfields>
                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_15850" key="com.atlassian.jira.plugins.jira-development-integration-plugin:devsummary">
                        <customfieldname>Development</customfieldname>
                        <customfieldvalues>
                            
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    <customfield id="customfield_12550" key="com.pyxis.greenhopper.jira:gh-lexo-rank">
                        <customfieldname>Rank</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>2|hrhbbj:</customfieldvalue>

                        </customfieldvalues>
                    </customfield>
                                                                <customfield id="customfield_10558" key="com.pyxis.greenhopper.jira:gh-global-rank">
                        <customfieldname>Rank (Obsolete)</customfieldname>
                        <customfieldvalues>
                            <customfieldvalue>14634</customfieldvalue>
                        </customfieldvalues>
                    </customfield>
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            </customfields>
    </item>
</channel>
</rss>