Couchbase with Docker Compose:无法插入 - DurabilityImpossibleError

Couchbase with Docker Compose: Unable to insert - DurabilityImpossibleError

我正在尝试使用 Docker-Compose 将 Couchbase 设置为服务器集合的一部分。这样做的唯一目的是为了本地应用程序开发。

问题是,一旦设置好,我就无法写入数据库。 Insert 和 Upsert 操作给我一个 DurabilityImpossibleError。

Docker 撰写文件:

version: '3.4'

services:

...


  couchbase-db:
    image: couchbase/server
    volumes:
      - ./docker-data/couchbase/node3:/opt/couchbase/var
      - ./provision/couchbase:/opt/startup/
    ports:
      - 8091:8091
      - 8092:8092 
      - 8093:8093 
      - 8094:8094
      - 11210:11210

构建后 运行 的启动 bash 脚本是尝试在不需要手动步骤的情况下执行数据库设置:


#!/bin/bash

# Enables job control
set -m

# Enables error propagation
set -e

# Run the server and send it to the background
/entrypoint.sh couchbase-server &

# Check if couchbase server is up
check_db() {
  curl --silent http://:8091/pools > /dev/null
  echo $?
}

# Variable used in echo
i=1
# Echo with
log() {
  echo "[$i] [$(date +"%T")] $@"
  i=`expr $i + 1`
}

# Wait until main server is ready
until [[ $(check_db 127.0.0.1) = 0 ]]; do
  >&2 log "Waiting for Couchbase Server to be available ..."
  sleep 1
done

couchbase-cli cluster-init -c localhost:8091 \
        --cluster-username Administrator --cluster-password password \
        --cluster-password password --services data,index,query --cluster-ramsize 512 \
        --cluster-index-ramsize 256 || true
couchbase-cli setting-cluster -c localhost:8091 -u Administrator -p password \
        --cluster-username Administrator --cluster-password password \
        --cluster-password password --cluster-ramsize 512 \
        --cluster-index-ramsize 256;
couchbase-cli setting-cluster -c localhost:8091 \
        -u Administrator -p password --cluster-username Administrator \
        --cluster-password password --cluster-ramsize 512 --cluster-index-ramsize 256;
curl -v POST http://localhost:8091/pools/default/buckets \
        -u Administrator:password \
        -d name=organisations \
        -d bucketType=couchbase \
        -d ramQuotaMB=512 \
        -d durabilityMinLevel=majorityAndPersistActive
curl -v -X POST -u Administrator:password \
        http://localhost:8091/settings/indexes \
        -d indexerThreads=4 \
        -d logLevel=verbose \
        -d maxRollbackPoints=10 \
        -d storageMode=plasma \
        -d memorySnapshotInterval=150 \
        -d stableSnapshotInterval=40000

# Need to wait until query service is ready to process N1QL queries
echo "$(date +"%T") Waiting ........."
sleep 20

# Create bucket1 indexes
echo "$(date +"%T") Create bucket1 indexes ........."
cbq -u Administrator -p password -s "CREATE PRIMARY INDEX idx_primary ON \`organisations\`;"
cbq -u Administrator -p password -s "CREATE INDEX idx_type ON \`organisations\`(_type);"

如果我尝试通过 Web 界面添加文档,我得到:

 Errors from server: ["Unexpected server error, request logged."]

如果我尝试通过 JavaScript SDK 添加文档,我得到:


DurabilityImpossibleError  durability impossible
details:
{
   name: 'DurabilityImpossibleError',
   cause: LibcouchbaseError: libcouchbase error 308
   at Object.translateCppError 
   (/app/node_modules/couchbase/dist/bindingutilities.js:174:21)
   at /app/node_modules/couchbase/dist/connection.js:245:54 {
      code: 308
   },
   context: KeyValueErrorContext {
     status_code: 0,
     opaque: 0,
     cas: CbCas {
       '0': <Buffer 00 00 00 00 00 00 00 00>
     },
     key: '22738bd4-7972-4370-85a3-71399d96ef05',
     bucket: '',
     collection: '',
     scope: '',
     context: '',
     ref: ''
   }
 }

我还尝试使用 insert/upsert 发送以下设置,但没有效果:


  insertOptions: {
    durabilityLevel: 0,
    durabilityPersistTo: 1,
    durabilityReplicateTo: 0,
    timeout: 5000,
  },

我最近的修复尝试是在 docker-compose 中构建一个包含 3 个节点的集群,并调用 API 命令以“添加服务器”作为构建脚本的一部分。但是,“添加服务器”采用静态 IP,因此我第二次 运行 服务器时,IP 发生变化,数据库变得无响应。不过,我确实在第一个 运行 上获得了一个正常运行的数据库。

我正在寻找针对单节点系统的修复(或我哪里出错的想法),或者让集群在 Docker-Compose 中工作的方法 [= =37=]循环。任何能给我一个稳定的发展环境的东西。

谢谢!

使用 -d durabilityMinLevel=majorityAndPersistActive 创建存储桶,默认情况下存储桶启用 1 个副本。

对于单节点集群,您将没有足够的数据节点来满足持久性 (https://docs.couchbase.com/server/current/learn/data/durability.html)。您可以通过 UI 禁用副本并重新平衡以生效或更改不包括最小持久性的存储桶设置。

我不知道 3 节点 docker 撰写错误。