无法连接到本地 azure cosmosdb 模拟器
Failed to connect to local azure cosmosdb emulator
我在我的Win10电脑上安装了Azure CosmosDB Emulator,我可以看到启动页面:
但是当我尝试通过 Robo3T 或命令行连接到数据库时,它不起作用。我使用以下命令:
mongo mongodb://localhost:foofoojf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/admin?ssl=true
我遇到了以下问题:
2019-07-18T14:33:27.265+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:10255 after 5000ms milliseconds, giving up.
2019-07-18T14:33:27.266+0200 E QUERY [thread1] Error: couldn't connect to server localhost:10255, connection attempt failed :
connect@src/mongo/shell/mongo.js:237:13
@(connect):1:6
exception: connect failed
它是本地的,所以我假设没有端口问题。是否可能与本地证书或我的公司防火墙有关?
我用ROBO3T工具连接了mongo模拟器,请看我的配置。
首先,从link.
中获取模拟器连接字符串
mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true
然后创建连接配置:
连接:
身份验证:
SSL:
单击“测试”按钮:
UI:
就我而言,要为 MongoDb 与 Azure CosmosDb API 交互,我们需要在 %localappdata%\CosmosDbEmulator 下创建一个专用的新文件夹并启用 MongoDb 端点 v3.6( 请参阅下面的 步骤 1) 中的 PowerShell 命令。
Note: For any reason if CosmosDb emulator is reset to default folder path %localappdata%\CosmosDbEmulator (or) fail to connect in Robo 3T
then always execute the below PowerShell script in Step 1 once again.
Note: From Robo 3T v1.4 onwards we don't have SSL tab in connection
Settings dialog. Instead we have a tab 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.
我在我的Win10电脑上安装了Azure CosmosDB Emulator,我可以看到启动页面:
但是当我尝试通过 Robo3T 或命令行连接到数据库时,它不起作用。我使用以下命令:
mongo mongodb://localhost:foofoojf5%2FR%2Bob0N8A7Cgv30VRDJIWEHLM%2B4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw%2FJw%3D%3D@localhost:10255/admin?ssl=true
我遇到了以下问题:
2019-07-18T14:33:27.265+0200 W NETWORK [thread1] Failed to connect to 127.0.0.1:10255 after 5000ms milliseconds, giving up. 2019-07-18T14:33:27.266+0200 E QUERY [thread1] Error: couldn't connect to server localhost:10255, connection attempt failed : connect@src/mongo/shell/mongo.js:237:13 @(connect):1:6 exception: connect failed
它是本地的,所以我假设没有端口问题。是否可能与本地证书或我的公司防火墙有关?
我用ROBO3T工具连接了mongo模拟器,请看我的配置。
首先,从link.
中获取模拟器连接字符串mongodb://localhost:C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==@localhost:10255/admin?ssl=true
然后创建连接配置:
连接:
身份验证:
SSL:
单击“测试”按钮:
UI:
就我而言,要为 MongoDb 与 Azure CosmosDb API 交互,我们需要在 %localappdata%\CosmosDbEmulator 下创建一个专用的新文件夹并启用 MongoDb 端点 v3.6( 请参阅下面的 步骤 1) 中的 PowerShell 命令。
Note: For any reason if CosmosDb emulator is reset to default folder path %localappdata%\CosmosDbEmulator (or) fail to connect in Robo 3T then always execute the below PowerShell script in Step 1 once again.
Note: From Robo 3T v1.4 onwards we don't have SSL tab in connection Settings dialog. Instead we have a tab 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.