1. 下载安装包
cd /usr/software/
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-amazon-3.6.2.tgz
tar -zxvf mongodb-linux-x86_64-amazon-3.6.2.tgz
2. mv mongodb-linux-x86_64-amazon-3.6.2 /usr/local/mongodb
3. vi /etc/profile
export MONGODB_HOME=/usr/local/mongodb
export PATH=$PATH:$MONGODB_HOME/bin
source /etc/profile
4. vi /etc/mongodb.conf
参考官方配置
systemLog: destination: file logAppend: true path: /data/mongodb/log/mongod.log storage: dbPath: /data/mongodb/data/db journal: enabled: true # engine: # mmapv1: # wiredTiger: # how the process runs processManagement: fork: true # fork and run in background # pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile # timeZoneInfo: /usr/share/zoneinfo # network interfaces net: port: 27017 bindIpAll: true # bindIp: 127.0.0.1 #to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting. security: authorization: disabled #disabled enabled
5. 新建相关目录
mkdir -p /data/mongodb/data/db
mkdir -p /data/mongodb/log
6. 测试
mongod -f /etc/mongodb.conf
top查看进程
mongo
> use mydb;
> db.test.save( { tecadmin: 100 } )
> db.test.find()
{ "_id" : ObjectId("52b0dc8285f8a8071cbb5daf"), "tecadmin" : 100 }
>exit