簡體   English   中英

無法在 azure 容器實例中將 azure 文件共享掛載為 mongodb 卷

[英]Unable to mount azure file shares as mongodb volume in azure container instances

我正在嘗試使用 azure 容器實例設置 mongo 數據庫實例並將其安裝在 Azure 文件共享上。

我們收到以下錯誤:

[initandlisten] WiredTiger error (1) [1579245437:724939][1:0x7f9419c67b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted Raw: [1579245437:724939][1:0x7f9419c67b00], connection: __posix_open_file, 667: /data/db/WiredTiger.wt: handle-open: open: Operation not permitted
W  STORAGE  [initandlisten] Failed to start up WiredTiger under any compatibility version.
F  STORAGE  [initandlisten] Reason: 1: Operation not permitted
F  -        [initandlisten] Fatal Assertion 28595 at src/mongo/db/storage/wiredtiger/wiredtiger_kv_engine.cpp 789
[initandlisten] 

***aborting after fassert() failure

AZ 命令我使用以下命令來創建存儲帳戶、文件共享和容器實例:

az storage account create -g $resourcegroup -n $storageaccount --sku Standard_LRS

az storage share create --name $mongofileshare --account-name $storageaccount

az container create --resource-group $resourcegroup --name $containername --image mongo:latest --dns-name-label $DNSName --ports 27017 --protocol TCP --environment-variables 'MONGO_INITDB_ROOT_USERNAME=admin' 'MONGO_INITDB_ROOT_PASSWORD=*******' --location westeurope --azure-file-volume-account-name $storageaccount --azure-file-volume-account-key '**********' --azure-file-volume-share-name 'mongofileshare' --azure-file-volume-mount-path '/data/db'

導致您得到錯誤的原因是將 Azure 文件共享掛載到容器實例將覆蓋掛載點中的所有文件。 該警告顯示在這里

將 Azure 文件共享裝載到容器實例類似於 Docker 綁定裝載。 請注意,如果您將共享掛載到存在文件或目錄的容器目錄中,則這些文件或目錄會被掛載隱藏並且在容器運行時無法訪問。

因此,不建議將 Azure 文件共享掛載到包含用於初始化 Mongo DB 的文件的現有目錄。 推薦目錄將類似於路徑/var/logs/

非常感謝上面的@Charles Xu 和@Santhosh,你們拯救了我的一天。 在這里,我使用 AKS、mongoDB 和 Azure Fileshare 的工作 yaml 總結了他們的解決方案:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo-db
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongo-db
  template:
    metadata:
      labels:
        app: mongo-db
    spec:
      nodeSelector:
        "beta.kubernetes.io/os": linux
      containers:
      - name: mongo-db
        image: mongo:latest
        command: ["mongod"] # Note here
        args: ["--dbpath=/data/mongoaz"] # Note here 
        ports:
        - containerPort: 27017
          name: redis
        resources:
          requests:
            cpu: 250m
          limits:
            cpu: 500m
        volumeMounts:
        - name: db-vol
          mountPath: /data/mongoaz
      volumes:
      - name: db-vol
        persistentVolumeClaim:
          claimName: my-db-pvc

更新:

如果您可以使用 Helm,那會容易得多。 在此處檢查 MongoDB 的 Bitnami 圖表:

https://github.com/bitnami/charts/tree/master/bitnami/mongodb

不會有這種頭疼的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM