#安装mongodb #1.创建mongodb yum安装源
cat >> /etc/yum.repos.d/mongodb-org-3.4.repo << EOF >[mongodb-org-3.4] >name=MongoDB Repository >baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/ >gpgcheck=1 >enabled=1 >gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc > EOF
#ps: $releasever可能为/,所以可以根据版本指定比如6,7等
#2.安装 yum install -y mongodb-org
#3.禁用selinux
vi /etc/selinux/config SELINUX=disabled
#ps: 须重启系统
#4.启动mongodb service mongod start
#5.查看是否启动成功 ps aux | grep mongodb
#6.设置mongodb随系统启动 chkconfig mongod on
#7.停止或重启mongodb service mongod stop|restart
#8.删除mongodb包 yum erase $(rpm -qa | grep mongodb-org)
rm -rf /var/log/mongodb rm -rf /var/lib/mongo rm -rf /etc/mongod.conf
#参考链接: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-red-hat/
原文链接:https://www.f2er.com/centos/376841.html