【问题标题】:MongoDB - Permission denied for socket: 127.0.0.1:27025MongoDB - 套接字的权限被拒绝:127.0.0.1:27025
【发布时间】:2017-06-06 11:52:54
【问题描述】:

Redhat 7 重启后我收到错误日志

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

我还没有为我的问题找到任何有用的答案。但是 mongod 通过从 cmd 以 root 用户身份运行成功启动

sudo mongod -f mongod1.conf

【问题讨论】:

    标签: linux mongodb sockets redhat systemd


    【解决方案1】:

    一段时间后找到答案..

    您必须配置 SELinux 以允许 MongoDB 在基于 Red Hat Linux 的系统(Red Hat Enterprise Linux 或 CentOS Linux)上启动。

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

    semanage port -a -t mongod_port_t -p tcp 27025
    

    【讨论】:

      【解决方案2】:

      我的 mongod.service 有

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

      而不是

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

      所有者是 mongod 而不是 root。

      【讨论】:

      • 你检查了所有 mongo 文件夹的所有者吗?
      猜你喜欢
      • 2012-01-18
      • 1970-01-01
      • 2013-12-22
      • 2014-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-07-25
      • 2023-03-09
      相关资源
      最近更新 更多