安装nfs

yum -y install rpcbind nfs-utils
vim /etc/exports
/root/data/rpm *(rw,no_root_squash,no_all_squash,sync)
/data/rpm *(rw,no_root_squash,no_all_squash,sync)
立即生效
exportfs -r
systemctl start rpcbind
systemctl start nfs

systemctl enable rpcbind
systemctl enable nfs
rpcinfo -p 查看端口是否生效。

showmount -e localhost
Export list for localhost:
/data/rpm *

将rpm生成源
cat >create_repo.sh<<EOF
#!/bin/bash
find /data/yum -name "*.rpm" -exec cp -r {} /data/rpm/ \;
cd /data/rpm/
createrepo ./
EOF


crontab -e
*/1 * * * * bash /root/create_repo.sh
客户端
cat >base.repo<<EOF
[base]
name=base
baseurl=file:///data/rpm
enabled=1
gpgcheck=0
EOF
yum -y install rpcbind
showmount -e 192.168.14.132
mkdir /data/rpm
mount -t nfs 192.168.14.132:/root/data/rpm /data/rpm -o nolock,nfsvers=3,vers=3
mount -t nfs 192.168.14.132:/data/rpm /data/rpm -o nolock,nfsvers=3,vers=3

cat >>/etc/rc.d/rc.local<<EOF
mount -t nfs 192.168.14.132:/root/data/rpm /data/rpm -o nolock,nfsvers=3,vers=3
EOF
chmod +x /etc/rc.d/rc.local