ОС: CentOS 6 Сервер Mongod: 4.4 Node 10.x
Я установил последнюю версию Mon go server 4.4, используя RPM, запустите службу, используя service mongod start
и используя ps | grep mongo
, чтобы знать, что Mon go работает.
Однако, когда я запускаю netstat -aunlp
, я не видел ни одного порта 27017, работающего Mon go ??
Вот мой 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: /var/log/mongodb/mongod.log
# Where and how to store data.
storage:
dbPath: /var/lib/mongo
journal:
enabled: true
# engine:
# wiredTiger:
# how the process runs
processManagement:
fork: true # fork and run in background
pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile
timeZoneInfo: /usr/share/zoneinfo
# network interfaces
net:
port: 27017
# Using either line didn't work, comment out both lines didn't work.
#bindIp: 127.0.0.1 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
#bindIp: 0.0.0.0 # Enter 0.0.0.0,:: to bind to all IPv4 and IPv6 addresses or, alternatively, use the net.bindIpAll setting.
Вот код NodeJS, который использует Mon go. Ни успех, ни ошибка в console.log не показаны.
var mongoose = require('mongoose');
// Connect to database - both lines didn't work
mongoose.connect('mongodb://localhost/somedb');
//mongoose.connect('mongodb://127.0.0.1/somedb', function(err){console.log({"err": err}); });
mongoose.connection.once('connected', function() {
console.log('Successfully connected to MongoDB.')
}).on('error', function(e){
console.log({"ERR": e});
});
Не могли бы вы помочь мне в этом?
Большое спасибо за вашу помощь заранее.