49
Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl.

Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Embed Size (px)

Citation preview

Page 1: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Unix Linux Administration III

Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl.

Page 2: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 3: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Agenda Introduction to Solaris 10/11. Solaris 11 node configuration Introduction to Perl

Page 4: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 5: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

ISO download

Start to download Solaris ISO now:

https://www.ulcert.uw.edu/ISO/sol-11_2-text-x86.iso

Page 6: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Brief history of SUNSun 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.

Page 7: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Acquisitions of note by SUNCray Business Systems – one of the founding

super computer companies.I-planet – sun web server is based on this

acquisitionStarOffice – answer to MSOfficeNetBeans – Sun IDE based on this acquisitionMySQL – database solutionVirtualBox – alternative to VMware and other

virtualization products.There are of course lots of others these are

just a sampling.

Page 8: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 9: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

SPARC and x86 historyEvery 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

Page 10: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Solaris user management

Solaris 10 provides a GUI user management tool, Solaris Management Console (SMC) to create accounts. This tool is removed in Solaris 11 and replaced by User Manager panel.

As you would expect there are command line tools for managing user accounts

Page 11: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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>

Page 12: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Shell initialization filesC, 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 ~/.profileThe system reads and executes the commands

from the first file it finds.The –noprofile option may be used when the shell

is started to inhibit this behavior.

Page 13: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 14: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 15: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 16: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Service Management Facility: SMF

Service Management Facility is a new feature added to Solaris 10 and improved in Solaris 11. replacing 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.

Page 17: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Review:SUN – Stanford University NetworkOracle – 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 LinuxShell 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.

Page 18: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

In class lab 1a

Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

Page 19: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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

Page 20: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Network interface configurationTypically a Solaris system will have at least one network interface. During the installation you are guided through initial configuration of this interface. Any other interfaces can be configured manually later.

The two primary configuration options are:Fixed network configuration

Network Configuration Profile (NCP) DefaultFixed

Reactive network configuration NCP Automatic

Page 21: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Reactive network configurationProvides automatic configuration removing the need for manual intervention. This works when moving between wired and wireless networks or if new networks become available. This is primarily envisioned for mobile clients.

Page 22: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

NCP Automatic

The Automatic NCP uses DHCP to obtain a basic network configuration (IP address, router, and DNS server) from any of the connected Ethernet interfaces. If this fails, it will try connecting to the best wireless network in the list of known networks.

Page 23: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Enable NCP AutomaticStarting with Solaris 11 ipconfig has been superseded by dladm and ipadm. Updates made using these commands persist reboots and have parse-able output that can be used in scripts.

root@solaris:~# netadm enable -p ncp Automatic

Page 24: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Fixed network configurationThe DefaultFixed NCP disables automatic network configuration. The administrator then has to manually configure the interface using dladm and ipadm. The name services are then managed using Oracle Solaris Service Management Facility (SMF).

root@solaris:~# netadm enable -p ncp DefaultFixed

Page 25: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Fixed network configuration

netadm will display the network connections.

ipadm will display IP address details.

Page 26: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Fixed network configurationCreating a Fixed or static address requires creating an IP interface and an IP address.

root@gsol11-01:#ipadm create-ip net0

And an IP address

root@gsol11-01:# ipadm create-addr –T static –a 172.16.15.98/24 net0/ext

The last argument net0/ext shows the interface name and user set string. Here it could represent external.

Page 27: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Default gateway address.Set the default gateway using the route command

root@gsol11-01:~# route -p add default 172.16.15.2

add net default: gateway 172.16.15.2: entry exists

add persistent net default: gateway 172.16.15.2

root@gsol11-01:~# route -p show

persistent: route add default 172.16.15.2

Page 28: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Name service configuration

Solaris 11 system maintains and manages the name service configuration using SMF.

The SMF service is

svc:/network/dns/client

The file /etc/resolv.conf still exists for backward compatibility but should not be edited directly.

Page 29: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Current Name service configuration

Starting with Solaris 10 SMF service updates are completed using svccfg.

In this example we are printing out the current host name service configuration.

svccfg -s network/dns/client listprop config

Page 30: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Set new nameserver values

The following command will replace the existing nameserver values.

Page 31: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Change the search domainsAgain we use the svccfg command

Once complete refresh (reload) the service. root@gsol11-01:# svcadm refresh svc:/network/dns/client

Page 32: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

nsswitch.conf configuration.

Solaris 11 system maintains and manages the nsswitch configuration using SMF.

The SMF service is

svc:/system/name-service/switch

The file /etc/nsswitch.conf still exists for backward compatibility but should not be edited directly.

Page 33: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Updating nsswitch with SMF

We still use svccfg to view and update these values. Multi-value changes may require single quotes around double quotes

Page 34: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Hostname configuraiton

You can check your current hostname using the command by the same name. Alternatively you can use uname –n

Updates should be made using svccfg

Page 35: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Interface names

Unlike Linux Solaris interface names are often hardware related.

hme0, e1000g0, bge0

Often the name first displayed though is the Data link name which often defaults to net0. We can change this to e1000g0 or anything else using dladm however the interface cannot be in use.

Page 36: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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 user5 = halt6 = rebootAlso available /usr/sbin/shutdown, halt,

reboot and poweroff

Page 37: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Review primary configuration options

fixed network configuration reactive network configuration

reactive networks or Automatic try to use DHCP services. They preferred wired to wireless connections.

Ipconfig has been replaced by dladm and ipadm. Set the default gateway using the route command. configuration updates like the name service, nsswitch,

hostname are managed using SMF Files like /etc/hosts and /etc/resolv.conf exist for

backward compatibility but should not edited directly.

Page 38: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

In class lab 1b

Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

Page 39: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Q3, Class 1, Unit 3

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

Page 40: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

History of PERL

PERL: Practical Extraction and Report Language

PERL: Pathologically Eclectic Rubbish Lister

Originally designed and coded by Larry Wall.

Page 41: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Purpose of PERL

Designed to optimally perform common tasks that areToo difficult to create effectively in shell

scriptsToo ephemeral to write in a CSkewed towards reading and processing

large streams of dataRequired to run on a variety of platforms

Page 42: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 43: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Basic Concepts PERL is an Interpreted Language

It is NOT compiled into a binary format Does not require a compiler to operate

PERL Interpreter FeaturesReads the entire program before execution

begins, ensuring syntactic correctnessHas built-in debugging features

Page 44: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Basic Concepts cont. PERL execution has a heavy startup

overheadDon’t use complicated scripts for simple tasksAvoid including unused functionsAvoid repetitiously calling other PERL

programs from inside another PERL Interpreter internally compiles

scripts so execution is rapid once begun

Page 45: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

Executing PERL Scripts Take a file of PERL code and pass it to the

interpreter /usr/bin/perl myfile.pl

Make an executable scriptTurn 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)

Page 46: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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";

Page 47: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.

Page 48: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

In class lab 1c

Lab notes for this session can be found here: http://www.ulcert.uw.edu -> Class Content -> InClass labs ->

Page 49: Unix Linux Administration III Class 1: Introduction to Solaris 10/11. Solaris node configuration. Introduction to Perl

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.