2017-06-06 35 views
0

我红帽7的启动的MongoDB - 权限被拒绝的插座:127.0.0.1:27025

listen(): bind() failed errno:13 Permission denied for socket: 127.0.0.1:27025 
systemd[1]: mongod.service: main process exited, code=exited, status=100/n/a 

mongod.service后得到一个埃罗日志

[Unit] 
    Description=High-performance, schema-free document-oriented database 
    After=network.target 

[Service] 
    User=mongod 
    Group=mongod 
    Environment="OPTIONS=--quiet -f /etc/mongod1.conf" 
    ExecStart=/usr/bin/mongod $OPTIONS run 
    ExecStartPre=/usr/bin/mkdir -p /var/run/mongodb 
    ExecStartPre=/usr/bin/chown root:root /var/run/mongodb 
    ExecStartPre=/usr/bin/chmod 0755 /var/run/mongodb 
    PermissionsStartOnly=true 
    PIDFile=/var/run/mongodb/mongod1.pid 


[Install] 
    WantedBy=multi-user.target 

mongod1.conf

#systemLog: 
    destination: file 
    logAppend: true 
    path: /home/telenstanley/mongod1.log 

# Where and how to store data. 
storage: 
    dbPath: /var/lib/mongo/db1 
    journal: 
    enabled: true 
# engine: 
    mmapv1: 
    smallFiles: true 
# wiredTiger: 

# how the process runs 
processManagement: 
    fork: false # fork and run in background 
    pidFilePath: /var/run/mongodb/mongod1.pid # location of pidfile 

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


#security: 
# authorization: enabled 
#operationProfiling: 

replication: 
    oplogSizeMB: 1024 
    replSetName: testrep 
#sharding: 

## Enterprise-Only Options 

我无法找到任何有用的答案我的问题yet.but的mongod的从CMD

须藤的mongod -f mongod1.conf

回答

0

发现一对夫妇的时间后的答案..

您必须配置的SELinux允许的MongoDB启动基于Linux Red Hat系统(红帽企业Linux部份或CentOS Linux的)。

权限问题通过访问SELinux的相关端口(例如27017)来解决,如果处于强制模式。有关MongoDB默认端口的更多信息,请参阅默认MongoDB端口。对于默认设置,这可以通过运行完成

semanage port -a -t mongod_port_t -p tcp 27025 
1

我的mongod运行为root用户启动成功。服务有

ExecStartPre=/usr/bin/chown mongod:mongod /var/run/mongodb 

,而不是

ExecStartPre=/usr/bin/chown root:root /var/run/mongodb 

拥有者是mongod而不是root。

+0

已经试过了,没用! –

+0

您是否检查过所有mongo文件夹的所有者? –