MongoDB使用不同的端口启动多个mongod

MongoDB使用不同的端口启动多个mongod,mongodb,Mongodb,我不能在cmd的第二个mongod中更改端口 1我正在c:\mongodb\bin中启动mongod 我开始写cmd了 cd c:\mongodb\bin mongod --port 10003 但第二种方法不起作用。 帮帮我,谢谢 这就是我所看到的错误 C:\Windows\system32> cd c:\mongodb\bin c:\mongodb\bin>mongod --port 10003 Wed Apr 16 22:15:56.619 Wed Apr 16

我不能在cmd的第二个mongod中更改端口 1我正在c:\mongodb\bin中启动mongod 我开始写cmd了

  cd c:\mongodb\bin
    mongod --port 10003
但第二种方法不起作用。 帮帮我,谢谢

这就是我所看到的错误

C:\Windows\system32> cd c:\mongodb\bin

c:\mongodb\bin>mongod --port 10003
Wed Apr 16 22:15:56.619
Wed Apr 16 22:15:56.620 warning: 32-bit servers don't have journaling enabled by
 default. Please use --journal if you want durability.
Wed Apr 16 22:15:56.622
Wed Apr 16 22:15:56.635 [initandlisten] MongoDB starting : pid=8240 port=10003 d
bpath=\data\db\ 32-bit host=Danil
Wed Apr 16 22:15:56.637 [initandlisten]
Wed Apr 16 22:15:56.638 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Wed Apr 16 22:15:56.640 [initandlisten] **       32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Wed Apr 16 22:15:56.641 [initandlisten] **       Note that journaling defaults t
o off for 32 bit and is currently off.
Wed Apr 16 22:15:56.643 [initandlisten] **       See http://dochub.mongodb.org/c
ore/32bit
Wed Apr 16 22:15:56.645 [initandlisten]
Wed Apr 16 22:15:56.646 [initandlisten] db version v2.4.10
Wed Apr 16 22:15:56.648 [initandlisten] git version: e3d78955d181e475345ebd60053
a4738a4c5268a
Wed Apr 16 22:15:56.650 [initandlisten] build info: windows sys.getwindowsversio
n(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST
_LIB_VERSION=1_49
Wed Apr 16 22:15:56.651 [initandlisten] allocator: system
Wed Apr 16 22:15:56.653 [initandlisten] options: { port: 10003 }
Wed Apr 16 22:15:56.655 [initandlisten] exception in initAndListen: 13627 Unable
 to create/open lock file: \data\db\mongod.lock ??????? ?? ????? ???????? ??????
 ? ?????, ??? ??? ???? ???? ????? ?????? ?????????.. Is a mongod instance alread
y running?, terminating
Wed Apr 16 22:15:56.657 dbexit:
Wed Apr 16 22:15:56.658 [initandlisten] shutdown: going to close listening socke
ts...
Wed Apr 16 22:15:56.660 [initandlisten] shutdown: going to flush diaglog...
Wed Apr 16 22:15:56.662 [initandlisten] shutdown: going to close sockets...
Wed Apr 16 22:15:56.663 [initandlisten] shutdown: waiting for fs preallocator...

Wed Apr 16 22:15:56.665 [initandlisten] shutdown: closing all files...
Wed Apr 16 22:15:56.666 [initandlisten] closeAllFiles() finished
Wed Apr 16 22:15:56.668 dbexit: really exiting now

c:\mongodb\bin>

不能在同一数据库上启动多个MongoDB进程

您需要做的是:

mongod --dbpath c:\database1 --port 27017
mongod --dbpath c:\database2 --port 27018
请记住,必须手动创建数据库文件夹

通常,如果仔细阅读错误日志,您会发现问题:

“13627无法创建/打开锁文件:\data\db\mongod.lock。
mongod实例是否已在运行?

您收到的错误消息是什么?是否在同一目录中启动它们?mongod的第二个实例将需要不同的db路径(与第一个实例使用的默认路径不同)。因此,您必须创建一个不同的数据文件夹,并指定在使用
--dbpath
启动第二个实例时,检查我前面关于
--dbpath
的评论。这就是问题所在。