Section 9.3. Installing the PDBA Toolkit for Unix

   

9.3 Installing the PDBA Toolkit for Unix

There are three basic steps involved in installing the toolkit on Unix systems:

Set the environment

We need to ensure that the Unix environment has been correctly prepared for installation.

Load the modules and scripts

Once the environment is set, we can install the main body of code.

Edit the configuration files

Once the code is installed, we can configure, secure, and store all of our database connection parameters.

You will need to follow the steps in this section to install the PDBA Toolkit on your Unix platform so the scripts introduced in later chapters will work properly.

9.3.1 Setting the PDBA Environment

PDBA_HOME is the default directory for the PDBA Toolkit and all of its associated files. However, as we mentioned earlier in the discussion of the PDBA module, it may not be necessary to set PDBA_HOME on Unix. If you create an account dedicated to running the PDBA Toolkit, you may be happy enough storing its configuration files under the HOME structure of that account. Recall from our earlier discussion that this is where PDBA will look for them if PDBA_HOME has not been set. For instance, for new user oramon in the /home directory, the default location will be under /home/oramon/pdba .

9.3.1.1 Setting PDBA_HOME from the command line

If you do wish to explicitly control the location of PDBA_HOME , it's as easy as this:

 $ export PDBA_HOME=/u01/my_pdba_home_dir 

To avoid typing this line as part of every login, edit your .profile file or equivalent, and add PDBA_HOME to the usual suspects required for the toolkit's installation. They are:

ORACLE_HOME
O RACLE_SID (or TWO_TASK )
TNS_ADMIN

It is possible to create the entire PDBA Toolkit, while logged in as the root account, but we'd like to recommend another approach. The toolkit modules and scripts should be installed as root or as the user who owns the Perl installation. (For instance, you may have installed a local Perl for user oracle .) However, the configuration files should be installed in a user account, such as oramon , oracle , or pdbauser . Toolkit scripts should be executed under that account as well to keep your system administrator happy.

9.3.2 Installing the PDBA Perl Modules and Scripts

Before actually installing the toolkit there are some other tasks you will need to deal with:

Install additional Perl modules

The PDBA Toolkit is dependent on other Perl modules that must first be installed.

Determine installation locations

Decide if the default locations for the supporting modules and the scripts are acceptable. Determine alternate locations as needed.

We'll first install the additional Perl modules needed for the PDBA Toolkit.

9.3.2.1 Installing additional modules

There are three external Perl modules we need to load. We've kept this list of extras to a minimum in order to keep installation as simple as possible. However, as we developed this toolkit, we did try to follow the maxim of Perl programmers everywhere: "Laziness is a virtue." Put another way, Perl programmers are advised to avoid reinventing the wheel whenever possible and to make use of existing code wherever they can.

These are the necessary modules; all of which can be installed from CPAN:

http://www.cpan.org/authors/id/GBARR

Graham Barr's TimeDate date parser.

http://www.cpan.org/authors/id/S/SI/SIFUKURT

Kurt Kincaid's Crypt::RC4 cryptographic module.

http://www.cpan.org/authors/id/M/MI/MIVKOVIC

Milivoj Ivkovic's OS-independent Mail::Sendmail email sender (described earlier).

When connected to the Internet, the easiest way of installing these modules is this:

 $ perl -MCPAN -e "shell" cpan> install  Date::Format  cpan> install Crypt::RC4 cpan> install Mail::Sendmail cpan> quit Lockfile removed. 

Installing Date::Format automatically picks up the rest of the TimeDate bundle.

9.3.2.2 Determining installation locations for Perl modules

Now we can go ahead with the toolkit installation. First you need to download the toolkit. You can download PDBA-1.0.tar.gz , or its latest derivative, from our O'Reilly site: [5]

[5] We will be regularly updating the PDBA Toolkit as an evolving open source project, although you may wish to load PDBA-1.0.tar.gz first, just to get the hang of its installation.

http://www.oreilly.com/catalog/oracleperl/pdbatoolkit

You now need to make two important decisions:

  • Where do we want the PDBA supporting modules to go?

  • Where do we want the PDBA scripts to go?

We generally want all of our Perl modules to be stored within the default Perl library tree. However, if you wish to install these modules elsewhere ” perhaps to control access ” use the PREFIX switch. For example, the following will install everything under ~/oramon/pdba :

 $ perl Makefile.PL  PREFIX=/home/oramon/pdba  

