今天在线上服务器上安装MongoDB,从Mongo官网直接下载链接,结果在下载时发觉速度慢的可怜。迫于无奈,只能找国内的镜像下载。这里选择阿里云的源进行安装,记录如下:
1)在/etc/yum.repos.d 创建一个mongodb-org.repo 源文件
[root@qd-vpc-dev-op01 ~]$ cd /etc/yum.repos.d/
[root@qd-vpc-dev-op01 yum.repos.d]$ touch mongodb-org.repo
[root@qd-vpc-dev-op01 yum.repos.d]$ cat mongodb-org.repo
[mongodb-org]
name=MongoDB Repository
baseurl=http://mirrors.aliyun.com/mongodb/yum/redhat/7Server/mongodb-org/3.2/x86_64/
gpgcheck=0
enabled=1 2)更新yum源
[root@qd-vpc-dev-op01 yum.repos.d]$ yum update 3) 安装MongoDB
[root@qd-vpc-dev-op01 yum.repos.d]$ yum install -y mongodb-org 4)启动MongoDB
[root@qd-vpc-dev-op01 yum.repos.d]$ service mongod start
[root@qd-vpc-dev-op01 yum.repos.d]$ chkconfig mongod on 5)配置远程访问
[root@qd-vpc-dev-op01 yum.repos.d]$cat /etc/mongod.conf|grep -v "#"|grep -v "^$"
systemLog:
destination: file
logAppend: true
path: /var/log/mongodb/mongod.log
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
processManagement:
net:
port: 27017 [root@qd-vpc-dev-op01 yum.repos.d]$ service mongod restart
Restarting mongod (via systemctl): [ OK ] 6)打开MongoDB
[root@qd-vpc-dev-op01 yum.repos.d]$ mongo 127.0.0.1:27017