【发布时间】:2021-07-29 10:30:21
【问题描述】:
我有三台服务器的负载平衡,1 是主服务器通过隧道 ssh 使用猫鼬将数据从服务器 2 和 3 存储到数据库中,目前我只有一个端口,比如说 1900,但我想增加副本成员 3 或更多,任何人知道怎么做吗?
抱歉,英文可能不正确,谢谢
const config = {
username: 'root',
host: '128.199.xx.xx',
port: 22,
agent: 345,
dstPort: 1900,
password: 'xxx'
};
tunnel(config, function (error, server) {
mongoose
.connect("mongodb://localhost:1900/db_name", {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
useCreateIndex: true,
replicaSet: "rs",
})
.then(() => {
console.log("MongoDB Connected");
})
});
【问题讨论】: