单机安装
yum install nfs-utils -ysudo systemctl enable rpcbindsudo systemctl enable nfs
启动
sudo systemctl restart rpcbindsudo systemctl restart nfs
数据共享
mkdir /data/nfschmod 755 /data/nfsvi /etc/exports/data/nfs/ *(rw,sync,no_root_squash,no_all_squash)systemctl restart nfsshowmount -e localhost
安装nfs的playbook,实现开机自启
- name: Install and configure NFS server hosts: modify ###如果共享目录是/data/nfs,就只需修改这里 tasks: - name: Install NFS server package yum: name: nfs-utils state: present - name: ensure and start nfs systemd: name: nfs enabled: yes state: started - name: Create shared directory file: path: /data/nfs state: directory mode: '0755' - name: Configure NFS exports lineinfile: path: /etc/exports line: "/data/nfs *(rw,sync,no_root_squash)" state: present handlers: - name: restart nfs service: name: nfs state: restarted