I am getting an erro log after the reboot of 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
I am not able to find any useful answer for my problem yet.but the mongod starts successfully by running as root user from cmd
sudo mongod -f mongod1.conf
found the answer after a couple of time..
You must configure SELinux to allow MongoDB to start on Red Hat Linux-based systems (Red Hat Enterprise Linux or CentOS Linux).
The permission issue is solved by making access to the relevant ports (e.g. 27017) for SELinux if in enforcing mode. See Default MongoDB Port for more information on MongoDB’s default ports. For default settings, this can be accomplished by running
semanage port -a -t mongod_port_t -p tcp 27025