Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MongoDB';t在Windows 7上作为服务运行_Mongodb - Fatal编程技术网

MongoDB';t在Windows 7上作为服务运行

MongoDB';t在Windows 7上作为服务运行,mongodb,Mongodb,我在Windows 7中运行MongoDB 3.0服务时遇到问题。 我已经在MongoDB根目录中创建了data/db和data/log,并配置了mongod.conf文件: 已编辑 # mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # where to write logging data. s

我在Windows 7中运行
MongoDB 3.0
服务时遇到问题。 我已经在
MongoDB
根目录中创建了
data/db
data/log
,并配置了
mongod.conf
文件:

已编辑

# mongod.conf

# for documentation of all options, see:
#    http://docs.mongodb.org/manual/reference/configuration-options/

# where to write logging data.
systemLog:
    destination: file
    logAppend: true
    path: C:\Program Files\MongoDB\data\log\mongod.log

# Where and how to store data.
storage:
    dbPath: C:\Program Files\MongoDB\data\db
    journal: 
        enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# how the process runs
processManagement:
    fork: true
    pidFilePath: C:\Program Files\MongoDB\mongod.pid

# network interfaces
# net:
#  port: 27017
#  bindIp: 127.0.0.1  # Listen to local interface only, comment to listen on all interfaces.


#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options

#auditLog:

#snmp:
然后,我创建了一个windows服务,它将在启动时运行mongodb:

sc.exe create MongoDB binPath= "C:\MongoDB\bin\mongod.exe
 --service --config=C:\MongoDB\mongod.conf" displayname= "MongoDB 3.0 Standard"
start= "auto"
我也尝试过:

sc.exe create MongoDB binPath= "\"C:\MongoDB\bin\mongod.exe\" --service --config=\"C:\MongoDB\mongod.conf\"" DisplayName= "MongoDB" start= "auto"
MongoDB服务属性显示可执行文件的路径:

C:\MongoDB\bin\mongod.exe --service --config=C:\MongoDB\mongod.conf
尝试运行服务(net start MongoDB)时显示错误消息:

The service is not responding to the control function.
More help is available by typing NET HELPMSG 2186.
我知道这个问题很流行,但大多数解决方案都会导致错误的路径、文件名/扩展名,这些都不能解决我的问题

更新:

在指定用户下创建windows服务的建议对我也没有帮助(服务启动时会显示相同的消息):

此外,我还尝试通过
services.msc->MongoDB->Properties->logon

Windows事件日志:

Error   6.05.2015 19:54:25  Service Control Manager 7009    None
A timeout was reached (30000 milliseconds) while waiting for the MongoDB service to connect.

Error   6.05.2015 19:54:25  Service Control Manager 7000    None
The MongoDB service failed to start due to the following error: 
The service did not respond to the start or control request in a timely fashion.

我找到了MongoDB服务无法成功启动的解决方案

首先,通过这种方式安装windows mongodb服务,以便在服务安装期间查看您的
YAML
config文件或任何其他文件中的所有类型的错误(在mongodb服务安装期间,sc.exe没有提供足够的ifnormalation):

实际上,我的问题是Windows中不存在的
processManagement.fork
选项,因为它会导致错误
无法识别的processManagement.fork选项。所以,我已经从配置文件中删除了这个选项,服务就可以正常启动了

最终配置文件:

systemLog:  
    destination: file  
    logAppend: true  
    path: C:\Program Files\MongoDB\data\log\mongod.log  
    timeStampFormat: iso8601-utc  

storage:  
    dbPath: C:\Program Files\MongoDB\data\db  
    journal:  
        enabled: true  

processManagement:
    pidFilePath: C:\Program Files\MongoDB\mongod.pid  

net:  
    port: 27017  
    bindIp: 127.0.0.1

我会开始检查访问权限。请注意,当在服务中启动时,默认情况下它是由一个相当有限的用户运行的。首先尝试将其更改为管理员(临时)。以消除访问被拒绝的可能性。你的文件位置相当自命不凡:系统驱动器的根目录我以管理员身份登录,我也以管理员身份运行cmd——还是一样。至于系统驱动器的根目录,这只是暂时的决定,以避免目前路径引用出现问题,例如“C:\Program Files\…”。我不是说你作为UI用户的工作。windows上的服务通常从
本地系统
帐户运行。如果您的服务已正确注册,您可以在services Alt+X/计算机管理/服务和应用程序/服务中找到它。请检查此方法,以通过控制台(
sc.exe
)创建服务,并提供一个非默认用户来运行。不幸的是,这对我没有帮助,请参阅我如何尝试执行此操作的帖子中的“更新”。
mongod.exe --config "C:\Program Files\MongoDB\mongod.cfg" --install
systemLog:  
    destination: file  
    logAppend: true  
    path: C:\Program Files\MongoDB\data\log\mongod.log  
    timeStampFormat: iso8601-utc  

storage:  
    dbPath: C:\Program Files\MongoDB\data\db  
    journal:  
        enabled: true  

processManagement:
    pidFilePath: C:\Program Files\MongoDB\mongod.pid  

net:  
    port: 27017  
    bindIp: 127.0.0.1