您好,欢迎来到知库网。
搜索
您的当前位置:首页Docker Swarm 进阶:NFS 共享数据卷

Docker Swarm 进阶:NFS 共享数据卷

来源:知库网

启动 NFS 服务(CentOS 7)

首先,安装 rpcbind 和 nfs-utils

yum install -y rpcbind nfs-utils

然后,编辑 /etc/exports 配置 NFS 共享目录,示例:

[root@VM_0_5_centos ~]# cat /etc/exports
/root/share *(rw,sync,all_squash,anonuid=0,anongid=0)

启动 rpcbind 和 nfs

sudo service rpcbind start

sudo service nfs start

查看共享的目录

exportfs

修改配置文件后,重新加载配置文件

exportfs -vr

创建 NFS 数据卷

docker volume create --driver local \
    --opt type=nfs \
    --opt o=addr=<NFS-Server>,rw \
    --opt device=:<Shared-Path> \
    share

创建多副本服务

docker service create \
  --mount type=volume,source=<Volume-Name>,destination=<Container-Path> \
  --replicas 2 \
  <Image>

相关文档

补充说明

注意读写分离,避免多写导致未知的错误

Copyright © 2019- zicool.com 版权所有 湘ICP备2023022495号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务