linux 启动mongodb
linux 启动mongodb
1.启动mongodb服务
先cd到mongodb的目录下
cd mongodb
创建data数据目录,和log日志目录
mkdir -p data/db
mkdir logs
启动mongodb服务
./bin/mongod --dbpath=./data/db --logpath=./logs/mongodb.log --fork
建议以后台方式启动(–fork),否则以常驻方式启动不能关闭启动的终端
其他参数
--dbpath arg (=/data/db/) directory for datafiles 指定数据存放目录
--quiet quieter output 静默模式
--logpath arg file to send all output to instead of stdout 指定日志存放目录
--logappend appnd to logpath instead of over-writing 指定日志是以追加还是以覆盖的方式写入日志文件
--fork fork server process 以创建子进程的方式运行
--cpu periodically show cpu and iowait utilization 周期性的显示cpu和io的使用情况
--noauth run without security 无认证模式运行
--auth run with security 认证模式运行
--objcheck inspect client data for validity on receipt 检查客户端输入数据的有效性检查
--quota enable db quota management 开始数据库配额的管理
--quotaFiles arg number of files allower per db, requires --quota 规定每个数据库允许的文件数
--appsrvpath arg root directory for the babble app server
--nocursors diagnostic/debugging option 调试诊断选项
--nohints ignore query hints 忽略查询命中率
--nohttpinterface disable http interface 关闭http接口,默认是28017
--noscripting disable scripting engine 关闭脚本引擎
--noprealloc disable data file preallocation 关闭数据库文件大小预分配
--smallfiles use a smaller default file size 使用较小的默认文件大小
--nssize arg (=16) .ns file size (in MB) for new databases 新数据库ns文件的默认大小
--diaglog arg 0=off 1=W 2=R 3=both 7=W+some reads 提供的方式,是只读,只写,还是读写都行,还是主要写+部分的读模式
--sysinfo print some diagnostic system information 打印系统诊断信息
--upgrade upgrade db if needed 如果需要就更新数据库
--repair run repair on all dbs 修复所有的数据库
--notablescan do not allow table scans 不运行表扫描
--syncdelay arg (=60) seconds between disk syncs (0 for never) 系统同步刷新磁盘的时间,默认是60s
2.启动mongodb
$ mongo
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)