[MongoDB]: shutdown script

[root@dbversity bin]$ cat shutdown_script.sh
#!/bin/bash
BIN=/tmp/mongodb/bin
DB=admin
HOST=`hostname`
UN=adm
PW=pwd
#PW=`cat /root/.pwd.txt`
cd $BIN

MONGOPID=`ps -ef | egrep ‘mongod|mongos’ | grep -v egrep | awk ‘{print $2}’`

if [ -z $MONGOPID ];
then echo “There are no Mongo processes are running, shutdown script has nothing to do now”;
exit;
fi

####################### To stop Router Services #################################################################

for i in `ps -ef | grep ‘mongos’ | grep -v grep | awk ‘{print $2}’`;
do
kill -9 $i;
echo “Router service with PID $i has been stopped”;
done

#### Identifying the Primary, Secondary, Config & Arbiter service port numbers #####

port=`ps -ef | grep ‘shardsvr’ | grep -v grep | awk -F “–port ” ‘{print $2}’ | cut -d’ ‘ -f1 | head -1`
PRIMARYPORT=`$BIN/mongo –port $port -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.isMaster())” | grep “primary” | cut -d: -f3 | cut -d'”‘ -f1`
SECONDARYPORTS=`ps -ef | grep ‘shardsvr’ | grep -v grep | awk -F “–port ” ‘{print $2}’ | cut -d’ ‘ -f1 | grep -v $PRIMARYPORT`
CONFIGPORTs=`ps -ef | grep mongo | grep ‘configsvr’ | awk -F “–port ” ‘{print $2}’ | cut -d’ ‘ -f1`
ARBITERPORT=`$BIN/mongo –port $port -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.status())”|grep -B 3 ARBITER|head -1|awk -F”:” ‘{print $3}’|awk -F”\”” ‘{print $1}’`

#### To check the nodes health #####

HEALTH=`$BIN/mongo $HOST:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.status())” | grep ‘health’ | grep -v ‘”health” : 1,’`

if [ -z $HEALTH ];
then echo “Your Replica set nodes are in Good Health.”
else echo “It seems, one/more node server are not in good health, please check & fix them.”;
exit;
fi

#### To lock the writes on Primary ######
PRIMARYPORT=`$BIN/mongo –port $port -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.isMaster())” | grep “primary” | cut -d: -f3 | cut -d'”‘ -f1`

$BIN/mongo $HOST:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.fsyncLock()”

#### To check the Replciation Lag ######
lag=`$BIN/mongo $HOST:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.status())” | grep “optimeDate” |sort -u|wc -l`

while [ $lag -ne 1 ]
do
sleep 5
lag=`$BIN/mongo $HOST:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.status())” | grep “optimeDate” |sort -u|wc -l`
done

##### To get the Secondaries’ Ports ####
for i in $SECONDARYPORTS
do
$BIN/mongo localhost:$i/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.shutdownServer()”;
done

##### To unlock the write lock and shutdown Primary #####

PRIMARYPORT=`$BIN/mongo –port $port -u $UN -p $PW –authenticationDatabase admin –eval “printjson(rs.isMaster())” | grep “primary” | cut -d: -f3 | cut -d'”‘ -f1`

$BIN/mongo $HOST:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.fsyncUnlock()”;
$BIN/mongo localhost:$PRIMARYPORT/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.shutdownServer()”;

#### To stop the Config servers ######
for i in $CONFIGPORTs
do
$BIN/mongo localhost:$i/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.shutdownServer()”;
done

#### To stop Arbiter service ######
$BIN/mongo localhost:$ARBITERPORT/admin –eval “db.shutdownServer()”;

#### To stop Non-replica/Non-Shared Nodes ######

NONSHARED_PORTS=`ps -ef | grep mongod |grep -v grep | awk -F “–port ” ‘{print $2}’ | cut -d’ ‘ -f1`

for i in $NONSHARED_PORTS
do
$BIN/mongo localhost:$i/admin –eval “db.shutdownServer()”;
$BIN/mongo localhost:$i/admin -u $UN -p $PW –authenticationDatabase admin –eval “db.shutdownServer()”;
done

[root@dbversity bin]$

