- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我一直在尝试通过 SSH 隧道连接到 EC2 实例并连接到位于同一 VPC 中的 DocumentDB。我已经尝试了所有可以在线挖掘的解决方案,但没有运气。我正在使用 ssh_pymongo 模块,它包装了 SSHTunnelForwarder。我能够直接通过 SSH 连接到 EC2 实例并连接到 DocumentDB 集群。我正在尝试通过 python 实现同样的事情。
示例代码:
from ssh_pymongo import MongoSession
session = MongoSession(
host='ec2-x-x-x-x.region.compute.amazonaws.com',
port=22,
user='ec2-user', # The user ec2-user is specific to EC2 instance OS Amazon Linux 2
key='key.pem',
uri='mongodb://<username>:<password>@xxxxx-docdb-cluster.cluster-xxxxxxxxxxxxx.region.docdb.amazonaws.com:27017'
)
# Note for the above function call: I've also tried various combinations of the to_host and to_port params without success.
db = session.connection['db-name']
print(db.collection_names())
错误:
Could not establish connection from local ('127.0.0.1', 36267) to remote ('xxxxx-docdb-cluster.cluster-xxxxxxxxxxxx.region.docdb.amazonaws.com', 27017) side of the tunnel: open new channel ssh error: Timeout opening channel.
最佳答案
我也尝试过 ssh_pymongo 模块,但没有成功。
但是,我直接尝试使用 sshtunnel 模块,并且能够查询我的数据库。
这是我的代码
from sshtunnel import SSHTunnelForwarder
from pymongo import MongoClient
# VM IP/DNS - Will depend on your VM
EC2_URL = '''*.*.compute.amazonaws.com'''
# Mongo URI Will depende on your DocDB instances
DB_URI = '''dbname.*.*.docdb.amazonaws.com'''
# DB user and password
DB_USER = 'dbuser'
DB_PASS = 'dbpassword'
# Create the tunnel
server = SSHTunnelForwarder(
(EC2_URL, 22),
ssh_username='ubuntu', # I used an Ubuntu VM, it will be ec2-user for you
ssh_pkey='~/.ssh/keypair.pem', # I had to give the full path of the keyfile here
remote_bind_address=(DB_URI, 27017),
local_bind_address=('127.0.0.1', 27017)
)
# Start the tunnel
server.start()
# Connect to Database
client = MongoClient(
host='127.0.0.1',
port=27017,
username='DB_USER',
password='DB_PASS'
)
# Close the tunnel once you are done
server.stop()
我想 3 个月后你会找到一个解决方案,但我会把这个留在这里给其他有同样问题的人
关于Python SSH 隧道进入 EC2 并连接到 DocumentDB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64828294/
AWS DocumentDB“与 MongoDB 兼容”意味着支持 3.6 和 4.0 版 API。我已经在3.6版本恢复数据并保存为快照。 我想知道 AWS 将支持 3.6 版本多长时间。如果万一
我有一个 ARM 模板,用于将 DocumentDB 以及其他 Azure 资源部署到资源组。我希望我的 ARM 模板设置一个使用 DocumentDB 作为输出的流分析作业。为此,ARM 模板创建的
我知道我们可以使用 Mongo shell 启用(或禁用)Amazon Document DB 的更改流。是否可以从 AWS 控制台或 MongoDB 驱动程序启用更改流? 最佳答案 您可以使用mod
我正在尝试查询包含 500M 文档 (1Tb) 的 documentDB。 var t1 = Date.now(); 'Total X Records:'; db.runCommand({aggreg
我在通过 TLS/SSL 使用纯 Java 连接我的 DocumentDB 集群时遇到问题 我按照 AWS docs 遵循的程序这是: 我下载了 .pem来自 AWS 的文件并复制到我的 java 项
我正在尝试使用新的 AWS DocumentDB 服务运行现有应用程序。我试图从 mongo shell 运行db.geojson.createIndex( { geoData : "2dsphere
我尝试使用 REST API 从 DocumentDB 获取文档。我正在使用分区集合,因此需要添加“x-ms-documentdb-partitionkey” header 。如果添加此内容,我会收到
我刚刚创建了一个新的 DocumentDB 实例。当我转到新 Azure 门户上的“ key ”区域时,我没有看到主键或辅助键。我的 URI 已列出。我尝试使用重新生成功能希望能够创建 key ,但没
我正在通过模拟器进行一些本地 DocumentDb 开发。我的 DocumentDb 模拟器已经使用了一两个月了。当我下载 DocumentDb 客户端的最新 Nuget 组件时,我无法连接到它并收到
DocumentDB 不支持“$lookup”运算符,DocumentDB 中 $lookup(MongoDB) 的任何其他替代方案。 这是 DocumentDB 支持的运算符列表。 https://
按照AWS文档,我们尝试使用以下命令列出所有更改流。我们在MongoDB Compass应用程序中提供的MongoSH中运行它。但我们收到一条错误消息:“ReferenceError:DBComman
我正在将具有以下结构的文档插入/更新插入到 DocumentDB 中: 使用默认索引时,更新插入此格式文档的请求费用为 10.67 RU。这似乎比我预期的要高,所以我正在寻求优化。 阅读本文中的性能提
我正在使用 Azure DocumentDB,并且我在 NoSql 中的所有经验都是在 MongoDb 中。我查看了定价模型,成本是按每个系列计算的。在 MongoDb 中,我会为我正在使用的内容创建
Azure 应用程序设置(适用于 azure 函数)有一个用于 DocumentDB 连接字符串的选项 有人知道如何填充/格式化它吗? 我目前使用: var documentDbEndpointUri
我们的数据存储在 documentdb 中。我们确实需要在一笔交易中执行涉及多个文档的操作。有没有办法在 documentDB 上执行类似 sqlserver 的事务? 最佳答案 如果您执行客户端操作
Microsoft Azure 文档 BadRequestException 使用针对未范围索引的路径的筛选器指定了无效查询。考虑在请求中添加允许扫描 header 。 我的查询是: SELECT c
我想弄清楚何时将 Mongodb 索引加载到内存中。假设我有 n 个集合,每个集合都有 m 个索引。那么mongodb启动的时候,会不会把所有n x m的索引都加载到内存中呢? 根据文档,他们提到如果
我最近意识到 DocumentDB 通过 ReplaceDocumentAsync 支持独立更新操作。 我已将下面的更新插入操作替换为替换操作。 var result = _client .U
这是 DocumentDB 上的一个新手问题。我们希望在我们的应用程序中使用 DocumentDB。我们有多个用户更改存储在 DocumentDB 中的数据。我们如何确保一个用户不会覆盖另一用户的更改
是否可以对所有分区集合执行存储过程。如果不是,我怎样才能在不往返的情况下存档? 提前致谢。 最佳答案 不,存储过程在单个分区中执行,并且执行存储过程时没有自动扇出。调用时需要指定分区键。 假设您的意思
我是一名优秀的程序员,十分优秀!