当前位置:网站首页>史上最全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()

边栏推荐
- API data interface of A-share index component data
- golang 根据生日计算星座和属相
- It's too convenient. You can complete the code release and approval by nailing it!
- A 股指数成分数据 API 数据接口
- 本机mysql
- 海思万能平台搭建:颜色空间转换YUV2RGB
- 二进制、八进制、十六进制
- Redis源码学习(30),字典学习,dict.h
- Some thoughts on cross end development of kbone and applet
- Hisilicon 3559 universal platform construction: RTSP real-time playback support
猜你喜欢

Kotlin Android environment construction
10 ways of interface data security assurance

【开发软件】 tilipa开发者软件

【OA】Excel 文档生成器: Openpyxl 模块

My brave way to line -- elaborate on what happens when the browser enters the URL

ggplot 分面的细节调整汇总

史上最全学习率调整策略lr_scheduler

Probability formula

【系统管理】清理任务栏的已删除程序的图标缓存

PHP lightweight Movie Video Search Player source code
随机推荐
Simple implementation of AVL tree insertion and verification operations
Summer 2022 daily question 1 (1)
三重半圆环进度条,直接拿去就能用
【编码字体系列】OpenDyslexic字体
OSCP工具之一: dirsearch用法大全
Adaptive non European advertising retrieval system amcad
A 股指数成分数据 API 数据接口
Tencent cloud native database tdsql-c was selected into the cloud native product catalog of the Academy of communications and communications
SSL certificate deployment
Antd Comment 递归循环评论
The most complete learning rate adjustment strategy in history LR_ scheduler
How to manage the expiration of enterprise distribution certificates- How to manage Enterprise Distribution certificate expiration?
Do you choose pandas or SQL for the top 1 of data analysis in your mind?
【安全攻防】序列化与反序列,你了解多少?
[MySQL] row sorting in MySQL
Enter the rough outline of the URL question (continuously updated)
idea gradle lombok 报错集锦
The true face of function pointer in single chip microcomputer and the operation of callback function
什么是 BA ?BA怎么样?BA和BI是什么关系?
25. (ArcGIS API for JS) ArcGIS API for JS line modification line editing (sketchviewmodel)