[root@dbversity bin]$ sh -x shard_set_up.sh
++ ps -ef
++ grep -v egrep
++ awk ‘-F ‘ ‘{print $2}’
++ egrep ‘shardsvr|configsvr|replSet|configdb’
+ for i in ‘`ps -ef | egrep ‘\”shardsvr|configsvr|replSet|configdb’\” | grep -v egrep | awk -F” ” ‘\”{print $2}’\”`’
+ kill -9 21052
+ for i in ‘`ps -ef | egrep ‘\”shardsvr|configsvr|replSet|configdb’\” | grep -v egrep | awk -F” ” ‘\”{print $2}’\”`’
+ kill -9 21162
+ for i in ‘`ps -ef | egrep ‘\”shardsvr|configsvr|replSet|configdb’\” | grep -v egrep | awk -F” ” ‘\”{print $2}’\”`’
+ kill -9 21294
+ rm -rf /tmp/mongodb/data/arbiter /tmp/mongodb/data/config1 /tmp/mongodb/data/config2 /tmp/mongodb/data/config3 /tmp/mongodb/data/journal /tmp/mongodb/data/local.0 /tmp/mongodb/data/local.ns /tmp/mongodb/data/mongod.lock /tmp/mongodb/data/shard1 /tmp/mongodb/data/shard2 /tmp/mongodb/data/shard3 /tmp/mongodb/data/_tmp
+ rm -rf /tmp/mongodb/logs/arbiter.log /tmp/mongodb/logs/config1.log /tmp/mongodb/logs/config2.log /tmp/mongodb/logs/config3.log /tmp/mongodb/logs/router.log /tmp/mongodb/logs/shard19.log /tmp/mongodb/logs/shard1.log /tmp/mongodb/logs/shard2.log /tmp/mongodb/logs/shard3.log /tmp/mongodb/logs/shard7.log /tmp/mongodb/logs/shard9.log
+ cd /tmp/mongodb/data/
+ mkdir shard1 shard2 shard3 config1 config2 config3 arbiter
+ cd /tmp/mongodb/bin
+ numactl –interleave=all ./mongod –configsvr –dbpath /tmp/mongodb/data/config1 –logpath /tmp/mongodb/logs/config1.log –port 39000 –config /etc/mongod.conf
+ numactl –interleave=all ./mongod –configsvr –dbpath /tmp/mongodb/data/config3 –logpath /tmp/mongodb/logs/config3.log –port 39002 –config /etc/mongod.conf
+ numactl –interleave=all ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard1 –logpath /tmp/mongodb/logs/shard1.log –port 27010 –config /etc/mongod.conf
+ sleep 15
+ numactl –interleave=all ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard2 –logpath /tmp/mongodb/logs/shard2.log –port 27011 –config /etc/mongod.conf
+ numactl –interleave=all ./mongod –replSet rs –dbpath /tmp/mongodb/data/arbiter –logpath /tmp/mongodb/logs/arbiter.log –port 30000 –config /etc/mongod.conf
+ numactl –interleave=all ./mongod –configsvr –dbpath /tmp/mongodb/data/config2 –logpath /tmp/mongodb/logs/config2.log –port 39001 –config /etc/mongod.conf
+ numactl –interleave=all ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard3 –logpath /tmp/mongodb/logs/shard3.log –port 27012 –config /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
about to fork child process, waiting until server is ready for connections.
about to fork child process, waiting until server is ready for connections.
forked process: 22733
forked process: 22734
forked process: 22735
all output going to: /tmp/mongodb/logs/shard2.log
all output going to: /tmp/mongodb/logs/shard3.log
all output going to: /tmp/mongodb/logs/config3.log
about to fork child process, waiting until server is ready for connections.
about to fork child process, waiting until server is ready for connections.
forked process: 22742
all output going to: /tmp/mongodb/logs/shard1.log
forked process: 22743
all output going to: /tmp/mongodb/logs/config2.log
about to fork child process, waiting until server is ready for connections.
about to fork child process, waiting until server is ready for connections.
forked process: 22752
forked process: 22753
all output going to: /tmp/mongodb/logs/config1.log
all output going to: /tmp/mongodb/logs/arbiter.log
child process started successfully, parent exiting
child process started successfully, parent exiting
child process started successfully, parent exiting
child process started successfully, parent exiting
child process started successfully, parent exiting
child process started successfully, parent exiting
child process started successfully, parent exiting
+ echo -e ‘\n\n\n\n Config, Shard, Router & Arbiter services are initiating … \n\n\n\n’
Config, Shard, Router & Arbiter services are initiating …
+ sleep 15
+ numactl –interleave=all ./mongos –configdb 10.116.34.35:39000,10.116.34.35:39001,10.116.34.35:39002 –logpath /tmp/mongodb/logs/router.log –port 10000 –keyFile /srv/mongodb/keyfile
all output going to: /tmp/mongodb/logs/router.log
^[[A+ ./mongo –port 27010 –eval ‘rs.initiate()’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:27010/test
[object Object]
+ echo -e ‘\n\n\n\n Replica set Initiation is in progress … \n\n\n\n’
Replica set Initiation is in progress …
+ sleep 25
+ ./mongo –port 27010 –eval ‘rs.status()’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:27010/test
[object Object]
+ ./mongo –port 27010 –eval ‘rs.add(“dbversity:27011”)’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:27010/test
[object Object]
+ ./mongo –port 27010 –eval ‘rs.add(“dbversity:27012”)’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:27010/test
[object Object]
+ ./mongo –port 27010 –eval ‘rs.addArb(“dbversity:30000”)’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:27010/test
[object Object]
+ echo -e ‘\n\n\n\n Replica set is is added. \n\n\n\n’
Replica set is is added.
+ sleep 40
+ ./mongo –port 10000 –eval ‘sh.addShard(“rs\dbversity:27010”)’
MongoDB shell version: 2.4.5
connecting to: 127.0.0.1:10000/test
[object Object]
+ echo -e ‘\n\n\n\n Shard is added, now you’\”re set for using the Shard (1Primary, 2Secondaries, 1Arbiter with 3Config & 1Router)’
Shard is added, now you’re set for using the Shard (1Primary, 2Secondaries, 1Arbiter with 3Config & 1Router)
[root@dbversity bin]$
[root@dbversity bin]$ ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/ –logpath /tmp/mongodb/logs/shard7.log –port 27050 –config /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 23242
all output going to: /tmp/mongodb/logs/shard7.log

child process started successfully, parent exiting
[root@dbversity bin]$
[root@dbversity bin]$ ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/ –logpath /tmp/mongodb/logs/shard9.log –port 27090 –config /etc/mongod.conf
about to fork child process, waiting until server is ready for connections.
forked process: 23352
all output going to: /tmp/mongodb/logs/shard9.log
child process started successfully, parent exiting
[root@dbversity bin]$ ./mongod –shardsvr –replSet rs –dbpath /tmp/ –logpath /tmp/mongodb/logs/shard19.log –port 27190 &
[1] 23518
[root@dbversity bin]$ all output going to: /tmp/mongodb/logs/shard19.log

[root@dbversity bin]$

[root@dbversity bin]$ ps -ef | grep mongo
root 14152 6626 0 Feb18 pts/2 00:00:00 ./mongo –port 27010
root 22733 1 0 06:36 ? 00:00:00 ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard3 –logpath /tmp/mongodb/logs/shard3.log –port 27012 –config /etc/mongod.conf
root 22734 1 0 06:36 ? 00:00:00 ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard2 –logpath /tmp/mongodb/logs/shard2.log –port 27011 –config /etc/mongod.conf
root 22735 1 0 06:36 ? 00:00:00 ./mongod –configsvr –dbpath /tmp/mongodb/data/config3 –logpath /tmp/mongodb/logs/config3.log –port 39002 –config /etc/mongod.conf
root 22742 1 0 06:36 ? 00:00:00 ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/shard1 –logpath /tmp/mongodb/logs/shard1.log –port 27010 –config /etc/mongod.conf
root 22743 1 0 06:36 ? 00:00:00 ./mongod –configsvr –dbpath /tmp/mongodb/data/config2 –logpath /tmp/mongodb/logs/config2.log –port 39001 –config /etc/mongod.conf
root 22752 1 0 06:36 ? 00:00:00 ./mongod –configsvr –dbpath /tmp/mongodb/data/config1 –logpath /tmp/mongodb/logs/config1.log –port 39000 –config /etc/mongod.conf
root 22753 1 0 06:36 ? 00:00:00 ./mongod –replSet rs –dbpath /tmp/mongodb/data/arbiter –logpath /tmp/mongodb/logs/arbiter.log –port 30000 –config /etc/mongod.conf
root 22974 1 0 06:37 pts/3 00:00:00 ./mongos –configdb xxxxxxxx:39000,xxxxxxxx:39001,xxxxxxxx:39002 –logpath /tmp/mongodb/logs/router.log –port 10000 –keyFile /srv/mongodb/keyfile
root 23242 1 0 06:38 ? 00:00:00 ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/data/ –logpath /tmp/mongodb/logs/shard7.log –port 27050 –config /etc/mongod.conf
root 23352 1 1 06:38 ? 00:00:00 ./mongod –shardsvr –replSet rs –dbpath /tmp/mongodb/ –logpath /tmp/mongodb/logs/shard9.log –port 27090 –config /etc/mongod.conf
root 23518 9628 3 06:38 pts/0 00:00:01 ./mongod –shardsvr –replSet rs –dbpath /tmp/ –logpath /tmp/mongodb/logs/shard19.log –port 27190
root 23744 9628 0 06:39 pts/0 00:00:00 grep mongo
[root@dbversity bin]$
[root@dbversity bin]$ ./mongo localhost:10000/admin
MongoDB shell version: 2.4.5
connecting to: localhost:10000/admin
mongos>
mongos>
mongos> db.addUser( { “roles” : [ “dbAdminAnyDatabase”, “clusterAdmin”, “readWriteAnyDatabase”, “userAdminAnyDatabase” ], “user” : “adm”, “pwd” : “pwd” } )
{
“roles” : [
“dbAdminAnyDatabase”,
“clusterAdmin”,
“readWriteAnyDatabase”,
“userAdminAnyDatabase”
],
“user” : “adm”,
“pwd” : “8f1cf56da9da9e575e0c85ed1c5a4fba”,
“_id” : ObjectId(“5305e7b2020100c8a121143f”)
}
>
>
> db.auth(“adm”,”pwd”)
1
mongos>
mongos>

mongos>
bye
[root@dbversity bin]$
[root@dbversity bin]$ ./mongo localhost:27010/admin
MongoDB shell version: 2.4.5
connecting to: localhost:27010/admin
rs:PRIMARY>
rs:PRIMARY> db.addUser( { “roles” : [ “dbAdminAnyDatabase”, “clusterAdmin”, “readWriteAnyDatabase”, “userAdminAnyDatabase” ], “user” : “adm”, “pwd” : “pwd” } )
{
“roles” : [
“dbAdminAnyDatabase”,
“clusterAdmin”,
“readWriteAnyDatabase”,
“userAdminAnyDatabase”
],
“user” : “adm”,
“pwd” : “8f1cf56da9da9e575e0c85ed1c5a4fba”,
“_id” : ObjectId(“5305e81c9ad5ef1c8f6692b9”)
}
>
>
> db.auth(“adm”,”pwd”)
1
rs:PRIMARY>

[root@dbversity bin]$ pwd
/tmp/mongodb/bin
[root@dbversity bin]$ cat /etc/mongod.conf

# MongoDB Configuration File

# General Settings
journal = true
fork = true
quiet = true
#directoryperdb = true
smallfiles = true

# Logging
verbose = true
logappend = true
oplogSize = 50
#logpath = /tmp/mongodb/logs/

# Security
auth = true
keyFile = /srv/mongodb/keyfile

#setParameter = supportCompatibilityFormPrivilegeDocuments=0
#setParameter = logUserIds=1
#sslOnNormalPorts = true
#sslPEMKeyFile = /etc/ssl/mongodb.pem
#sslPEMKeyPassword = pass
#nohttpinterface = true
#bind_ip = xxxxxxxx
#noscripting = true
#dbpath = /tmp/mongodb/data
[root@dbversity bin]$

[root@dbversity bin]$ ./mongo –username adm –password –port 10000 –host localhost –authenticationDatabase admin
MongoDB shell version: 2.4.5
Enter password:
connecting to: localhost:10000/test
mongos>
mongos> use admin
switched to db admin
mongos>
mongos> show collections
system.indexes
system.users
mongos>
mongos> db.system.users.find()
{ “_id” : ObjectId(“5305d6fe3e2b781c9878e463”), “roles” : [ “dbAdminAnyDatabase”, “clusterAdmin”, “readWriteAnyDatabase”, “userAdminAnyDatabase” ], “user” : “adm”, “pwd” : “8f1cf56da9da9e575e0c85ed1c5a4fba” }
mongos>
mongos>
[root@dbversity bin]$ sh -x shut.sh
+ BIN=/tmp/mongodb/bin
+ DB=admin
++ hostname
+ HOST=dbversity
+ UN=adm
+ PW=pwd
+ cd /tmp/mongodb/bin
++ ps -ef
++ awk ‘{print $2}’
++ grep -v egrep
++ egrep ‘mongod|mongos’
+ MONGOPID=’22733
22734
22735
22742
22743
22752
22753
22974
23242
23352
23518′
+ ‘[‘ -z 22733 22734 22735 22742 22743 22752 22753 22974 23242 23352 23518 ‘]’
shut.sh: line 12: [: too many arguments
++ ps -ef
++ awk ‘{print $2}’
++ grep mongos
++ grep -v grep
+ for i in ‘`ps -ef | grep ‘\”mongos’\” | grep -v grep | awk ‘\”{print $2}’\”`’
+ kill -9 22974
+ echo ‘Router service with PID 22974 has been stopped’
Router service with PID 22974 has been stopped
++ head -1
++ awk -F ‘–port ‘ ‘{print $2}’
++ cut ‘-d ‘ -f1
++ grep shardsvr
++ grep -v grep
++ ps -ef
+ port=27012
++ /tmp/mongodb/bin/mongo –port 27012 -u adm -p pwd –authenticationDatabase admin –eval ‘printjson(rs.isMaster())’
++ cut ‘-d”‘ -f1
++ cut -d: -f3
++ grep primary
+ PRIMARYPORT=27010
++ ps -ef
++ grep -v 27010
++ grep -v grep
++ grep shardsvr
++ awk -F ‘–port ‘ ‘{print $2}’
++ cut ‘-d ‘ -f1
+ SECONDARYPORTS=’27012
27011
27050
27090
27190′
++ ps -ef
++ grep configsvr
++ awk -F ‘–port ‘ ‘{print $2}’
++ grep mongo
++ cut ‘-d ‘ -f1
+ CONFIGPORTs=’39002
39001
39000′
++ head -1
++ /tmp/mongodb/bin/mongo –port 27012 -u adm -p pwd –authenticationDatabase admin –eval ‘printjson(rs.status())’
++ awk -F: ‘{print $3}’
++ grep -B 3 ARBITER
++ awk ‘-F”‘ ‘{print $1}’
+ ARBITERPORT=30000
++ /tmp/mongodb/bin/mongo dbversity:27010/admin -u adm -p pwd –authenticationDatabase admin –eval ‘printjson(rs.status())’
++ grep -v ‘”health” : 1,’
++ grep health
+ HEALTH=
+ ‘[‘ -z ‘]’
+ echo ‘Your Replica set nodes are in Good Health.’
Your Replica set nodes are in Good Health.
+ /tmp/mongodb/bin/mongo dbversity:27010/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.fsyncLock()’
MongoDB shell version: 2.4.5
connecting to: dbversity:27010/admin
[object Object]
++ /tmp/mongodb/bin/mongo dbversity:27010/admin -u adm -p pwd –authenticationDatabase admin –eval ‘printjson(rs.status())’
++ wc -l
++ grep optimeDate
++ sort -u
+ lag=1
+ ‘[‘ 1 -ne 1 ‘]’
+ for i in ‘$SECONDARYPORTS’
+ /tmp/mongodb/bin/mongo localhost:27012/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27012/admin
Thu Feb 20 06:41:32.996 DBClientCursor::init call() failed
server should be down…
+ for i in ‘$SECONDARYPORTS’
+ /tmp/mongodb/bin/mongo localhost:27011/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27011/admin
Thu Feb 20 06:41:33.043 DBClientCursor::init call() failed
server should be down…
+ for i in ‘$SECONDARYPORTS’
+ /tmp/mongodb/bin/mongo localhost:27050/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27050/admin
Thu Feb 20 06:41:33.095 JavaScript execution failed: Error: 18 { code: 18, ok: 0.0, errmsg: “auth fails” } at src/mongo/shell/db.js:L228
exception: login failed
+ for i in ‘$SECONDARYPORTS’
+ /tmp/mongodb/bin/mongo localhost:27090/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27090/admin
Thu Feb 20 06:41:33.141 JavaScript execution failed: Error: 18 { code: 18, ok: 0.0, errmsg: “auth fails” } at src/mongo/shell/db.js:L228
exception: login failed
+ for i in ‘$SECONDARYPORTS’
+ /tmp/mongodb/bin/mongo localhost:27190/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27190/admin
Thu Feb 20 06:41:33.188 JavaScript execution failed: Error: 18 { code: 18, ok: 0.0, errmsg: “auth fails” } at src/mongo/shell/db.js:L228
exception: login failed
+ /tmp/mongodb/bin/mongo dbversity:27010/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.fsyncUnlock()’
MongoDB shell version: 2.4.5
connecting to: dbversity:27010/admin
[object Object]
+ /tmp/mongodb/bin/mongo localhost:27010/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27010/admin
Thu Feb 20 06:41:33.282 DBClientCursor::init call() failed
server should be down…
+ for i in ‘$CONFIGPORTs’
+ /tmp/mongodb/bin/mongo localhost:39002/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:39002/admin
Thu Feb 20 06:41:33.335 DBClientCursor::init call() failed
server should be down…
+ for i in ‘$CONFIGPORTs’
+ /tmp/mongodb/bin/mongo localhost:39001/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:39001/admin
Thu Feb 20 06:41:33.384 DBClientCursor::init call() failed
server should be down…
+ for i in ‘$CONFIGPORTs’
+ /tmp/mongodb/bin/mongo localhost:39000/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:39000/admin
Thu Feb 20 06:41:33.433 DBClientCursor::init call() failed
server should be down…
+ /tmp/mongodb/bin/mongo localhost:30000/admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:30000/admin
Thu Feb 20 06:41:33.481 DBClientCursor::init call() failed
server should be down…
++ ps -ef
++ grep -v grep
++ awk -F ‘–port ‘ ‘{print $2}’
++ grep mongod
++ cut ‘-d ‘ -f1
+ NONSHARED_PORTS=’27050
27090
27190′
+ for i in ‘$NONSHARED_PORTS’
+ /tmp/mongodb/bin/mongo localhost:27050/admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27050/admin
Thu Feb 20 06:41:33.628 DBClientCursor::init call() failed
server should be down…
+ /tmp/mongodb/bin/mongo localhost:27050/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27050/admin
Thu Feb 20 06:41:33.676 JavaScript execution failed: Error: couldn’t connect to server localhost:27050 at src/mongo/shell/mongo.js:L114
exception: connect failed
+ for i in ‘$NONSHARED_PORTS’
+ /tmp/mongodb/bin/mongo localhost:27090/admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27090/admin
Thu Feb 20 06:41:33.720 DBClientCursor::init call() failed
server should be down…
+ /tmp/mongodb/bin/mongo localhost:27090/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27090/admin
Thu Feb 20 06:41:33.769 JavaScript execution failed: Error: couldn’t connect to server localhost:27090 at src/mongo/shell/mongo.js:L114
exception: connect failed
+ for i in ‘$NONSHARED_PORTS’
+ /tmp/mongodb/bin/mongo localhost:27190/admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27190/admin
Thu Feb 20 06:41:33.831 DBClientCursor::init call() failed
server should be down…
+ /tmp/mongodb/bin/mongo localhost:27190/admin -u adm -p pwd –authenticationDatabase admin –eval ‘db.shutdownServer()’
MongoDB shell version: 2.4.5
connecting to: localhost:27190/admin
Thu Feb 20 06:41:33.879 JavaScript execution failed: Error: couldn’t connect to server localhost:27190 at src/mongo/shell/mongo.js:L114
exception: connect failed
[1]+ Done ./mongod –shardsvr –replSet rs –dbpath /tmp/ –logpath /tmp/mongodb/logs/shard19.log –port 27190
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$
[root@dbversity bin]$ ps -ef | grep mongo
root 14152 6626 0 Feb18 pts/2 00:00:00 ./mongo –port 27010
root 24340 9628 0 06:41 pts/0 00:00:00 grep mongo
[root@dbversity bin]$

  • Ask Question