This will mean that the modules get installed in directories that normally are invisible to Perl. The installer will take care of this by adding a code line near the top of PDBA executable shell scripts, as in the following:

 use lib qq{/home/oramon/pdba/lib/site_perl/5.6.1/}; 

Later on, this specification will tell Perl where to find the PDBA modules as Perl requires them. However, we recommend that you accept the default Perl library locations just to keep everything simple.

9.3.2.3 Determining installation locations for Perl scripts

The recommended location for the Perl scripts isn't as obvious. Perl's ExtUtils::MakeMaker generally places scripts within the /usr/bin location. However, we (or your system administrator) may prefer /usr/local/bin . A slight command-line modification changes the target script directory as follows :

 $ perl Makefile.PL  INSTALLSCRIPT=/usr/local/bin  

Installing the PDBA scripts in /usr/local/bin has the added advantage of separating the executable scripts from the OS binaries found in /usr/bin . This makes your scripts less vulnerable during system upgrades or rebuilds. Making them publicly available under /usr/local/bin still avoids a security risk (as the configuration files contain the confidential information). This information may be easily protected inside a user account such as oramon .

9.3.2.4 INSTALLSITELIB

Installation variations are possible too. For example, you might wish to put the modules in /home/oramon/pdba and the executable scripts in /usr/local/bin . But beware! You might think the following would suffice:

 $ perl Makefile.PL  PREFIX=/home/oramon/pdba INSTALLSCRIPT=/usr/local/bin  

Alas, this produces unintuitive results. Rather than placing executables in /usr/local/bin , you'll find them lurking in /home/oramon/local/bin . This is because PREFIX takes precedence over INSTALLSCRIPT . We must instead substitute INSTALLSITELIB for PREFIX :

 $ perl Makefile.PL  INSTALLSITELIB=/home/oramon/pdba  INSTALLSCRIPT=/usr/local/bin 

For more on this and other MakeMaker variations, try the following command:

 $ perldoc ExtUtils::MakeMaker 
9.3.2.5 Ready to install

From now on, we'll assume that the PDBA Toolkit is being built by the oramon account. Follow these steps:

  1. Go to the PDBA_HOME directory:

     $ chdir $PDBA_HOME 
  2. Unpack the tarball:

     $ gzip -d PDBA-1.0.tar.gz $ tar xvf PDBA-1.0.tar 
  3. Now we configure and compile in the traditional manner:

     $ cd PDBA-1.0 $ perl Makefile.PL INSTALLSCRIPT=/usr/local/bin $ make 

    Let's test the compilation. This requires setting the ORACLE_USERID environment variable to a user with the SELECT ANY TABLE privilege:

     $ export ORACLE_USERID=system/manager $ make test 
  4. To install the PDBA Toolkit under the Perl library tree, you'll need to log in as root :

     $ su - root # cd /home/oramon/PDBA-1.0 
  5. Now finish the job:

     # make install 

    You'll see output that looks something like this:

     Installing /usr/lib/perl5/site_perl/5.6.1/PDBA/CM.pm ... Installing /usr/share/man/man3/PDBA::CM.3pm ... Installing /usr/bin/pwd.pl Writing /usr/lib/perl5/site_perl/5.6.1/i586-linux/auto/PDBA/.packlist Appending installation info to /usr/lib/perl5/5.6.1/i586-linux/perllocal.pod 

9.3.3 Installing PDBA Unix Configuration Files

We'll store our Unix configurables via the highly sophisticated flat-file method, [6] albeit one with a special twist. While PDBA modules and scripts are now installed in the proper locations, the configuration files remain within the build directory. Let's find them a proper home:

[6] If it's good enough for Apache, it's good enough for us!

 $ cd $PDBA_HOME/PDBA-1.0 

Of course, the final location of the files will depend on how you set PDBA_HOME :

  • If PDBA_HOME is set to /u01/app/pdba , for example, this is where the files will get stored.

  • If PDBA_HOME is not set, the configuration files will get stored in $HOME/pdba .

To install the default configuration files, you simply need to execute this command:

 $ perl cp_config 

The cp_config script checks any potential PDBA_HOME value, determines what to do, and then installs the files accordingly (as described earlier). To configure these files, skip the Win32 installation, and go directly to the Section 9.5, later in this chapter, as configuration is similar for both platforms.

   


Perl for Oracle DBAs
Perl for Oracle Dbas
ISBN: 0596002106
EAN: 2147483647
Year: 2002
Pages: 137

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net