Mongodb在32位Windows平台下部署安装
听说Mongodb对32位Windows平台的支持不是那么理想,所以安装过程中出现了比较多的问题
1.无法启动MongoDB
1.将绿色版的Mongodb解压在安装目录下,配置好环境变量,步骤传送门 我是传送门
2.天真的在终端输入命令 mongodb以为可以打开数据库了,但终端提示,各种异常
3.看了一下log,发现关键点,exception in initAndListen: 28663 Cannot start server. The default storage engine 'wiredTiger' is not available with this build of mongod. Please specify a different storage engine explicitly, e.g. --storageEngine=mmapv1., terminating
2020-11-06T09:39:00.821+0800 I CONTROL [main] Hotfix KB2731284 or later update is not installed, will zero-out data files
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] MongoDB starting : pid=10460 port=27017 dbpath=C:\data\db\ 32-bit host=yxwj-PC
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] targetMinOS: Windows Vista/Windows Server 2008
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] db version v3.2.22
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] git version: 105acca0d443f9a47c1a5bd608fd7133840a58dd
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] allocator: tcmalloc
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] modules: none
2020-11-06T09:39:00.854+0800 I CONTROL [initandlisten] build environment:
2020-11-06T09:39:00.855+0800 I CONTROL [initandlisten] distarch: i386
2020-11-06T09:39:00.855+0800 I CONTROL [initandlisten] target_arch: i386
2020-11-06T09:39:00.855+0800 I CONTROL [initandlisten] options: { systemLog: { destination: "file", path: "D:\MongoDB\Server\3.2\data\log\MongoDB.log" } }
2020-11-06T09:39:00.867+0800 I STORAGE [initandlisten] exception in initAndListen: 28663 Cannot start server. The default storage engine 'wiredTiger' is not available with this build of mongod. Please specify a different storage engine explicitly, e.g. --storageEngine=mmapv1., terminating
2020-11-06T09:39:00.867+0800 I CONTROL [initandlisten] dbexit: rc: 100
4.发现是32位的电脑系统不支持mongodb的默认存储引擎wiredTiger,都怪单位的电脑比较有历史,只能换成mmapv1
5.在终端输入mongod --dbpath "D:\mongodb\data" --storageEngine==mmapv1,出现红色框的内容,证明mongodb安装成功
6.在浏览器输入 http://localhost:27017/,可以看到下面提示
2.关闭电脑或者重启电脑后不能再次连接MongoDB(1)
1.重新打开电脑输入mongo发现不能连接mongodb服务器,找了一下原因,可能是因为mongodb服务器还不能自动开启
2.在终端输入mongod.exe --dbpath D:\MongoDB\Server\3.2\data\db,看到端口监听消息就可以连接数据库了
3.也可以通过输入下列命令达到在终端输入net start MongoDB便开启mongodb服务的目的
mongod.exe --dbpath "D:\MongoDB\data\db" --logpath "D:\MongoDB\data\log\mongodb.log" --install --serviceName "mongo" --logappend --directoryperdb
3.关闭电脑或者重启电脑后不能再次连接MongoDB(2)
1.输入mongod.exe --dbpath "D:\MongoDB\data\db" --logpath "D:\MongoDB\data\log\mongodb.log" --install --serviceName "mongo" --logappend --directoryperdb后,不能连接MongoDB数据库
2.看到出现这个异常old lock file: D:\MongoDB\Server\3.2\data\db\mongod.lock. probably means unclean shutdown,可能是电脑异常关闭
3.解决办法:
1)将MongoDB数据库bin文件夹中得mongod.lock文件删掉
2)执行mongod --repair命令
4.再次输入mongod -dbpath "D:\MongoDB\Server\3.2\data\db" -journal --storageEngine=mmapv1连接成功