下载mongodb和系统对应的二进制文件
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.4.9.tgz
解压文件:
tar -xvzf mongodb-linux-x86_64-rhel62-3.4.9.tgz
拷贝到安装目录:
sudo cp -a mongodb-linux-x86_64-rhel62-3.4.9 /usr/local/mongodb
新建数据文件夹:
mkdir -p data/db
mkdir -p data/log
touch /usr/local/mongodb/data/log/mongodb.log
先启动试试:
bin/mongod --dbpath data/db
写mongdb的配置文件:
vim /usr/local/mongodb/mongodb.conf
systemLog:
destination: file
path: "/usr/local/mongodb/data/log/mongodb.log"
logAppend: true
storage:
journal:
enabled: true
dbPath: "/usr/local/mongodb/data/db"
directoryPerDB: false
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 4
directoryForIndexes: false
journalCompressor: zlib
collectionConfig:
blockCompressor: zlib
indexConfig:
prefixCompression: true
net:
port: 27017
processManagement:
fork: true
security:
authorization: disabled
启动:
bin/mongod -f /usr/local/mongodb/mongodb.conf
客服端:
mongo 127.0.0.1:27017/test
mongo