Sunday, May 28, 2023

Client/application/ driver currently connect to Mongodb

In order to know what operations are currently running on the MongoDB services, we use this query:
We can get the application server, which is connected to the MongoDB services with the below query:
We want to know what is the active connection detail which is currently running in the MongoDB services
We want to know driver, driver version, app name , client ip , current active and current inactive connection in mongodb service
found better version from stackoverflow Check the current number of connections to MongoDb
Find detail of connection detail by IP
Reference
Check the current number of connections to MongoDb
What’s Running in My DB? A Journey with currentOp() in MongoDB

Monday, February 9, 2015

MongoDB crash when PC not proper shutdown

repair and restart
1. start mongod, log indicate mongd unclean shutdown detect, Please visit http://dochub.mongodb.org/core/repair for recovery instructions. the service shutdown automatically
2. repair mongodb with mongod -repair
3. start mongod again, service start

start mongd
mongod --help for help and startup options
2015-02-10T10:04:01.893+0800
2015-02-10T10:04:01.903+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2015-02-10T10:04:01.903+0800
2015-02-10T10:04:01.943+0800 [initandlisten] MongoDB starting : pid=6836 port=27
017 dbpath=\data\db\ 32-bit host=WN7-9Q2H12S
2015-02-10T10:04:01.943+0800 [initandlisten]
2015-02-10T10:04:01.943+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-10T10:04:01.953+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-10T10:04:01.953+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-10T10:04:01.963+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-10T10:04:01.963+0800 [initandlisten]
2015-02-10T10:04:01.963+0800 [initandlisten] targetMinOS: Windows XP SP3
2015-02-10T10:04:01.963+0800 [initandlisten] db version v2.6.7
2015-02-10T10:04:01.973+0800 [initandlisten] git version: a7d57ad27c382de82e9cb9
3bf983a80fd9ac9899
2015-02-10T10:04:01.973+0800 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2015-02-10T10:04:01.983+0800 [initandlisten] allocator: system
2015-02-10T10:04:01.983+0800 [initandlisten] options: {}
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.

*************
2015-02-10T10:04:02.063+0800 [initandlisten] exception in initAndListen: 12596 o
ld lock file, terminating
2015-02-10T10:04:02.073+0800 [initandlisten] dbexit:
2015-02-10T10:04:02.073+0800 [initandlisten] shutdown: going to close listening
sockets...
2015-02-10T10:04:02.073+0800 [initandlisten] shutdown: going to flush diaglog...

2015-02-10T10:04:02.083+0800 [initandlisten] shutdown: going to close sockets...

2015-02-10T10:04:02.083+0800 [initandlisten] shutdown: waiting for fs preallocat
or...
2015-02-10T10:04:02.093+0800 [initandlisten] shutdown: closing all files...
2015-02-10T10:04:02.093+0800 [initandlisten] closeAllFiles() finished
2015-02-10T10:04:02.093+0800 [initandlisten] dbexit: really exiting now




