无法连接到远程mongodb但可以在本地连接

时间:2018-02-15 09:53:49

标签: node.js mongodb amazon-ec2

我正在尝试将我的node.js服务器(在ec2实例上)连接到我的mongodb服务器(在ec2实例上但不一样)。一切正常,我可以在本地使用mongo连接到我的mongodb但我的node.js不能。如果我尝试输入此命令,则为事件:

mongo <ec2-instance>/<dbname> -u <username> -p <password> --authenticationDatabase <dbname>

我收到此错误:

  

E QUERY [thread1]错误:无法连接到服务器   :27017,连接尝试失败:   connect@src/mongo/shell/mongo.js:237:13 @(连接):1:6异常:   连接失败

1 个答案:

答案 0 :(得分:0)

2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] MongoDB starting : pid=2888 port=27017 dbpath=/data/db 64-bit host=ip-172-31-23-145
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] db version v3.4.9
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] git version: 876ebee8c7dd0e2d992f36a848ff4dc50ee6603e
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.0.0-fips 29 Mar 2010
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] allocator: tcmalloc
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] modules: none
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] build environment:
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten]     distmod: amazon
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten]     distarch: x86_64
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten]     target_arch: x86_64
    2018-02-15T10:37:08.017+0000 I CONTROL  [initandlisten] options: {}
    2018-02-15T10:37:08.017+0000 W -        [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty.
    2018-02-15T10:37:08.042+0000 I -        [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
    2018-02-15T10:37:08.042+0000 W STORAGE  [initandlisten] Recovering data from the last clean checkpoint.
    2018-02-15T10:37:08.042+0000 I STORAGE  [initandlisten]
    2018-02-15T10:37:08.042+0000 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
    2018-02-15T10:37:08.042+0000 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
    2018-02-15T10:37:08.042+0000 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3480M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),
    2018-02-15T10:37:08.065+0000 E STORAGE  [initandlisten] WiredTiger error (1) [1518691028:65354][2888:0x7f4adae46e00], file:collection-2--1305918998266443804.wt, WT_SESSION.open_cursor: /data/db/collection-2--1305918998266443804.wt: handle-open: open: Operation not permitted
    2018-02-15T10:37:08.065+0000 I -        [initandlisten] Invariant failure: ret resulted in status UnknownError: 1: Operation not permitted at src/mongo/db/storage/wiredtiger/wiredtiger_session_cache.cpp 95
    2018-02-15T10:37:08.065+0000 I -        [initandlisten]

    ***aborting after invariant() failure


    2018-02-15T10:37:08.076+0000 F -        [initandlisten] Got signal: 6 (Aborted).

这是我在我的实例上尝试启动mongod时得到的结果。