我在Win10计算机上安装了Azure CosmosDB Emulator,并且可以看到启动页面:
但是当我尝试通过Robo3T或命令行连接到数据库时,它不起作用。我使用以下cmd:
mongo mongodb://localhost:foofoojf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/admin?ssl=true
我遇到了以下问题:
2019-07-18T14:33:27.265 + 0200 W网络[thread1]在5000ms毫秒后无法连接到127.0.0.1:10255,放弃了。 2019-07-18T14:33:27.266 + 0200 E查询[thread1]错误:无法连接到服务器localhost:10255,连接尝试失败: connect@src/mongo/shell/mongo.js:237:13 @(连接):1:6 例外:连接失败
它在本地,所以我认为没有端口问题。
答案 0 :(得分:1)
我用ROBO3T工具连接了mongo模拟器,请参阅我的配置。
首先,从此link获取仿真器连接字符串。
mongodb:// localhost:C2y6yDjf5 / R + ob0N8A7Cgv30VRDJIWEHLM + 4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw / Jw == @ localhost:10255 / admin?ssl = true
然后创建连接配置:
连接:
身份验证:
SSL:
点击测试按钮:
UI:
答案 1 :(得分:0)
就我而言,要与用于MongoDb的Azure CosmosDb API进行交互,我们需要在%localappdata%\ CosmosDbEmulator下创建一个专用的新文件夹,并启用MongoDb端点v3.6(请参见以下步骤1中的PowerShell命令< / strong> )。
注意: 出于任何原因,如果将CosmosDb仿真器重置为默认文件夹路径%localappdata%\ CosmosDbEmulator(或)在Robo 3T中无法连接 然后始终在步骤1 中再次执行以下PowerShell脚本。
注意: 从Robo 3T v1.4开始,我们没有SSL标签 设置对话框。相反,我们有一个TLS标签。
1. Download and install Azure CosmosDb Emulator from https://docs.microsoft.com/en-us/azure/cosmos-db/local-emulator?tabs=powershell%2Cssl-netstd21
2. Download and install Robo 3T (1.4.2 or latest) from https://robomongo.org/download
3. To show Azure CosmosDb emulator related database(s) in Robo 3T client app
Step 1
- Launch Azure CosmosDb Emulator
(Optional: Just to check CosmosDbEmulator is started successfully)
- Open Powershell as administrator and execute below commands
# PowerShell Script
# Change directory to default location where CosmosDb emulator is installed.
cd\
cd '.\Program Files\Azure Cosmos DB Emulator\'
# [Optional] If any cosmosDb emulator instance is running then shutdown
.\Microsoft.Azure.Cosmos.Emulator.exe /shutdown
# To interact Azure CosmosDb API for MongoDb, create a new folder "<MongoDb>" under
# %localappdata%\CosmosDbEmulator and enable MongoDb endpoint v3.6
.\Microsoft.Azure.Cosmos.Emulator.exe /DataPath="$env:localappdata\CosmosDBEmulator\MongoDb" /EnableMongoDbEndpoint=3.6
Step 2
- Now CosmosDb emulator will be successfully started,
and launches the URL https://localhost:8081/_explorer/index.html in the browser
- Note down MongoDb connection string details from browser which will be required
while creating new Robo 3T connection. The default MongoDb connection string format is
mongodb://username:password@host:port/[database]?ssl=true
- Username: localhost
- Password (Primary Key): C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
- Port: 10255
- Database: admin
Step 3
- Launch Robo 3T
- Click on Create new connection
- In "Connection" tab
- Provide Name of the connection as "<CosmosDbEmulator>"
- Add port number as 10255
- In "Authentication" tab provide details noted down in previous Step 2
- Check "Perform authentication"
- Add Database as "admin"
- Add Username as "https://localhost:8081"
- Add Password as "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw=="
- In "TLS" tab provide
- Check "Use TLS protocol"
- From Authentication Method dropdown select "Self-signed Certificate"
- Click on "Test" button.
- It should successfully connects to localhost:10255 via TLS tunnel
- It should successfully authorise to database "admin"
- Click on "Save" button
- Click on "Connect" button.
- It will show the admin database and its related collections.