无法将 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 文件共享挂载到容器实例会覆盖挂载点中的所有文件。注意显示 here:
Mounting an Azure Files share to a container instance is similar to a
Docker bind mount. Be aware that if you mount a share into a container
directory in which files or directories exist, these files or
directories are obscured by the mount and are not accessible while the
container runs.
因此不建议将 Azure 文件共享挂载到包含用于初始化 Mongo 数据库的文件的现有目录。推荐目录将喜欢路径 /var/logs/
.
非常感谢上面的@Charles Xu 和@Santhosh,你们拯救了我的一天。在这里,我用我的 AKS、mongoDB 和 Azure 文件共享的工作 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
不会再有这个令人头疼的问题了
我正在尝试使用 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 文件共享挂载到容器实例会覆盖挂载点中的所有文件。注意显示 here:
Mounting an Azure Files share to a container instance is similar to a Docker bind mount. Be aware that if you mount a share into a container directory in which files or directories exist, these files or directories are obscured by the mount and are not accessible while the container runs.
因此不建议将 Azure 文件共享挂载到包含用于初始化 Mongo 数据库的文件的现有目录。推荐目录将喜欢路径 /var/logs/
.
非常感谢上面的@Charles Xu 和@Santhosh,你们拯救了我的一天。在这里,我用我的 AKS、mongoDB 和 Azure 文件共享的工作 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
不会再有这个令人头疼的问题了