安装步骤:
1.配置包管理系统
vim /etc/yum.repos.d/mongodb.repo
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
[mongodb] name=MongoDB Repository baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/ gpgcheck=0 enabled=1
wq保存退出
2.执行安装命令
sudo yum install -y mongodb-org
3.启动MongoDB
sudo service mongod start
4.确保每次centos重启MongoDB也会启动
sudo chkconfig mongod on
1.MongoDB官网根据系统下载tzg包
2.根目录建立software文件夹
cd ~
mkdir software
cd software
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.6.2.tgz # 如果不行,就去官网下载,拖这里吧
tar -xf mongodb-linux-x86_64-rhel70-3.6.2.tgz
cd mongodb-linux-x86_64-rhel70-3.6.2
mv bin ~/
cd ~
mkdir -p ~/data/db
mkdir -p ~/data/mongodb/log
mongod -dbpath ~/data/db -port 79744
mkdir -p /home/dp/data/mongodb/config
vim /home/dp/data/mongodb/config/mongod.conf
vim /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
摘自:
https://www.mongodb.com/download-center?jmp=nav#community # 官网
https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
https://stackoverflow.com/questions/34725574/yum-install-mongodb-3-2-fails # 碰到问题解决帖子