CentOS 7下MongoDB安装记录

版本:

cat /etc/redhat-release 

CentOS Linux release 7.5.1804 (Core) 

一、配置yum

用阿里云的镜像:

1. 备份

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


2. 下载

curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo


3. 生成缓存

yum clean all
yum makecache

配置yum完成 

二、安装MongoDB

1、安装依赖包

yum install libcurl openssl

2、下载MongoDB

要下载系统对应的软件版本,否则安装会各种问题

 下载链接:MongoDB Community Download | MongoDBDownload the Community version of MongoDB's non-relational database server from MongoDB's download center.https://www.mongodb.com/try/download/community

 CentOS 7下MongoDB安装记录_第1张图片

 选择平台和版本,然后复制链接,下面是我下载的链接 

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.4.tgz

用此链接下载软件  

curl -o mongodb5.tgz https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.4.tgz

 解压

tar -xvf mongodb5.tgz

移动到指定的目录 

mv mongodb-linux-x86_64-rhel70-5.0.4/ ../app/mongodb5

 3、配置全局变量

export PATH=/home/lht/app/mongodb5/bin:$PATH

创建两个目录并授权,用于存放数据和日志

/var/lib/mongodb
/var/log/mongodb

4、启动MongoDB

./mongod --dbpath /var/lib/mongodb --logpath /var/log/mongodb/mongod.log --fork

 输出:
about to fork child process, waiting until server is ready for connections.
forked process: 21007
child process started successfully, parent exiting

5、测试MongoDB

[lht@localhost bin]$ mongo

输出
MongoDB shell version v5.0.4
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("baf90d0a-b930-4f6c-8849-6337b0bf474b") }
MongoDB server version: 5.0.4 

安装成功
 

你可能感兴趣的:(mongodb,数据库,database)