1 / 49

Unix Linux Administration III

Unix Linux Administration III. Class 1: Solaris administration, package management and networking. Introduction to Perl. Class details. We will be working primarily with Solaris x86 this quarter.

shasta
Télécharger la présentation

Unix Linux Administration III

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix Linux Administration III Class 1: Solaris administration, package management and networking. Introduction to Perl.

  2. Class details We will be working primarily with Solaris x86 this quarter. We will allocate sometime in class for lab work but you should expect some remote work each week to be completed on your “production” build. Just as we did last quarter, in class we will try to use a local Solaris “development” install.

  3. Agenda • Introduction to Solaris 10. • Package management options for Solaris • UnixPackages (sunfreeware). • OpenCSW • Solaris networking • Intro to Perl

  4. Q3, Class 1, Unit 1 What we are going to cover: • Oracle & SUN and Solaris What you should leave this session with: • A little history about SUN and Oracle • Basic shell functionality and user management.

  5. ISO download Start to download Solaris ISO now: https://www.ulcert.uw.edu/ISO/sol-10-u9-ga-x86-dvd.iso

  6. Brief history of SUN Sun was founded in 1982 by three Stanford graduate students later joined by Bill Joy. The name SUN came from Stanford University Network. Sun sold proprietary and commodity hardware and much of the revenue stream was tied to this and support. later sun focused on multi-threading and multiprocessing which was seen in the Niagara chip sets found in the T series servers. Sun has had been working with Fujitsu to bring to market a new chip found in the M series servers used for mid to high range servers. IBM almost acquired by SUN in 2009 but the deal fell through. Oracle stepped up next to purchase SUN, the acquisition was completed on January 27th, 2010.

  7. Acquisitions of note by SUN Cray Business Systems – one of the founding super computer companies. I-planet – sun web server is based on this acquisition StarOffice – answer to MSOffice NetBeans – Sun IDE based on this acquisition MySQL – database solution VirtualBox – alternative to VMware and other virtualization products. There are of course lots of others these are just a sampling.

  8. What does Oracle plan to do? According to Larry Ellison • Spend more $$ on SPARC than SUN did. • Spend more $$ on Solaris than SUN did. • Increase sales and support for hardware • Provide a complete stack. Think SPARC chips, Solaris, Oracle, BEA. They will provided certified solutions from end to end. • While lately it has been reported that hardware sales are dropping for Oracle we are still seeing significant effort from them regarding the hardware and software line. Solaris 11 was released 11/9/2011. • Oracle has continued the hardware roadmap and released new hardware since the acquisition.

  9. SPARC and x86 history Every release of Solaris 10 since it was introduced in January 2005 has shipped for SPARC and X86 concurrently. The only difference in the versions is relevant to the CPU instructions. Sun now also ships a broad line of AMD and Intel powered x86 servers. All of these are certified for Solaris x86 Sun has supported other hardware in the past such as the Power PC (granted for a short time). Solaris has been developed on x86 hardware for a long time and has always been ported to SPARC at completion. Solaris has had 64 bit support since Solaris 7 circa 95

  10. Solaris user management From the GUI Solaris leverages the Solaris Management Console (SMC) to create accounts. There is also a cmd line version of this tool available which provides some additional features related to configuring users and interacting with naming services.

  11. Solaris user management cont. Solaris also provides access to tools and functions which closely mimic those found on your Centos and Debian hosts. • /usr/sbin/useradd | userdel | usermod • /usr/sbin/groupadd | groupmod | groupdel Typical syntax to create an account /usr/sbin/useradd –g <primary group> -G <secondary group> -d /export/home/<userid> -m –s /bin/SHELL –c “Comment” <userid>

  12. Shell initialization files C, Bourne, Korn and Bash initialization processes are slightly different. When the bash initialization files are run commands in /etc/profile are executed first. Next the shell looks for: ~/.bash_profile ~/.bash_login ~/.profile In that order. The –noprofile option may be used when the shell is started to inhibit this behavior.

  13. Shell initialization continued. When a login shell exits, bash reads and executes commands from the file ~/.bash_logout, if it exists. When an interactive shell that is not a login shell is started, bash reads and executes commands from ~/.bashrc, if that file exists. This may be inhibited by using the –norc option. The --rcfile file option will force bash to read and execute commands from file instead of ~/.bashrc.

  14. Default system initialization files When a new user is added to the system default initialization files are created in the user’s home directory. These are stored under /etc/skel Korn, Bourne and Bash all create .profile files based on the contents of local.profile.

  15. Why /export/home/<userid> Home directories can technically be anywhere; however, on a Solaris system /export/home/<userid> is fairly common/standard. This is based on the intent to mount the home directory remotely. When AutoFS is running (default) and configured to mount home directories users are NOT permitted to create any directories under /home.

  16. Service Management Facility: SMF • Service Management Facility is a new feature added to Solaris 10 intended to replace traditional startup scripts (init.d) • SMF comes with its own set of tools which include: • svcs • svcs –a # lists all services, enabled or disabled • svcadm • svcadm disable ssh # disable ssh • svcadm enable ssh # enable ssh • We will discuss SMF more later in the quarter.

  17. Review: SUN – Stanford University Network Oracle – completes the SUN acquisition Jan 27th 2010. Oracle still losing market share with SUN hardware but delivering new hardware solutions. Solaris 11 released 11/11. Solaris support for x86 extensive. User management similar to Linux Shell initialization reads: .bash_profile .bash_login and .profile in that order. Non interactive shells read .bashrc by default. SMF is the intended replacement for /etc/init.d scripts.

  18. In class lab 1a • Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

  19. Q3, Class 1, Unit 2 What we are going to cover: • Solaris networking What you should leave this session with: • How to update your network settings • Files involved in hostnames values • How to start/stop/reboot your server

  20. Basic Solaris networking To see your current network information • /sbin/ifconfig –a *root access required for mac info. Enable/Disable interface: • /sbin/ifconfig <interface> up|down e.g. /sbin/ifconifg e1000g0 up Interface names are hardware related hme0, e1000g0, bge0

  21. Solaris networking cont. Network connectivity requires: plumbed interface – using the shell script: • /lib/svc/method/net-physical configured interface – ip assigned Interface must be up • Ifconfig -a Interface must be connected Interface must have valid routes • netstat -rn

  22. Changing the hostname Requires updating: • /etc/nodename • /etc/hostname.<int> • /etc/inet/hosts reboot or run: • /usr/sbin/svcadm restart network/physical Or • /usr/sbin/sys-unconfig This will remove all system identification details and start a wizard similar to the one used during the initial installation. Test the hostname value with: /usr/bin/uname -n

  23. Solaris networking – update IP info Edit these files: • /etc/inet/hosts = defines IP and host name • /etc/nodename = host name • /etc/hostname.<interface> =hostname • /etc/inet/netmasks = define subnet & netmask • /etc/defaultrouter = default gateway Initialize the interface and bring it back online Ifconfig <int> <hostname> netmask + broadcast + up Restart the network service or reboot. (svcadm…)

  24. Additional troubleshooting options If you have problems getting your interface online check if the service has switched maintenance mode. • svcs –a Note the –a means list all svcs. By default services in maintenance mode are not be displayed. Try toggling the service between disabled and enabled after confirming the configurations. svcadm enable network/physical svcadm disable network/physcial Check the logs for issues: /var/svc/log

  25. Basic Solaris networking cont. Un-configure DHCP move or rename /etc/dhcp.<interface> Define files and values previously mentioned and restart network services or reboot. If this fails you can run sys-unconfig Default route = can be defined in /etc/defaultrouter if it is not broadcast on the subnet.

  26. Client DNS and Solaris /etc/resolv.conf = defines the name servers /etc/nsswitch.conf = defines a variety of services including how to resolve hosts and ipnodes. Samples provided under /etc Best practice is to copy the nswitch.conf sample over the default. cp /etc/nsswitch.dns /etc/nsswitch.conf Changing these files should NOT require a reboot.

  27. Basic networking cont. Solaris 10 manages network services with inetadm inetadm - lists all services inetadm -e <service name> - enable service inetadm -d <service name> - disable service inetadm -l <service name> - list properties for service. e.g. inetadm –l smserver

  28. How to shut Solaris down /usr/sbin/shutdown –y –g0 –i0 -y answer the confirmation question. -g grace period, 0 means now. -i init state to invoke 0 = stop 1 = single user 5 = halt 6 = reboot Also available /usr/sbin/shutdown, halt, reboot and poweroff

  29. Review • Interface details available using: /sbin/ifconfig -a • Interface names are based on the NIC chipset. hme0, bge0, e1000g0 • By default the net-physical shell script configures the interfaces. • Changing the hostname and or IP requires changing multiple files. • svcs, svcadm and inetadm are used for managing network services. • The DHCP configuration is dependent on /etc/dhcp.<interface> file. • Client DNS primarily managed using resolv.conf and nsswitch.conf

  30. In class lab 1b • Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

  31. Q3, Class 1, Unit 3 What we are going to cover: • Solaris package mgmt What you should leave this session with: • Basic Solaris package management tools • The ability to install packages from OpenCSW

  32. Basic package management Tools and products designed for Solaris systems come in software packages that conform to the ABI (application binary interface) standard. Actually the C ABI. C is the standard UNIX implementation language. Installed packages are tracked under /var/sadm. If you remove files or directories from /var/sadm directly it will likely cause problems during the next patch revision due to references for missing files.

  33. Tools for working with packages showrev –p = shows all packages on the system. pkgparam <pkgid> PATCHLIST = shows all patches applied to the selected package pkgparam SUNWsshcu PATCHLIST pkgparam <pkgid> PATCH INFO <patch number> = shows install date and name for the host from which the patch was applied. /usr/sbin/patchadd -p = show all patches applied to the system. patchrm <patchname> = remove patch

  34. Tools for working with packages • /usr/bin/pkginfo – package information • /usr/sbin/pkgrm – package remove • /usr/sbin/pkgadd – package add can be used with –d for packages not found under /var/spool/pkg • /usr/sbin/pkgchk – check status of package A complete list of the installed packages on your host can be found in the file /var/sadm/install/contents Use caution when editing this file directly as errors can cause additional issues.

  35. Additional Solaris package sources Other resources for Solaris packages include UnixPackages (previously sunfreeware) and OpenCSW. UnixPackages is a subscription based site. OpenCSW is available to anyone, no account required. Their packages will install under: /opt/csw

  36. OpenCSW OpenCSW is a fork of blastwave a now defunct software repository. However, so far OpenCSW appears active and growing. Installing OpenCSW should be fairly simple. Assuming your server has a valid internet connection and can resolve names. pkgadd –d http://get.opencsw.org/now Next update your path to include /opt/csw/bin and /opt/csw/sbin Update your pkgutil package. /opt/csw/bin/pkgutil –u pkgutil To install packages use the –i option.

  37. Review Solaris comes with more than a few standard package management install utilities. OpenCSW uses a customized pkgutil tool for installation.

  38. In class lab 1c • Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

  39. Q3, Class 1, Unit 4 What we are going to cover: • Intro to Perl What you should leave this session with: • When to consider Perl over shell • How to define a Perl script

  40. History of PERL PERL: Practical Extraction and Report Language PERL: Pathologically Eclectic Rubbish Lister Originally designed and coded by Larry Wall.

  41. Purpose of PERL Designed to optimally perform common tasks that are Too difficult to create effectively in shell scripts Too ephemeral to write in a C Skewed towards reading and processing large streams of data Required to run on a variety of platforms

  42. Design Concepts PERL was written by a linguist, so much of the syntax works like people speak. Which is to same it can be clear and concise or wordy and confusing. No built-in limitations to the language Avoid painful distinctions between data types All variables are considered strings unless a specific numeric comparison is called for.

  43. Basic Concepts PERL is an Interpreted Language It is NOT compiled into a binary format Does not require a compiler to operate PERL Interpreter Features Reads the entire program before execution begins, ensuring syntactic correctness Has built-in debugging features

  44. Basic Concepts cont. PERL execution has a heavy startup overhead Don’t use complicated scripts for simple tasks Avoid including unused functions Avoid repetitiously calling other PERL programs from inside another PERL Interpreter internally compiles scripts so execution is rapid once begun

  45. Executing PERL Scripts Take a file of PERL code and pass it to the interpreter /usr/bin/perl myfile.pl Make an executable script Turn on the execute bit on the file (chmod 755 myfile.pl) Include the location of the interpreter at the beginning of the file (#!/usr/bin/perl)

  46. Perl directives very similar in many ways to shell scripting in perl we use a directive such as print followed by an argument. However, in perl each line must end with a semi-colon print "Hello"; If we want a new line after the output we add \n within the double quotes. print "Hello\n";

  47. Perl review Perl is an interpreted langauge like shell. Perl is good at working with large text files and data sets. Perl has no built in limitiations. Perl tries to make it possible to write perl as we might speak. Perl requires a semi-colon at the end of each line.

  48. In class lab 1d • Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

  49. Homework If there is time left over I would like you to ensure that your Q1 and Q2 servers are on line are running the required services. I also expect that your Nagios servers are online now. Production server assignments will be sent out later this week. Homework will be posted later this week also.

More Related