英文:
MongoDB - Windows 10 service autostart fails after enabling Authorization and BindIP change
问题
我在Windows 10上运行MongoDB。它已设置为在系统启动时自动启动。一切正常,但后来我以两种方式更改了配置文件。
存储数据的位置和方式:
storage:
dbPath: C:\Program Files\MongoDB\Server.0\data
journal:
enabled: true
日志数据写入位置:
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server.0\log\mongod.log
网络接口:
net:
port: 27017
bindIp: 10.255.2.155 //在此更改-我的本地网络IP
安全性设置:
security://在此更改
authorization: "enabled" //在此更改
自动启动失败的日志:
{ "t": { "$date": "2023-06-09T05:55:03.534+02:00" }, "s": "I", "c": "CONTROL", "id": 20698, "ctx": "-", "msg": "***** 服务器重新启动 *****" }
{ "t": { "$date": "2023-06-09T05:55:03.564+02:00" }, "s": "I", "c": "NETWORK", "id": 4915701, "ctx": "-", "msg": "已初始化Wire规范", "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": "自动禁用TLS 1.0,要强制启用TLS 1.0,请指定--sslDisabledProtocols 'none'" }
// 更多日志...
当我打开Windows服务并手动启动服务时,它正常工作。为什么手动启动正常,但自动启动失败呢?
我检查了手动启动成功的日志,它们与崩溃行之前的日志相同。
感谢任何建议。
英文:
I am running mongoDB on windows 10 machine. It is setup to autostart on system startup. All worked as expeced but then i changed the configuration file in two ways.
# 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.0\data
journal:
enabled: true
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: C:\Program Files\MongoDB\Server.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:
//Changed HERE comments are here just for you to see. They are not in the config.
Logs of the failed start
{"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."}}}
When i open windows services and manually start the service. It works fine.
How is it possible that manual start works but automatic fails ?
I checked the logs for the sucesfully manual start and they are identical up the the crash line.
Thanx for any suggestions.
I checked the logs for the sucesfully manual start and they are identical up the the crash line.
Thanx for any suggestions.
答案1
得分: 1
我建议使用以下代码之一:
net:
bindIpAll: true
或者
net:
bindIp: localhost
根据您的需求来选择。如果您只想允许本地机器连接,请使用 bindIp: localhost
。如果您想允许远程机器连接,请使用 bindIpAll: true
。
在我看来,bindIp: 10.255.2.155
只在具有多个网络接口的计算机上才有意义。然而,由于 MongoDB 不支持多个接口(请参阅Oracle Exadata Network Interfaces),这也没有太多意义。另外,根据您的网络设置,此 IP 可能随时更改。
请注意,将日志文件、数据文件或配置文件放在 C:\Program Files
文件夹下是相当不常见的。我建议将其放在 %APPDATA%
、%LOCALAPPDATA%
或一个专用文件夹中,例如 C:\MongoDB
。
英文:
I would suggest to use
net:
bindIpAll: true
or
net:
bindIp: localhost
Depending on your requirements. Use bindIp: localhost
if you like to permit connections only from the local machine. Use bindIpAll: true
if you like to permit connections also from remote machines.
In my opinion bindIp: 10.255.2.155
makes only sense on a computer with multiple network interfaces. However, since MongoDB does not support multiple interfaces (see for example Oracle Exadata Network Interfaces) it does not make much sense either.
Also depending on your network settings, this IP may change at any time.
Just a note, it is rather uncommon to put log files or data files or configuration files under C:\Program Files
folder. I would propose a folder under %APPDATA%
, %LOCALAPPDATA%
or a dedicated folder, e.g. C:\MongoDB
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论