如何分别在主机上配置Rocket Chat和MongoDB?

sulc1iza  于 2022-11-28  发布在  Go
关注(0)|答案(1)|浏览(162)

我正在尝试在不同的主机上安装和配置rocketchat和mongodb。一个用于应用程序,另一个用于mongodb。我遵循这个教程https://rocket.chat/docs/installation/manual-installation/ubuntu/
我分别完成了每个部分的所有步骤(mongodb和rocketchat)
当我运行main.js命令时:
MONGO_URL=mongodb://<mongodb-ip-host>:27017/rocketchat?replicaSet=rs01 MONGO_OPLOG_URL=mongodb://<mongodb-ip-host>:27017/local?replicaSet=rs01 ROOT_URL=http://0.0.0.0:3000 PORT=3000 node /var/Rocket.Chat/main.js
我得到这个错误如下:

throw(ex);
                        ^

MongoNetworkError: failed to connect to server [127.0.0.1:27017] on first connect [Error: connect ECONNREFUSED 127.0.0.1:27017
    at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1137:16) {
  name: 'MongoNetworkError',
  errorLabels: [Array],
  [Symbol(mongoErrorContextSymbol)]: {}
}]
    at Pool.<anonymous> (/var/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/topologies/server.js:431:11)
    at Pool.emit (events.js:311:20)
    at /var/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/pool.js:557:14
    at /var/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connect.js:39:11
    at callback (/var/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connect.js:261:5)
    at Socket.<anonymous> (/var/Rocket.Chat/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb-core/lib/connection/connect.js:286:7)
    at Object.onceWrapper (events.js:418:26)
    at Socket.emit (events.js:311:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)
    at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
    at processTicksAndRejections (internal/process/task_queues.js:84:21) {
  name: 'MongoNetworkError',
  errorLabels: [ 'TransientTransactionError' ],
  [Symbol(mongoErrorContextSymbol)]: {}
}

PS.:我把RocketChat设置在/var/Rocket.chat文件夹下
我想了解为什么应用程序某些部分试图在mongodb中进行本地连接:127.0.0.1:27017

u3r8eeie

u3r8eeie1#

我认为问题出在您的mongodb服务器的副本集中。它被错误地配置了127.0.0.1mongodb服务器的www.example.com IP地址。
您可以在mongodb服务器的shell中获得此命令。mongomongosh取决于您的mongodb版本。我在这里使用mongo,但您可能需要使用mongosh

$ mongo
> rs.conf()

mongojsrs.conf()函数调用的结果应该类似于以下内容:

{
        "_id" : "rs01",
        "version" : 2,
        "protocolVersion" : NumberLong(1),
        "writeConcernMajorityJournalDefault" : true,
        "members" : [
                {
                        "_id" : 0,
                        "host" : "127.0.0.1:27017",
                        "arbiterOnly" : false,
                        "buildIndexes" : true,
                        "hidden" : false,
                        "priority" : 1,
                        "tags" : {

                        },
                        "slaveDelay" : NumberLong(0),
                        "votes" : 1
                }
        ],
        "settings" : {
                "chainingAllowed" : true,
                "heartbeatIntervalMillis" : 2000,
                "heartbeatTimeoutSecs" : 10,
                "electionTimeoutMillis" : 10000,
                "catchUpTimeoutMillis" : -1,
                "catchUpTakeoverDelayMillis" : 30000,
                "getLastErrorModes" : {

                },
                "getLastErrorDefaults" : {
                        "w" : 1,
                        "wtimeout" : 0
                },
                "replicaSetId" : ObjectId("<<masked>>")
        }
}

请注意,副本集的主机配置为127.0.0.1:27017
这可以通过在副本集所在的mongo服务器上的mongo shell中执行以下命令来修复。

> cfg = rs.conf()
> cfg.members[0].host = "mongodb-server-ip:27017"
> rs.reconfig(cfg)

您可以在此处阅读更多信息:
https://github.com/RocketChat/Rocket.Chat/issues/26519

相关问题