1.下载MongoDB安装包
下载 https://www.mongodb.com/try/download/community 选择MongoDB Community Server Version:5.0.2(current) Platform:RedHat / CentOS 7.0 Package:tgz 安装位置:/usr/local/mongodb
cd /usr/local
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.2.tgz
tar -zxvf mongodb-linux-x86_64-rhel70-5.0.2.tgz
mv mongodb-linux-x86_64-rhel70-5.0.2 mongodb
rm -rf mongodb-linux-x86_64-rhel70-5.0.2.tgz
2.配置环境变量
vim /etc/profile
export MONGO_HOME=/usr/local/mongodb
export PATH=$PATH:$MONGO_HOME/bin;
source /etc/profile
3.建立日志、数据文件夹、配置文件夹
cd /usr/local/mongodb
mkdir logs data conf
cd /usr/local/mongodb/conf
vim mongodb.conf
port=27017
bind_ip=0.0.0.0
dbpath=/usr/local/mongodb/data
logpath=/usr/local/mongodb/logs/mongodb.log
fork=true
4.启动MongoDB
./mongod --config /usr/local/mongodb/conf/mongodb.conf
5.连接
mongo
|