nfs = unix, linux
cifs = windows
@@Physical computer
> nfs utils 패키지 있는지 확인
[root@station14 ~]# rpm -qa | grep nfs
libnfsidmap-0.25-15.el7.x86_64
nfs4-acl-tools-0.3.3-15.el7.x86_64
nfs-utils-1.3.0-0.33.el7_3.x86_64
> 실습 서버가 공유하고 있는 공유 디렉토리 목록 출력
[root@station14 ~]# showmount -e 59.29.224.181
Export list for 59.29.224.181:
/export/courserepos *
/export/autoyast *
/export/home *
/export/tmp *
/export/netinstall *
/export/kickstart *
> /data1이라는 서브 디렉토리 생성
[root@station14 ~]# mkdir /data1
> 공유 디렉토리에 /data1 마운트
[root@station14 ~]# mount -t nfs 59.29.224.181:/export/netinstall /data1
> df -h 확인
[root@station14 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 8.0G 4.6G 3.5G 57% /
devtmpfs 7.8G 0 7.8G 0% /dev
tmpfs 7.8G 54M 7.8G 1% /dev/shm
tmpfs 7.8G 712K 7.8G 1% /run
tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup
/dev/sda1 494M 151M 344M 31% /boot
/dev/mapper/vg0-tmp 1014M 34M 981M 4% /tmp
/dev/mapper/vg0-var 2.0G 671M 1.4G 33% /var
/dev/sda3 100G 4.9G 96G 5% /var/lib/libvirt/images
tmpfs 1.6G 12K 1.6G 1% /run/user/0
59.29.224.181:/export/netinstall 931G 14G 917G 2% /data1 --this check!!
> /data1 디렉토리에 mount된 모습
[root@station14 ~]# ls /data1
CENTOS7 configs postinstalldata README.txt
/etc/fstab 파일에 등록 -> 다음번 부팅할 때, 자동으로 마운트된다.
첫번째 컬럼 : 59.29.224.181:/공유디렉토리명
두번째 컬럼: /data1
세번째 컬럼 : nfs
네번째 컬럼 : mount옵션 -> default
다섯번째 컬럼 : 백업안하므로 -> 0
여섯번째 컬럼 : 파일시스템체크할것인가? 내것도 아니므로 체크 x ->0
문제점: 재부팅할 때 /data1에 마운트할 것이라고 시도를 하는데, nfs 서버에 응답이 없을 경우 계속 시도를 해서 결국 시스템 부팅이 안되는 문제 발생.
AutoFS를 설정하여 마운트하는 것이 일반적!
부팅할 때 마운트하는게 아니라, 필요할 때 자동으로 마운트
AutoFS
@@@VM -nfs server
[root@localhost ~]# vi /etc/exports
/nfsdata 192.168.122.0/24(rw,sync)
> nfs-server 상태 확인
[root@localhost ~]# systemctl status nfs-server
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: inactive (dead)
> nfs server start
[root@localhost ~]# systemctl start nfs-server
[root@localhost ~]# mkdir /nfsdata
[root@localhost ~]# cp /etc/*.conf /nfsdata
[root@localhost ~]# systemctl status nfs-server
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; vendor preset: disabled)
Active: active (exited) since Mon 2023-04-17 16:57:15 KST; 2min 4s ago
Process: 8028 ExecStart=/usr/sbin/rpc.nfsd $RPCNFSDARGS (code=exited, status=0/SUCCESS)
Process: 8026 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=1/FAILURE)
Main PID: 8028 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/nfs-server.service
Apr 17 16:57:15 localhost.localdomain systemd[1]: Starting NFS server and services...
Apr 17 16:57:15 localhost.localdomain exportfs[8026]: exportfs: Failed to stat /nfsdata: No such file or d...ory
Apr 17 16:57:15 localhost.localdomain systemd[1]: Started NFS server and services.
Hint: Some lines were ellipsized, use -l to show in full.
[root@localhost ~]# systemctl restart nfs-server
[root@localhost ~]# showmount -e localhost
Export list for localhost:
/nfsdata 192.168.122.0/24
@@@ physical computer - nfs client 역할
> data2 디렉토리 생성 후 vm에서 공유하는 디렉토리를 마운트 (재부팅 후에도 자동으로 마운트되도록 설정)
[root@station14 ~]# mkdir /data2
[root@station14 ~]# showmount -e vm의 ip
[root@station14 ~]# mkdir /data2
[root@station14 ~]# vi /etc/fstab
vm의ip:/nfsdata /data2 nfs defaults 0 0
[root@station14 ~]# mount -a
[root@station14 ~]# df -h
@@@ physical computer -nfs client
> cifs-utils와 samba있는지 검색
[root@station14 ~]#rpm -qa | grep 새-e samba -e cifs
[root@station14 ~]# smbclient -L 59.29.224.20
[root@station14 ~]# mkdir /data3
[root@station14 ~]# moount -t cifs -o user=administrator //59.29.224.20/windata /data3
[root@station14 ~]# df -h
[root@station14 ~]# ls /data3