CentOS7 MongoDB安裝
查看MongoDB的最新版官方下载地址:
https://www.mongodb.com/download-center#community
使用wget命令下载安装包
1
|
wget https: //fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.2.6.tgz |
tar zxvf mongodb-linux-x86_64-3.2.6.tgz
mv mongodb-linux-x86_64-3.2.6.tgz mongodb
cd mongodb
mkdir db
mkdir logs
cd bin
vi mongodb.conf
1
2
3
4
5
|
dbpath=/usr/local/mongodb/db logpath=/usr/local/mongodb/logs/mongodb.log port=27017 fork= true nohttpinterface= true |
重新绑定mongodb的配置文件地址和访问IP
/usr/local/mongodb/bin/mongod --bind_ip localhost -f /usr/local/mongodb/bin/mongodb.conf
开机自动启动mongodb
vi /etc/rc.d/rc.local
/usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
重启一下系统测试下能不能自启
#进入mongodb的shell模式
/usr/local/mongodb/bin/mongo
#查看数据库列表
show dbs
#当前db版本
db.version();
新版安装方法见:
Install MongoDB Community Edition on Red Hat Enterprise or CentOS Linux
https://docs.mongodb.com/master/tutorial/install-mongodb-on-red-hat/