如何使用bitnami/mongodb-sharded和docker-compose禁用写关注?

m4pnthwp  于 2023-08-04  发布在  Go
关注(0)|答案(1)|浏览(103)

我使用来自bitnami/mongodb-sharded文档的docker-compose示例文件创建了一个共享集群。像这样:

curl -sSL https://raw.githubusercontent.com/bitnami/containers/main/bitnami/mongodb-sharded/docker-compose.yml > docker-compose.yml
docker-compose up -d

字符串
我使用Prisma连接到数据库,发生了以下错误:

writeConcern is not allowed within a multi-statement transaction


现在我需要知道hot来禁用使用ENV变量的写关注
这是我的docker-compose.yml:

# Copyright VMware, Inc.
# SPDX-License-Identifier: APACHE-2.0

version: '2'

services:
  mongodb-sharded:
    image: docker.io/bitnami/mongodb-sharded:6.0
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-sharded
      - MONGODB_SHARDING_MODE=mongos
      - MONGODB_CFG_PRIMARY_HOST=mongodb-cfg
      - MONGODB_CFG_REPLICA_SET_NAME=cfgreplicaset
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_ROOT_PASSWORD=password123
    ports:
      - "27017:27017"

  mongodb-shard0:
    image: docker.io/bitnami/mongodb-sharded:6.0
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-shard0
      - MONGODB_SHARDING_MODE=shardsvr
      - MONGODB_MONGOS_HOST=mongodb-sharded
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=shard0
    volumes:
      - 'shard0_data:/bitnami'

  mongodb-cfg:
    image: docker.io/bitnami/mongodb-sharded:6.0
    environment:
      - MONGODB_ADVERTISED_HOSTNAME=mongodb-cfg
      - MONGODB_SHARDING_MODE=configsvr
      - MONGODB_ROOT_PASSWORD=password123
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_KEY=replicasetkey123
      - MONGODB_REPLICA_SET_NAME=cfgreplicaset
    volumes:
      - 'cfg_data:/bitnami'

volumes:
  shard0_data:
    driver: local
  cfg_data:
    driver: local

kcugc4gi

kcugc4gi1#

尝试设置replicaSet设置和默认RW问题,例如

cfg = rs.conf()
cfg.settings.getLastErrorDefaults.w = 1
cfg.settings.getLastErrorDefaults.wtimeout = 0
rs.reconfig(cfg)

db.adminCommand({ getDefaultRWConcern: 1 })

db.adminCommand({
   setDefaultRWConcern: 1,
   defaultWriteConcern: { w: "majority", wtimeout: 3600 }
})

字符串
我不认为你可以在任何设置中设置它。

相关问题