我在Windows 10机器上运行MongoDB。它被设置为在系统启动时自动启动。所有工作如预期,但后来我改变了配置文件在两个方面。
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: C:\Program Files\MongoDB\Server\6.0\data
journal:
enabled: true
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server\6.0\log\mongod.log
# network interfaces
net:
port: 27017
bindIp: 10.255.2.155 //Changed Here -My local network IP
#processManagement:
security://Changed HERE
authorization: "enabled" //Changed HERE
#operationProfiling:
#replication:
#sharding:
## Enterprise-Only Options:
#auditLog:
#snmp:
//修改后的评论在这里只是为了让你看到。它们不在配置中。
启动失败的日志
{"t":{"$date":"2023-06-09T05:55:03.534+02:00"},"s":"I", "c":"CONTROL", "id":20698, "ctx":"-","msg":"***** SERVER RESTARTED *****"}
{"t":{"$date":"2023-06-09T05:55:03.564+02:00"},"s":"I", "c":"NETWORK", "id":4915701, "ctx":"-","msg":"Initialized wire specification","attr":{"spec":{"incomingExternalClient":{"minWireVersion":0,"maxWireVersion":17},"incomingInternalClient":{"minWireVersion":0,"maxWireVersion":17},"outgoing":{"minWireVersion":6,"maxWireVersion":17},"isInternalClient":true}}}
{"t":{"$date":"2023-06-09T05:55:03.577+02:00"},"s":"I", "c":"CONTROL", "id":23285, "ctx":"-","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2023-06-09T05:55:07.032+02:00"},"s":"I", "c":"NETWORK", "id":4648602, "ctx":"thread1","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2023-06-09T05:55:07.073+02:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationDonorService","namespace":"config.tenantMigrationDonors"}}
{"t":{"$date":"2023-06-09T05:55:07.073+02:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"TenantMigrationRecipientService","namespace":"config.tenantMigrationRecipients"}}
{"t":{"$date":"2023-06-09T05:55:07.073+02:00"},"s":"I", "c":"REPL", "id":5123008, "ctx":"thread1","msg":"Successfully registered PrimaryOnlyService","attr":{"service":"ShardSplitDonorService","namespace":"config.tenantSplitDonors"}}
{"t":{"$date":"2023-06-09T05:55:07.073+02:00"},"s":"I", "c":"CONTROL", "id":5945603, "ctx":"thread1","msg":"Multi threading initialized"}
{"t":{"$date":"2023-06-09T05:55:07.073+02:00"},"s":"I", "c":"CONTROL", "id":23316, "ctx":"thread1","msg":"Trying to start Windows service","attr":{"serviceName":"MongoDB"}}
{"t":{"$date":"2023-06-09T05:55:07.077+02:00"},"s":"I", "c":"CONTROL", "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":3852,"port":27017,"dbPath":"C:/Program Files/MongoDB/Server/6.0/data","architecture":"64-bit","host":"TOPCORE_Process_1"}}
{"t":{"$date":"2023-06-09T05:55:07.077+02:00"},"s":"I", "c":"CONTROL", "id":23398, "ctx":"initandlisten","msg":"Target operating system minimum version","attr":{"targetMinOS":"Windows 7/Windows Server 2008 R2"}}
{"t":{"$date":"2023-06-09T05:55:07.077+02:00"},"s":"I", "c":"CONTROL", "id":23403, "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"6.0.2","gitVersion":"94fb7dfc8b974f1f5343e7ea394d0d9deedba50e","modules":[],"allocator":"tcmalloc","environment":{"distmod":"windows","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2023-06-09T05:55:07.078+02:00"},"s":"I", "c":"CONTROL", "id":51765, "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Microsoft Windows 10","version":"10.0 (build 17763)"}}}
{"t":{"$date":"2023-06-09T05:55:07.078+02:00"},"s":"I", "c":"CONTROL", "id":21951, "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"config":"C:\\Program Files\\MongoDB\\Server\\6.0\\bin\\mongod.cfg","net":{"bindIp":"10.255.2.155","port":27017},"security":{"authorization":"enabled"},"service":true,"storage":{"dbPath":"C:\\Program Files\\MongoDB\\Server\\6.0\\data","journal":{"enabled":true}},"systemLog":{"destination":"file","logAppend":true,"path":"C:\\Program Files\\MongoDB\\Server\\6.0\\log\\mongod.log"}}}}
{"t":{"$date":"2023-06-09T05:55:07.084+02:00"},"s":"E", "c":"CONTROL", "id":20568, "ctx":"initandlistend","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"The requested address is not valid in its context."}}}
当我打开windows服务并手动启动服务时。它工作正常。怎么可能手动启动工作,但自动启动失败?
我检查了成功手动启动的日志,它们在崩溃线上是相同的。Thanx任何建议。
我检查了成功手动启动的日志,它们在崩溃线上是相同的。Thanx任何建议。
1条答案
按热度按时间70gysomp1#
我建议使用
或
根据您的要求。如果只允许从本地计算机进行连接,请使用
bindIp: localhost
。如果您也希望允许来自远程计算机的连接,请使用bindIpAll: true
。在我看来,
bindIp: 10.255.2.155
只在具有多个网络接口的计算机上才有意义。然而,由于MongoDB不支持多个接口(例如Oracle Exadata Network Interfaces),因此它也没有多大意义。此外,根据您的网络设置,此IP可能随时更改。请注意,将日志文件或数据文件或配置文件放在
C:\Program Files
文件夹下是相当罕见的。我建议在%APPDATA%
,%LOCALAPPDATA%
或专用文件夹下创建一个文件夹,例如:C:\MongoDB