1

我已经为此奋斗了一段时间。

设想

我们在项目中使用 Cosmos SQL API 和 Cosmos Graph (Gremlin)。很长一段时间以来,我们在开发图形数据库时都被迫使用 Azure 资源。

我希望为 LDE 摆脱这个并使用mcr.microsoft.com/cosmosdb/windows/azure-cosmos-emulator:latest图像在 docker 中运行 Azure CosmosDB 模拟器。使用 docker 的原因是我们有一些来自 IT 公司的奇怪政策,这使得即使是 SQLAPI 也无法让 Azure Cosmos DB Emulator 正常工作。SQL Api 与 docker 映像配合得很好。我正在运行 docker compose。

经过一番调查,我发现该图像实际上并没有寻找要设置的AZURE_COSMOS_EMULATOR_GREMLIN_ENDPOINT:true等环境变量。这是在调查容器中的C:/CosmosDB.Emulator/Start.ps1之后。所以我想我可以通过简单地替换容器中的 Start.ps1 来解决这个问题,停止它,并将其作为新图像提交。

哪个有效!然后我创建了一个用于复制手动步骤的脚本,这样我的团队就不必执行相同的程序。现在它无法正常工作,SQLAPI 和 Azure Cosmos DB Explorer 工作完美,但我无法通过端口 8901 连接 Gremlin,至少一次。

我已经确认在容器启动期间执行的 Start-CosmosDbEmulator 命令设置了 -EnableGremlin 标志。但没有运气,我只是得到:

Unable to connect to the remote server ---> System.Net.Http.HttpRequestException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond..

有没有人有这两个工作?我无法弄清楚问题是什么。

这是我尝试/做过的:

  • 证书被导入并且 https://localhost:8081/_explorer/index.html 是可信的。
  • docker-compose 文件中的端口设置是标准的。
  • 我试图用docker run启动容器,但没有运气。
  • 我 100% 确定启动命令是使用 -EnableGremlin 集运行的。由于脚本日志文件和调查容器中的 Start.ps1 文件。
  • 容器中的 computemachine.config 具有容器管理员用户的“IsGremlinEndpointEnabled”:true。
  • 我使用标准密钥通过 localhost:8901 连接,并创建数据库和容器/集合。
  • 使用 SQLAPI 进行查询可以找到。
    • 注意:当我让它与 Gremlin API 功能一起工作时,它运行良好。

码头工人撰写

version: '2.4' # Do not upgrade to 3.x yet, unless you plan to use swarm/docker stack: https://github.com/docker/compose/issues/4513

networks:
  default:
    external: false
    ipam:
      driver: default
      config:
        - subnet: "172.16.238.0/24"

services:
  cosmosdb:
    container_name: "azurecosmosemulator-sqlapi"
    hostname: "azurecosmosemulator-sqlapi"
    image: 'customimagename'
    platform: windows
    tty: true
    restart: always
    mem_limit: 3GB
    ports:
        - '8081:8081'
        - '8900:8900'
        - '8901:8901'
        - '8902:8902'
        - '10250:10250'
        - '10251:10251'
        - '10252:10252'
        - '10253:10253'
        - '10254:10254'
        - '10255:10255'
        - '10256:10256'
        - '10350:10350'
    environment:
        - AZURE_COSMOS_EMULATOR_PARTITION_COUNT:10
        - AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE:true
        - AZURE_COSMOS_EMULATOR_GREMLIN_ENDPOINT:true
    networks:
      default:
        ipv4_address: 172.16.238.246
    volumes:
        - '${hostDirectoryCosmosDBSQLAPI}:C:\CosmosDB.Emulator\bind-mount'

我没有删除似乎根本没有任何用途的环境变量。但是,如果这对我无法或尚未在容器内调查的代码有任何影响,我已经尝试将它们删除几次。

成绩单日志

**********************
Windows PowerShell transcript start
Start time: 20220204162955
Username: User Manager\ContainerAdministrator
RunAs User: User Manager\ContainerAdministrator
Machine: AZURECOSMOSEMUL (Microsoft Windows NT 10.0.14393.0)
Host Application: powershell.exe -NoExit -NoLogo -Command C:\CosmosDB.Emulator\Start.ps1
Process ID: 1868
PSVersion: 5.1.14393.4583
PSEdition: Desktop
PSCompatibleVersions: 1.0, 2.0, 3.0, 4.0, 5.0, 5.1.14393.4583
BuildVersion: 10.0.14393.4583
CLRVersion: 4.0.30319.42000
WSManStackVersion: 3.0
PSRemotingProtocolVersion: 2.3
SerializationVersion: 1.1.0.1
**********************
Transcript started, output file is C:\CosmosDB.Emulator\bind-mount\Diagnostics\Transcript.log
INFO: Stop-CosmosDbEmulator
INFO: Start-CosmosDbEmulator -AllowNetworkAccess -NoFirewall -NoUI -Key C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==  -Consistency Session -Timeout 300 -EnableGremlin


    Directory: C:\CosmosDB.Emulator\bind-mount


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
-a----         2/4/2022   4:30 PM            804 CosmosDbEmulatorCert.cer

Key   : GremlinEndpoint
Value : {http://azurecosmosemulator-sqlapi:8901/, http://172.16.238.246:8901/}
Name  : GremlinEndpoint


Key   : TableEndpoint
Value : {https://azurecosmosemulator-sqlapi:8902/, https://172.16.238.246:8902/}
Name  : TableEndpoint


Key   : Key
Value : C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==
Name  : Key


Key   : Version
Value : 2.14.5.0
Name  : Version


Key   : IPAddress
Value : 172.16.238.246
Name  : IPAddress


Key   : Emulator
Value : CosmosDB.Emulator
Name  : Emulator


Key   : CassandraEndpoint
Value : {tcp://azurecosmosemulator-sqlapi:10350/, tcp://172.16.238.246:10350/}
Name  : CassandraEndpoint


Key   : MongoDBEndpoint
Value : {mongodb://azurecosmosemulator-sqlapi:10255/, mongodb://172.16.238.246:10255/}
Name  : MongoDBEndpoint


Key   : Endpoint
Value : {https://azurecosmosemulator-sqlapi:8081/, https://172.16.238.246:8081/}
Name  : Endpoint

我希望有人能在这里为我指明正确的方向。也许解决方案是完全跳过这一点,并接受这样一个事实,即我必须在 Azure 中创建集合并针对图形数据库进行处理。

非常感谢任何建议。

4

0 回答 0