美文网首页
【MongoDB】MongoDB根据启动命令行生成配置文件

【MongoDB】MongoDB根据启动命令行生成配置文件

作者: Bogon | 来源:发表于2024-04-29 15:47 被阅读0次

请根据如下进程启动命令行生成mongodb 启动的配置文件 mongod.conf

numactl --interleave=all mongod  \
  --directoryperdb   \
  --auth \
  --keyFile=/path/to/key_file  \
  --wiredTigerCacheSizeGB 6 \
  --dbpath=/path/to/db  \
  --port 27017 \
  --fork  \
  --replSet test  \
  --logpath /path/to/mongd.log \
  --logappend \
  --maxConns 16000

根据提供的启动参数,以下是对应的 MongoDB 配置文件 mongod.conf 的内容:

net:
  port: 27017
  maxIncomingConnections: 16000

storage:
  dbPath: /path/to/db
  directoryPerDB: true
  wiredTiger:
    engineConfig:
      cacheSizeGB: 6

security:
  authorization: enabled
  keyFile: /path/to/key_file

systemLog:
  destination: file
  path: /path/to/mongod.log
  logAppend: true

replication:
  replSetName: test

processManagement:
  fork: true

可以看出,这是一个MongoDB复制集的一个节点的配置。

请根据如下进程启动命令行生成mongodb 启动的配置文件 mongod.conf

numactl --interleave=all mongod \
  --directoryperdb  \
  --auth  \
  --keyFile=/path/to/key_file \
  --configsvr \
  --dbpath=${datapath} \
  --port ${dbport} \
  --fork \
  --replSet ${replSetName} \
  --logpath /path/to/mongod.log \
  --logappend \
  --maxConns 16000

根据提供的启动参数,以下是对应的 MongoDB 配置文件 mongod.conf 的内容:

net:
  port: ${dbport}
  maxIncomingConnections: 16000 
  
systemLog:
  destination: file
  path: /path/to/mongod.log
  logAppend: true
storage:
  dbPath: ${datapath}
  directoryPerDB: true
  journal:
    enabled: true
processManagement:
  fork: true

security:
  authorization: enabled
  keyFile: /path/to/key_file

replication:
  replSetName: ${replSetName}

sharding:
  clusterRole: configsvr

可以看出这是MongoDB分片集群中的一个 config server 节点进程。

请根据如下进程启动命令行生成mongodb 启动的配置文件 mongos.conf

numactl --interleave=all mongos  \
  --keyFile=/path/to/bin/key_file  \
  --port ${dbport} \
  --fork  \
  --logpath /path/to/mongos.log \
  --logappend \
  --configdb "XXX/xx.xx.xx.xx:40001,xx.xx.xx.xx:40001,xx.xx.xx.xx:40001"
net:
  port: ${dbport}
  bindIp: xx.xx.xx.xx  
  
security:
  keyFile: /path/to/key_file
  
processManagement:
  fork: true
  
systemLog:
  destination: file
  path: /path/to/mongos.log
  logAppend: true
 
sharding:
  configDB: "XXX/xx.xx.xx.xx:40001,xx.xx.xx.xx:40001,xx.xx.xx.xx:40001"

可以看出,这是一个MongoDB分片集群中一个mongos节点的配置, configDB: "XXX/xx.xx.xx.xx:40001,xx.xx.xx.xx:40001,xx.xx.xx.xx:40001" 行中的 XXX 为分片集群中config server 副本集的 replSetName。

请根据如下进程启动命令行生成mongodb 启动的配置文件 mongod.conf

numactl --interleave=all mongod \
  --directoryperdb  \
  --auth \
  --shardsvr  \
  --keyFile=/path/to/key_file \
  --wiredTigerCacheSizeGB 45  \
  --dbpath=${datapath} \
  --port ${dbport} \
  --fork \
  --replSet ${replSetName} \
  --logpath /path/to/mongod.log \
  --logappend \
  --maxConns 16000
net:
  port: ${dbport}
  bindIp: xx.xx.xx.xx,127.0.0.1
  maxIncomingConnections: 16000

systemLog:
  destination: file
  path: /path/to/mongod.log
  logAppend: true

processManagement:
  fork: true

storage:
  dbPath: /path/to/db
  directoryPerDB: true
  wiredTiger:
    engineConfig:
      cacheSizeGB: 45

replication:
  replSetName: ${replSetName}

security:
  keyFile: "path/to/key_file"
  authorization: enabled

sharding:
  clusterRole: shardsvr

参考

MongoDB Manual/Replication
https://www.mongodb.com/docs/v4.4/replication/

MongoDB Manual/Sharding
https://www.mongodb.com/docs/v4.4/sharding/

相关文章

  • mongodb 常用命令

    Mongodb启动 配置mongodb启动配置文件 连接mongodb服务器 mongod -f conf/mon...

  • Mongodb配置文件

    Mongodb启动命令 mongod --config mongo.config Mongodb配置文件内容

  • MongoDB高级应用之高可用方案实战(4)

    1、MongDB启动与关闭 1.1、命令行启动 1.2、配置文件启动 环境变量配置 2、MongoDB主从搭建 M...

  • MongoDB 配置

    [TOC] Mac 下配置 Mongo MongoDB服务的启动 配置文件方式 如果不想每次启动的时候都在命令行中...

  • mongodb学习笔记

    mongodb安装 命令行客户端操作mongodb 启动mongodb shellmongo 登录指定host和p...

  • mongodb入门学习

    Mongodb: 启动命令 ./mongod –f mongodb.conf 配置文件示例 dbpath = /u...

  • 宝塔安装mongodb无法开启解决笔记!

    宝塔mongodb安装v4.4.6面板上无法启动.service mongodb start命令行启动提示如下,打...

  • mongodb守护进程启动

    新增配置文件 mongodb.conf 启动 ./bin/mongod -f mongodb.conf 报错处理 ...

  • 安装mongodb

    mac安装 使用home-brew安装mongoldb 默认的配置文件启动mongodb 下载mongodb可视化...

  • mongodb 命令备忘

    配置文件方式 如果不想每次启动的时候都在命令行中输入很多繁琐的参数,可以把参数信息保存在配置文件中MongoDB ...

网友评论

      本文标题:【MongoDB】MongoDB根据启动命令行生成配置文件

      本文链接:https://www.haomeiwen.com/subject/zjwtfjtx.html