Centos 使用nfs配置共享目录使docker集群所有容器日志统一主机访问

Centos 使用nfs配置共享目录,使docker集群所有容器日志统一存放在主机一个共享目录下,供开发人员访问查看

  1. 准备两台或以上Centos 服务器

    复制代码
    192.168.0.1  nfs服务器
    192.168.0.2  nfs客户端
  2. 以root 用户登录192.168.0.1 服务器,执行以下操作

    复制代码
    注意先关闭防火墙;
    service firewalld stop
    systemctl disable firewalld
    
    # 1、安装nfs
    yum -y install nfs-utils rpcbind
       
    # 2、设置开机启动
    systemctl enable nfs.service
    systemctl enable rpcbind.service
       
    # 3、启动rpcbind和nfs
    systemctl restart nfs.service
    systemctl restart rpcbind.service
      
    # 4、编辑共享配置
    vi /etc/exports
      
    # 5、写入共享目录(根据实际情况修改,chmod 777 权限)
    /share *(rw,sync,no_root_squash)
      
    # 6、重新加载
    exportfs -rv
      
    # 7、查看本机共享的nfs目录
    showmount -e
  3. 以root 用户登录192.168.0.2 服务器,执行以下操作进行共享目录挂载

    复制代码
    安装 nfs-utils
    yum install nfs-utils
     
    # 1、查看服务器发布的nfs目录
    showmount -e 192.168.0.1
      
    # 2、创建本地挂载目录(根据实际情况修改),chmod 777 权限
    mkdir -p /share
      
    # 3、挂载服务器目录
    mount -t nfs -o nolock 192.168.0.1:/share /share

docker -v 挂载到容器

复制代码
   docker run -v <宿主机路径>:<容器内路径> <其他选项> <镜像名>
相关推荐
七歌杜金房12 小时前
我终于又有了自己的 Linux 电脑
linux·debian·mac
tntxia2 天前
linux curl命令详解_curl详解
linux
扛枪的书生2 天前
Linux 网络管理器用法速查
linux
顺风尿一寸2 天前
Java Socket 内核之旅:从 SocketChannel.read() 到 tcp_recvmsg 与 epoll 的完整调用链路
linux
lichenyang4532 天前
Docker 学习笔记(五):Docker Compose,用一个 YAML 启动前端、后端和 MongoDB
docker
lichenyang4532 天前
Docker 学习笔记(四):Dockerfile,把项目打成自己的镜像
docker·容器
lichenyang4532 天前
Docker 学习笔记(三):Docker 网络、bridge、子网和容器互通
docker·容器
lichenyang4532 天前
Docker 学习笔记(二):docker run 的参数到底在控制什么?
docker·容器
XIAOHEZIcode2 天前
Ubuntu 终端美化全栈指南:Bash 到 Kitty 踩坑实录
linux·ubuntu·命令行
唐青枫2 天前
别再只会用 cron:Linux systemd Timer 定时任务实战详解
linux