无法从本地Windows在Ubuntu EC2实例中连接MongoDB

时间:2018-08-02 06:53:44

标签: database windows mongodb ubuntu amazon-ec2

我已经在ubuntu 16.04上安装了mongodb-clients,mongodb-server。 我已启用该服务,并且该服务运行良好。 为了从远程连接,安全组端口已打开27017。

/etc/mongodb.conf

# /etc/mongodb.conf
#Where to store the data.
dbpath=/var/lib/mongodb

#where to log
logpath=/var/log/mongodb/mongodb.log

logappend=true

#bind_ip = 127.0.0.1
#port = 27017

# Enable journaling, http://www.mongodb.org/display/DOCS/Journaling
journal=true

/etc/init/mongodb.conf

description "MongoDB"

start on runlevel [2345]
stop on runlevel [!2345]

# Recommended ulimit values for mongod or mongos
# See http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
#
limit fsize unlimited unlimited
limit cpu unlimited unlimited
limit as unlimited unlimited
limit nofile 64000 64000
limit rss unlimited unlimited
limit nproc 32000 32000

kill timeout 300 # wait 300s between SIGTERM and SIGKILL.

pre-start script
    mkdir -p /var/lib/mongodb/
    mkdir -p /var/log/mongodb/
end script

script
    ENABLE_MONGODB="yes"
    CONF=/etc/mongodb.conf
    DAEMON=/usr/bin/mongod
    DAEMONUSER=${DAEMONUSER:-mongodb}

    if [ -f /etc/default/mongodb ]; then
        . /etc/default/mongodb
    fi

    # Handle NUMA access to CPUs (SERVER-3574)
    # This verifies the existence of numactl as well as testing that the command works
    NUMACTL_ARGS="--interleave=all"
    if which numactl >/dev/null 2>/dev/null && numactl $NUMACTL_ARGS ls / >/dev/null 2>/dev/null
    then
        NUMACTL="$(which numactl) -- $NUMACTL_ARGS"
        DAEMON_OPTS=${DAEMON_OPTS:-"--config $CONF"}
    else
        NUMACTL=""
        DAEMON_OPTS="-- "${DAEMON_OPTS:-"--config $CONF"}
fi

    if [ "x$ENABLE_MONGODB" = "xyes" ]; then
        exec start-stop-daemon --start --chuid $DAEMONUSER --exec $NUMACTL $DAEMON $DAEMON_OPTS
    fi
end script

尝试远程连接时

E QUERY    Error: couldn't connect to server ec2-13-232-199-50.ap-south-1.compute.amazonaws.com:27017 (13.232.199.50), connection attempt failed
    at connect (src/mongo/shell/mongo.js:181:14)
    at (connect):1:6 at src/mongo/shell/mongo.js:181
2018-08-02T11:44:19.159+0530 D -        User Assertion: 12513:connect failed
exception: connect failed

这可能很愚蠢,我是MongoDB的初学者。有人可以帮忙吗?谢谢

0 个答案:

没有答案