1.下载文件
curl -O https://fastdl.mongodb.org/linux/mongodb-linux-i686-3.2.4.tgz
2.解压缩并修改路径
tar -zxvf mongodb-linux-i686-3.2.4.tgz sudo mv mongodb-linux-i686-3.2.4.tgz /usr/local/mongodb
cd /usr/local/mongodb/bin sudo mkdir conf sudo touch mongod.conf
配置文件如下:
systemLog: destination: file path: "/home/ubuntu/mongodb/mongod.log" logAppend: true storage: engine: mmapv1 dbPath: "/home/ubuntu/mongodb/data/db" journal: enabled: true processManagement: pidFilePath: "/home/ubuntu/mongodb/pids/pids.txt" fork: true net: bindIp: 127.0.0.1 port: 27017 setParameter: enableLocalhostAuthBypass: false
注意:storageEngine
是数据库引擎,自version 3.2
后默认是wiredTiger
,无法在32位系统运行,修改为mmapv1
4.添加环境变量
PATH=$PATH:/usr/local/mongodb/bin export PATH
5.启动mongo
mongod --config /usr/local/mongodb/bin/conf/mongod.conf
如果出现一下错误
2017-09-17T13:11:51.397+0800 F CONTROL [main] Failed global initialization: BadValue: Invalid or no user locale set. Please ensure LANG and/or LC_* environment variables are set correctly.
在终端输入export LC_ALL=C
即可