centos7.3安装MongoDB

时间:2023-02-05 16:37:14

安装步骤:

1.配置包管理系统

  vim /etc/yum.repos.d/mongodb.repo

[mongodb]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64/
gpgcheck=
enabled=

把下面代码粘贴到vim里

  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://*.com/questions/34725574/yum-install-mongodb-3-2-fails    # 碰到问题解决帖子