合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
>[info] centos安装 1. 下载安装包 **下载地址:** https://www.mongodb.com/try/download ![](https://img.kancloud.cn/eb/b7/ebb7125b63017a29bc794c9696cd91c4_1363x1162.png) ~~~ wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.5.tgz ~~~ 2. 解压 ``` tar -zxvf mongodb-linux-x86_64-rhel70-5.0.5.tgz mkdir mongodb | mv mongodb-linux-x86_64-rhel70-5.0.5/ mongodb ``` 3. 创建配置文件 ``` cd mongodb vim mongodb.conf ``` ~~~ port=27017 bind_ip=0.0.0.0 dbpath=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-5.0.5/data/ logpath=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-5.0.5/logs/mongodb.log pidfilepath=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-5.0.5/mongo.pid fork=true logappend=true auth=false #auth=true ~~~ 4. 创建目录文件 ~~~ mkdir data logs run ~~~ 5. 添加环境变量 ~~~ vim /etc/profile #for mongodb export MONGODB_HOME=/usr/local/mongodb/mongodb-linux-x86_64-rhel70-5.0.5 export PATH=$MONGODB_HOME/bin:$PATH source /etc/profile ~~~ >[info] 启动&停止mongodb 1. 指定配置文件启动mongodb ``` mongod --config /usr/local/mongodb/mongodb-linux-x86_64-rhel70-5.0.5/mongodb.conf ``` ![](https://img.kancloud.cn/0d/69/0d69a382f36dc027285d7eb1d97b0d64_959x103.png) 2. 停止mongodb(无认证停止) ~~~ mongo 127.0.0.1:27017/admin --eval "db.shutdownServer()" ~~~ 3. 查看mongdb是否启动 ~~~ netstat -lanp | grep "27017" ~~~