-- start repair
mongod -repair
2015-02-10T10:20:44.637+0800
2015-02-10T10:20:44.644+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2015-02-10T10:20:44.648+0800
2015-02-10T10:20:44.681+0800 [initandlisten] MongoDB starting : pid=7224 port=27
017 dbpath=\data\db\ 32-bit host=WN7-9Q2H12S
2015-02-10T10:20:44.684+0800 [initandlisten]
2015-02-10T10:20:44.687+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-10T10:20:44.694+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-10T10:20:44.697+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-10T10:20:44.700+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-10T10:20:44.703+0800 [initandlisten]
2015-02-10T10:20:44.705+0800 [initandlisten] targetMinOS: Windows XP SP3
2015-02-10T10:20:44.708+0800 [initandlisten] db version v2.6.7
2015-02-10T10:20:44.712+0800 [initandlisten] git version: a7d57ad27c382de82e9cb9
3bf983a80fd9ac9899
2015-02-10T10:20:44.721+0800 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2015-02-10T10:20:44.725+0800 [initandlisten] allocator: system
2015-02-10T10:20:44.729+0800 [initandlisten] options: { repair: true }
2015-02-10T10:20:44.821+0800 [initandlisten] repairDatabase local
2015-02-10T10:20:44.829+0800 [initandlisten] allocating new ns file \data\db\_tm
p_repairDatabase_0\local.ns, filling with zeroes...
2015-02-10T10:20:46.299+0800 [FileAllocator] allocating new datafile \data\db\_t
mp_repairDatabase_0\local.0, filling with zeroes...
2015-02-10T10:20:46.305+0800 [FileAllocator] creating directory \data\db\_tmp_re
pairDatabase_0\_tmp
2015-02-10T10:20:47.261+0800 [FileAllocator] done allocating datafile \data\db\_
tmp_repairDatabase_0\local.0, size: 64MB,  took 0.946 secs
2015-02-10T10:20:50.371+0800 [initandlisten] repairDatabase pcat
2015-02-10T10:20:50.379+0800 [initandlisten] allocating new ns file \data\db\_tm
p_repairDatabase_0\pcat.ns, filling with zeroes...
2015-02-10T10:20:51.327+0800 [FileAllocator] allocating new datafile \data\db\_t
mp_repairDatabase_0\pcat.0, filling with zeroes...
2015-02-10T10:20:51.331+0800 [FileAllocator] creating directory \data\db\_tmp_re
pairDatabase_0\_tmp
2015-02-10T10:20:52.087+0800 [FileAllocator] done allocating datafile \data\db\_
tmp_repairDatabase_0\pcat.0, size: 64MB,  took 0.69 secs
2015-02-10T10:20:58.202+0800 [initandlisten] finished checking dbs
2015-02-10T10:20:58.202+0800 [initandlisten] dbexit:
2015-02-10T10:20:58.202+0800 [initandlisten] shutdown: going to close listening
sockets...
2015-02-10T10:20:58.202+0800 [initandlisten] shutdown: going to flush diaglog...

2015-02-10T10:20:58.202+0800 [initandlisten] shutdown: going to close sockets...

2015-02-10T10:20:58.212+0800 [initandlisten] shutdown: waiting for fs preallocat
or...
2015-02-10T10:20:58.222+0800 [initandlisten] shutdown: closing all files...
2015-02-10T10:20:58.222+0800 [initandlisten] closeAllFiles() finished
2015-02-10T10:20:58.232+0800 [initandlisten] shutdown: removing fs lock...
2015-02-10T10:20:58.232+0800 [initandlisten] dbexit: really exiting now

--service start
mongod
mongod --help for help and startup options
2015-02-10T10:21:53.965+0800
2015-02-10T10:21:54.065+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2015-02-10T10:21:54.065+0800
2015-02-10T10:21:54.095+0800 [initandlisten] MongoDB starting : pid=4208 port=27
017 dbpath=\data\db\ 32-bit host=WN7-9Q2H12S
2015-02-10T10:21:54.095+0800 [initandlisten]
2015-02-10T10:21:54.095+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-10T10:21:54.095+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-10T10:21:54.095+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-10T10:21:54.095+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-10T10:21:54.095+0800 [initandlisten]
2015-02-10T10:21:54.095+0800 [initandlisten] targetMinOS: Windows XP SP3
2015-02-10T10:21:54.095+0800 [initandlisten] db version v2.6.7
2015-02-10T10:21:54.095+0800 [initandlisten] git version: a7d57ad27c382de82e9cb9
3bf983a80fd9ac9899
2015-02-10T10:21:54.095+0800 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2015-02-10T10:21:54.105+0800 [initandlisten] allocator: system
2015-02-10T10:21:54.105+0800 [initandlisten] options: {}
2015-02-10T10:21:54.145+0800 [initandlisten] waiting for connections on port 270
17

Wednesday, February 4, 2015

Start mongodb, free tutorial from Mongodb university

Mongodb university
M102: MongoDB for DBAs

Download mongodb
I download windows 32 bit MSI and install

start mongodb services
from command prompot, mongo db bin folder
mongodb.exe

