//step 1. 检查CentOS 版本
# cat /etc/os-release
//返回结果
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
//step 2. 创建并编辑mongodb-org.repo文件
# vim /etc/yum.repos.d/mongodb-org-3.4.repo
[mongodb-org-3.4]
name=MongoDB Repository
#可选择速度较快的镜像,例如mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/3.5/x86_64
baseurl=https://repo.mongodb.org/yum/redhat/7Server/mongodb-org/3.5/x86_64/
gpgcheck=0
enabled=1
gpgcheck=1,需添加字段 gpgkey= https://www.mongodb.org/static/pgp/server-3.4.asc
//step 3. (推荐)清空yum缓存,避免出现异常(例如,没有可用软件包等)
# rm -rf /var/cache/yum
//step 4.安装
# sudo yum install -y mongodb-org
启动安装过程
安装过程自动切换镜像服务器
#未测试aliyun等镜像地址,速度未知
如果以上步骤未完成安装,请参见:
https://docs.mongodb.com/master/tutorial/install-mongodb-on-red-hat/
MongoDB Community Edition 可分别安装在以下系统中,可参考:
- Red Hat: https://docs.mongodb.com/master/tutorial/install-mongodb-on-red-hat/
- SUSE: https://docs.mongodb.com/master/tutorial/install-mongodb-on-suse/
- Amazon: https://docs.mongodb.com/master/tutorial/install-mongodb-on-amazon/
- Ubuntu: https://docs.mongodb.com/master/tutorial/install-mongodb-on-ubuntu/
- Debian: https://docs.mongodb.com/master/tutorial/install-mongodb-on-debian/
# vim /etc/mongod.conf
//对文件中的bindIp: 127.0.0.1 进行注释
#sudo chkconfig mongod on
#sudo service mongod start
网友评论