当前位置:网站首页>史上最全MongoDB之部署篇
史上最全MongoDB之部署篇
2022-07-06 21:33:00 【janyxe】
MongoDB系列文章目录
如果本文对你们的开发之路有所帮助,请帮忙点个赞,您的支持是我坚持写博客的动力
前言
本系列课程将带着大家以面试题的方式 深入分布式专题之MongoDB。这篇文章带着大家部署MongoDB
Linux 安装 MongoDB
下载 MongoDB Community Server
1、访问 https://www.mongodb.com/try/download/community
2、选择版本
Linux 版本
界面下载
Version: 4.4.14
Platform: RedHat / CentOS 7.0
curl 下载
wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.4.14.tgz
tar -zxvf mongodb-linux-x86_64-rhel70-4.4.14.tgz
Windows 平台(Win7\10\11) 选择
启动MongoDB
创建数据库路径 以及 日志路径
[[email protected] local]# mv mongodb-linux-x86_64-rhel70-4.4.14 mongodb
[[email protected] local]# cd mongodb/
[[email protected] mongodb]# ls
bin LICENSE-Community.txt MPL-2 README THIRD-PARTY-NOTICES
[[email protected] mongodb]# mkdir -p data log
启动MongoDB服务
bin/mongod --port=27017 --dbpath=/usr/local/mongodb/data --logpath=/usr/local/mongodb/log/mongodb.log \
--bind_ip=0.0.0.0 --fork
参数说明
参数 | 说明 |
---|---|
–port | 指定端口,默认为27017 |
–bind_ip | 绑定ip,默认只监听本地网卡 |
–dbpath | 指定数据文件存放目录 |
–logpath | 使用追加的方式记录日志 |
–logappend | 使用追加的方式记录日志 |
–fork | 后台启动 |
–auth | 开启认证模式 |
curl MongoDB
部署成功会返回如下信息
curl 127.0.0.1:27017
返回如下信息说明MongoDB 启动成功
[[email protected] mongodb]# curl 127.0.0.1:27017
It looks like you are trying to access MongoDB over HTTP on the native driver port.
配置环境变量
[[email protected] mongodb]# vi /etc/profile
按Shift
+ G
可到底部
添加如下环境变量
export MONGODB_HOME=/usr/local/mongodb
PATH=$PATH:$MONGODB_HOME/bin
让环境变量生效
source /etc/profile
配置文件方式启动服务
[[email protected] mongodb]# pwd
/usr/local/mongodb
[[email protected] mongodb]# mkdir config
[[email protected] mongodb]# vi config/mongod.conf
systemLog:
destination: file
path: "/usr/local/mongodb/log/mongodb.log" # 日志路径
logAppend: true # 开启追加日志
storage:
dbPath: "/usr/local/mongodb/data" # mongod存储数据的目录
journal:
enabled: true # 启用或禁用journal日志(持久性日志)
processManagement:
fork: true # 是否后台启动
net:
bindIp: 0.0.0.0 # 服务实例绑定ip,默认是localhost
port: 27017 # 绑定端口,默认是27017
启动mongoDB服务
mongod -f config/mongod.conf
关闭MongoDB 服务
正常关闭
[[email protected] mongodb]# mongod -f config/mongod.conf --shutdown
shell方式 关闭
进入mongoDB shell
mongo
切换admin库,关闭mongodb
use admin
db.shutdownServer()
边栏推荐
- MySQL storage engine
- Summer 2022 daily question 1 (1)
- 自适应非欧表征广告检索系统AMCAD
- 2022夏每日一题(一)
- Storage of data
- POJ培训计划2253_Frogger(最短/floyd)
- [dpdk] dpdk sample source code analysis III: dpdk-l3fwd_ 001
- ABAP Dynamic Inner table Group cycle
- Kbone与小程序跨端开发的一些思考
- Que savez - vous de la sérialisation et de l'anti - séquence?
猜你喜欢
Simple implementation of AVL tree insertion and verification operations
Gpt-3 is a peer review online when it has been submitted for its own research
Que savez - vous de la sérialisation et de l'anti - séquence?
Mysql-数据丢失,分析binlog日志文件
Kotlin Android environment construction
Implementation steps of docker deploying mysql8
The most complete learning rate adjustment strategy in history LR_ scheduler
What is Ba? How about Ba? What is the relationship between Ba and Bi?
海思3559万能平台搭建:RTSP实时播放的支持
【mysql】mysql中行排序
随机推荐
SSL certificate deployment
web服务性能监控方案
When QT uses qtooltip mouse to display text, the picture of the button will also be displayed and the prompt text style will be modified
Binary, octal, hexadecimal
Implementation steps of docker deploying mysql8
Allow public connections to local Ruby on Rails Development Server
Introduction to opensea platform developed by NFT trading platform (I)
UltraEdit-32 温馨提示:右协会,取消 bak文件[通俗易懂]
Termux set up the computer to connect to the mobile phone. (knock the command quickly), mobile phone termux port 8022
未来发展路线确认!数字经济、数字化转型、数据...这次会议很重要
复杂因子计算优化案例:深度不平衡、买卖压力指标、波动率计算
codeforces每日5题(均1700)-第七天
1.19.11.SQL客户端、启动SQL客户端、执行SQL查询、环境配置文件、重启策略、自定义函数(User-defined Functions)、构造函数参数
机器学习笔记 - 使用机器学习进行鸟类物种分类
使用 BR 备份 TiDB 集群到 GCS
25. (ArcGIS API for JS) ArcGIS API for JS line modification line editing (sketchviewmodel)
你心目中的数据分析 Top 1 选 Pandas 还是选 SQL?
【knife-4j 快速搭建swagger】
23. (ArcGIS API for JS) ArcGIS API for JS ellipse collection (sketchviewmodel)
【系统管理】清理任务栏的已删除程序的图标缓存