今天在线上服务器上安装MongoDB,从Mongo官网直接下载链接,结果在下载时发觉速度慢的可怜。迫于无奈,只能找国内的镜像下载。这里选择阿里云的源进行安装,记录如下:
1)在/etc/yum.repos.d 创建一个mongodb-org.repo 源文件 [[email protected] ~]$ cd /etc/yum.repos.d/ [[email protected] yum.repos.d]$ touch mongodb-org.repo [[email protected] 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源 [[email protected] yum.repos.d]$ yum update 3) 安装MongoDB [[email protected] yum.repos.d]$ yum install -y mongodb-org 4)启动MongoDB [[email protected] yum.repos.d]$ service mongod start [[email protected] yum.repos.d]$ chkconfig mongod on 5)配置远程访问 [[email protected] 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 [[email protected] yum.repos.d]$ service mongod restart Restarting mongod (via systemctl): [ OK ] 6)打开MongoDB [[email protected] yum.repos.d]$ mongo 127.0.0.1:27017
时间: 2024-10-19 21:03:53