Final Project NFS and NIS jwbai Computer Center
Final Project– NFS and NIS jwbai
Computer Center, CS, NCTU Goal master. passwd group netgroup amd. conf user. A, /nis/home/user. A user. B, /nis/home/user. B user. C, /nis/home/user. C host. A Home storage center /home/allhome/user. A /home/allhome/user. B /home/allhome/user. C export /home/partner. C rw to host. C export /home/partner. B ro to host. B host. C 2 export /home/partner. A rw to host. A export /home/partner. C ro to host. C export /home/partner. B rw to host. B export /home/partner. A ro to host. A
Computer Center, CS, NCTU Outline q Team Work - Find at most two partners to finish this job q Labs • Lab 1 – NFS exports and mount • Lab 2 – NIS servers and clients • Lab 3 – NIS, NFS, and amd q Bonus • Bonus – NIS slave server q Appendix • Appendix A – mount_nullfs q Deadline 3
Computer Center, CS, NCTU Labs Lab 1 – NFS exports and mount(1) q Goal: • Export NFS • Import NFS q Requirement: • Mount NFS with correct exports permission q Triangle relationship q Arrow is the direction of exports 4
Computer Center, CS, NCTU Labs Lab 1 – NFS exports and mount(2) q For Partner. A • Make directories as following names Ø % mkdir /home/partner. A Ø % mkdir /home/partner. B Ø % mkdir /home/partner. C • Export /home/partner. A (Relation as previous picture) Ø Modify /etc/exports Ø Read-Only for partner. B, Read-Write for partner. C • Edit /etc/fstab to mount partner. B and partner. C via NFS • Try to Create Files in these two NFS Ø Partner. A can write /home/partber. B, cannot write /home/partner. C q Similarly for Partner. B and Partner. C 5
Computer Center, CS, NCTU 6 Labs Lab 2 – NIS servers and clients(1) q Goal: • NIS master servers, and clients q Requirement: • Share master. passwd, and group • Three NIS accounts, you can choose names you like (everyone has his/her own account) • The group of these accounts is written in NIS group • All NIS accounts can login all NIS clients, but only admin user (the owner of NIS master server gets) can login the NIS master server • No need to take care the home directories, and other filesystems
Computer Center, CS, NCTU Labs Lab 2 – NIS servers and clients(2) q Settings for NIS master server(1) • Copy /var/yp/Makefile. dist to /var/yp/Makefile (original is a symbolic link) • Comment out this line in the Makefile Ø NOPUSH = "True“ #NOPUSH = “True” • To ensure NIS master server reads the shared files from NIS, please modify the GROUP variables to be read from /var/yp/ Ø GROUP = $(YPDIR)/group • Copy master. passwd, group from /etc/ to /var/yp/ 7
Computer Center, CS, NCTU Labs Lab 2 – NIS servers and clients(3) q Settings for NIS master server(2) • Modify master. passwd Ø Delete system accounts, and add three NIS accounts – You can use the names you like, but not be the same as system’s accounts – Notice no collision with local accounts Ø Their home directories in /nis/home/nis_account (Will be done in Lab 3) • Modify group Ø Add a NIS group • Build NIS master server Ø Set domainname Ø Modify /etc/rc. conf Ø % ypinit –m <domainname> Ø Start NIS Master Server 8
Computer Center, CS, NCTU 9 Labs Lab 2 – NIS servers and clients(4) q Settings for NIS clients • Set domainname • Modify /etc/rc. conf • Modify /etc/hosts Ø Add the entry of the NIS server • • Modify /etc/group Modify /etc/master. passwd Start NIS Client Note: The NIS master server also needs to be an NIS client, but only admin user can login
Computer Center, CS, NCTU Labs Lab 3 – NIS, NFS, and amd(1) q Goal: • Continue after Lab 2, using NFS as NIS home q Requirement: • Pick a machine different from the NIS master server to export NFS • Export Read-Write for all Ø /home/allhome (/home/allhome/user. A, …) • maproot=nobody for all clients, but root for NIS master server • Because /etc/exports cannot export one device twice to the same host, please use mount_nullfs to mount this filesystem to /home/for_nis • NFS clients should let NIS users see their home directories at /nis/home/nis_account Ø Symbolic link /nis/home to the amd real mount point Ø Check permission is correct (user can do anything in his own home dir) 10
Computer Center, CS, NCTU Labs Lab 3 – NIS, NFS, and amd(2) q Add some files on the NIS master server • Modify the AMDHOST variables to be read from /var/yp/ Ø AMDHOST = $(YPDIR)/amd. map • Copy amd. map, netgroup from /etc/ to /var/yp/ • Modify amd. map Ø The fstype of NFS SERVER machine (link) is different from that of other NFS CLIENT machine • Modify netgroup Ø Use netgroup to export the NFS, and so add one new client is easy Ø Also, you can add admins in one netgroup for NIS master to set in the master. passwd (Optional) • Rebuild NIS database 11
Computer Center, CS, NCTU Labs Lab 3 – NIS, NFS, and amd(3) q Export NIS Home • Use mount_nullfs to mount this filesystem (/home/allhoome) to /home/for_nis • Modify /etc/exports Ø Export /home/for_nis to all, specify the maproot option. • Modify /etc/rc. conf • Run NFS server q Run amd on all machines • Modify /etc/rc. conf • Start amd • Note: In amd_flags, set the mapname as amd. map, it will automatically search the NIS, you can man amd. conf and see the map_type for more information. 12
Computer Center, CS, NCTU Bonus NIS slave server q Goal: • Pick the machine, which is neither the NFS server nor the NIS master server, and build the NIS slave server. q Requirement: • The NIS slave server can bind itself q Settings for the NIS slave server • • • Set domainname Modify /etc/rc. conf ypinit -s <master> <domainname> Start NIS Slave Server You can read this for more details Ø http: //www. tw. freebsd. org/doc/zh_TW. Big 5/books/handbook/networknis. html 13
Computer Center, CS, NCTU Appendix A – mount_nullfs q $ man exports A host may be specified only once for each local file system on the server and there may be only one default entry for each server file system that applies to all other hosts. q The command • mount_nullfs <origin> <new_path> • For example Ø % mkdir /home/allhome make a directory for Real NFS Home Ø % mkdir /home/for_nis make a directory for NFS Home exports Ø % mount_nullfs /home/allhome /home/for_nis mount it q Use it in /etc/fstab • Change the fstype to nullfs • For example Ø /home/allhome 14 /home/for_nis nullfs rw 2 2
Computer Center, CS, NCTU 15 Deadline q Announced Date: 2010/12/28 q Due Date: 2011/1/11 q Demo
Computer Center, CS, NCTU 16 Help q IRC channel #nctu. NASA on freenode q Newsgroup cs. course. sysadmin q BBS bs 2. to board CS-Sys. Admin q Email ta@nasa. cs. nctu. edu. tw q Goto CSCC to ask professional 3 F!
- Slides: 16