【问题标题】:Can't connect to mongodb on remote but can on local无法远程连接到mongodb,但可以在本地连接
【发布时间】:2018-07-26 00:47:58
【问题描述】:

我正在尝试将我的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 @(connect):1:6 异常: 连接失败

【问题讨论】:

  • 您可能需要打开 EC2 实例上的传入端口
  • 我不认为问题来自这里。一切都很好,但我的 mongodb 服务器崩溃了(我知道为什么)并且不会重新启动。我让它工作了一分钟,但现在不能再工作了

标签: node.js mongodb amazon-ec2


【解决方案1】:
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 时得到的结果..

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-12
    • 2018-11-12
    • 2017-05-16
    • 2019-05-28
    • 1970-01-01
    相关资源
    最近更新 更多