Linux environment deployment record (2): linux environment deployment record
NFS file sharing service
Assume that the existing two Server IP addresses are 192.168.0.2 and 192.168.0.3, 192.168.0.2 as the Server, and 192.168.0.3 as the Client, then:
Nfs-utils rpcbind must be installed on both machines:
yum -y install nfs-utils rpcbindchkconfig nfs onchkconfig rpcbind on
Enable Firewall ports 111 and 2049:
/sbin/iptables -I INPUT -p tcp --dport 111 -j ACCEPT/sbin/iptables -I INPUT -p udp --dport 111 -j ACCEPT/sbin/iptables -I INPUT -p tcp --dport 2049 -j ACCEPT/sbin/iptables -I INPUT -p udp --dport 2049 -j ACCEPT/etc/init.d/iptables saveservice iptables restart
Next, create a shared directory on 192.168.0.2:
mkdir -p /home/nfs
Modify the nfs configuration file:
vi /etc/exports
Add the following code:
/home/nfs 192.168.0.0/24(rw,sync,insecure,no_root_squash)
Start the nfs and rpc services:
service rpcbind startservice nfs start
View the nfs shared directory released on the local machine:
showmount -e localhost
As the client 192.168.0.3, you can directly mount the Server Directory to the local directory after starting the service:
mkdir -p /home/nfs_servermount 192.168.0.2:/home/nfs /home/nfs_server
View the mounting status of the file system:
tail -1 /etc/mtab
Set automatic mounting:
vi /etc/fstab
# Add the following code 192.168.0.2:/home/nfs/home/nfs_server nfs ults, rw, _ netdev 0 0