mongod.exe --help for help and startup options
2015-02-05T13:12:02.452+0800
2015-02-05T13:12:02.462+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2015-02-05T13:12:02.470+0800
2015-02-05T13:12:02.507+0800 [initandlisten] MongoDB starting : pid=121552 port=
27017 dbpath=\data\db\ 32-bit host=WN7-9Q2H12S
2015-02-05T13:12:02.510+0800 [initandlisten]
2015-02-05T13:12:02.512+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-05T13:12:02.517+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-05T13:12:02.521+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-05T13:12:02.523+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-05T13:12:02.526+0800 [initandlisten]
2015-02-05T13:12:02.527+0800 [initandlisten] targetMinOS: Windows XP SP3
2015-02-05T13:12:02.528+0800 [initandlisten] db version v2.6.7
2015-02-05T13:12:02.531+0800 [initandlisten] git version: a7d57ad27c382de82e9cb9
3bf983a80fd9ac9899
2015-02-05T13:12:02.534+0800 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2015-02-05T13:12:02.539+0800 [initandlisten] allocator: system
2015-02-05T13:12:02.540+0800 [initandlisten] options: {}
2015-02-05T13:12:02.542+0800 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (\data\db\) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo

*********************************************************************
, terminating
2015-02-05T13:12:02.552+0800 [initandlisten] dbexit:
2015-02-05T13:12:02.553+0800 [initandlisten] shutdown: going to close listening
sockets...
2015-02-05T13:12:02.556+0800 [initandlisten] shutdown: going to flush diaglog...

2015-02-05T13:12:02.558+0800 [initandlisten] shutdown: going to close sockets...

2015-02-05T13:12:02.566+0800 [initandlisten] shutdown: waiting for fs preallocat
or...
2015-02-05T13:12:02.571+0800 [initandlisten] shutdown: closing all files...
2015-02-05T13:12:02.574+0800 [initandlisten] closeAllFiles() finished
2015-02-05T13:12:02.577+0800 [initandlisten] dbexit: really exiting now

default folder is c:\data\db
create folder c:\data\db and start again; this start will successful
mongod.exe

mongod.exe --help for help and startup options
2015-02-05T13:14:22.396+0800
2015-02-05T13:14:22.408+0800 warning: 32-bit servers don't have journaling enabl
ed by default. Please use --journal if you want durability.
2015-02-05T13:14:22.413+0800
2015-02-05T13:14:22.445+0800 [initandlisten] MongoDB starting : pid=120864 port=
27017 dbpath=\data\db\ 32-bit host=WN7-9Q2H12S
2015-02-05T13:14:22.449+0800 [initandlisten]
2015-02-05T13:14:22.452+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-05T13:14:22.456+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-05T13:14:22.458+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-05T13:14:22.461+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-05T13:14:22.466+0800 [initandlisten]
2015-02-05T13:14:22.468+0800 [initandlisten] targetMinOS: Windows XP SP3
2015-02-05T13:14:22.472+0800 [initandlisten] db version v2.6.7
2015-02-05T13:14:22.475+0800 [initandlisten] git version: a7d57ad27c382de82e9cb9
3bf983a80fd9ac9899
2015-02-05T13:14:22.478+0800 [initandlisten] build info: windows sys.getwindowsv
ersion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1')
BOOST_LIB_VERSION=1_49
2015-02-05T13:14:22.483+0800 [initandlisten] allocator: system
2015-02-05T13:14:22.485+0800 [initandlisten] options: {}
2015-02-05T13:14:22.540+0800 [initandlisten] waiting for connections on port 270
17

start another command prompt
mongo.exe

MongoDB shell version: 2.6.7
connecting to: test
Server has startup warnings:
2015-02-05T13:14:22.449+0800 [initandlisten]
2015-02-05T13:14:22.452+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b
inary.
2015-02-05T13:14:22.456+0800 [initandlisten] **       32 bit builds are limited
to less than 2GB of data (or less with --journal).
2015-02-05T13:14:22.458+0800 [initandlisten] **       Note that journaling defau
lts to off for 32 bit and is currently off.
2015-02-05T13:14:22.461+0800 [initandlisten] **       See http://dochub.mongodb.
org/core/32bit
2015-02-05T13:14:22.466+0800 [initandlisten]
>

installation successful and mongo start accept connection
help
show dbs