|
Home | Switchboard | Unix Administration | Red Hat | TCP/IP Networks | Neoliberalism | Toxic Managers |
(slightly skeptical) Educational society promoting "Back to basics" movement against IT overcomplexity and bastardization of classic Unix |
|
Perl is a very powerful tool for Oracle database administrators, but too few DBAs realize how helpful Perl can be in managing, monitoring, and tuning Oracle. See Perl for Unix System Administrators and e-book Introduction to Perl for Unix System Administrators
Perl is installed as part of the Oracle client. Also Perl is installed by default on all commercial Unixes, Linux provides the best scripting environment for Perl of all Unixes. Solaris 10 come the second close. HP-UX is the worst and unless you update Perl default installation it is unusable on HP-US 11.11 and below -- you really need to use Oracle client version. AIX is somewhere in between Sun and HP-UX.
|
Perl DBI is a generic application programming interface (API) used to connect to Oracle database from Perl. It was strongly influenced by ODBC (Open Database Connectivity) standard. Oracle uses the DBD::Oracle driver, another Perl module that provides the actual communication to the low-level OCI code. It is OCI that makes the final connection to the Oracle database.
Perl DBI connectivity was first implemented in 1991 when an Oracle DBA, Kevin Stock, created a database connection program called OraPerl that was released for Perl 4. Over time, similar Perl 4 programs appeared, such as Michael Pepper's Sybperl, designed for communication with the Sybase database. Perl DBI module was developed around the time Perl 5 became available and it incorporated new object oriented features of Perl 5.
DBI architecture permits to connect to any database, as long as you had the right driver. For Oracle such driver is DBD::Oracle written by Tim Bunce, the main creator of Perl DBI. Among the calls used by Perl DBI module:
See Connection to Oracle database from Perl scripts for more details
There are many excellent Perl modules and complete open source applications that are freely available for Oracle DBAs to use. You can also create custom application using Perl/Tk, Perl's toolkit for developing graphical user interfaces.
There are many useful Oracle database administration scripts written in Perl and freely available on the Net. For example the books like Perl for Oracle DBAs and Oracle Scripts (both now outdated) contain set assembled by authors from various sources.
You can also create Web applications using Apache with Perl and Oracle
Many Oracle DBAs spend at least part of their time dealing with data warehousing as well as database administration. They often need to clean and transform data that originates in other databases and applications and is now destined for Oracle.
Perl, with its regular expressions and high performance, is one of the best solutions
around for preparing data for use in data warehouse applications. Data mangling
is the term used to describe the data cleaning, formatting, and transformation often
required by data warehouses. There is a Perl book devoted to data mangling.
Every DBA ends up needing to write quick ad hoc programs simply to glue things together
in their databases. Perl is perfect for this task. It also makes it easy for
you to add, change, or customize your pet scripts.
|
Switchboard | ||||
Latest | |||||
Past week | |||||
Past month |
More and more of Tivoli's applications are being based around Relational Databases. TEC and Inventory have always had a database as a key component, but newer applications like User Admin and even the Framework now rely upon a separate database as an information store.
While much of the information held in the database can be retrieved and viewed through the relevant Tivoli tools, there will always be a need to extract information from such repositories yourself.
Retrieving Data from a Database with Perl
Retrieving data from a database is not straight forward, usually because there is a whole load of baggage that is returned along with the data. The following is the output from a TEC Database (Oracle) from a query to count the number of records in a particular table:
sqlplus tec/tectec SQL*Plus: Release 8.1.6.0.0 - Production on Mon Mar 11 06:50:36 2002 (c) Copyright 1999 Oracle Corporation. All rights reserved. Connected to: Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production SQL> select count(1) from tec_t_evt_rec_log; COUNT(1) ---------- 478 SQL> quit Disconnected from Oracle8i Enterprise Edition Release 8.1.6.0.0 - Production With the Partitioning option JServer Release 8.1.6.0.0 - Production,To simply get the data from this query (ie the value '478'), you have to do a vast amount of filtering. For example :
,#!/bin/perl $user = "tec"; $password = "tectec"; $sql = "select count(1) from tec_t_evt_rec_log; quit;"; open(SQL, "$sqlplus $user/$password <,&1|"); while ( ) { # Filter out stuff we don't want next if (/Oracle/); next if (/SQL Plus/); next if (/Connected to/); next if (/Partitioning/); next if (/JServer/); next if (/COUNT/); next if (/-----/); if (/s+(d+)/) { $count = $1; last; } } close (SQL); print "Number of records = $count "; Whilst this method works ok in performing a query against the database and returning the data, you will see that this method is a little messy. If you have many such queries to perform in a script, then the script can become rather unwieldy.
There is an alternative method however that makes retrieving data from a database far simpler and a little more elegant -Perl DBI.
Perl DBI
Perl DBI is a Perl module that provides a simple / standard interface between the Perl programming language and other data sources. Using Perl DBI and other database modules (DBD) one can access all kinds of databases including flat file, CSV file, Oracle, Sybase, DB2, SQLServer MSAccess etc etc.
This quick reference was written to provide enough information to be able to access, update (insert, delete and update) and query information from a database. It is a huge subject and O'Reilly have published an excellent book - 'Programming the Perl DBI' where you can get more indepth information. As a quick guide however, this reference guide will hopefully give you a good starting point.
Prerequisites
There are a number of prerequisites that need to be in place before you can start using DBI:
- Perl 5.x (I use the latest Perl 5.6.1)
- Perl DBI Module
- The relevant Perl DBD module eg DBD::Oracle
- Access to the data source - either (i) directly, with the Perl scripts being run off the same box as the database, or (ii) indirectly through some sort of access level (eg SQLNet, ODBC etc.)
Getting Perl DBI / DBD
The Perl DBD and DBI modules can be downloaded and installed onto your system using the Perl built in package manager PPM (on NT) and cpan (on Unix). The following instructions are for use with NT / Windows 2000.
To do this ensure you are using Perl 5.x. To do this from a shell prompt type
perl -v
If you are on Perl 4.x (as supplied by Tivoli) then you will also have to have Perl 5.x installed on your system. Once installed you'll either need to unsource the Tivoli environment or goto the Perl 5.x directory and run Perl from there, eg
c:Perlin
Then launch the Perl package manager: ppm
ppm
PPM interactive shell (2.1.5) - type 'help' for available commands.
PPM>Search for the relevent modules, eg
PPM> search DBI
This should produce a list of the DBI releated modules. Choose the correct module and install it using the install command:
PPM> install DBI
This should download the correect code, install it and test the installation.
Once this is done, do the same for the relevent DBD module. There are loads of these so it's best to search for the database rather than just DBD ie :
PPM> search Oracle
Again once you've identified the module you need, install them eg
PPM> install DBD::Oracle8
Once this is complete, exit and you are ready to go.
Your first Script
The following sections are going to walk through a simple script that will access a local Oracle database (the TEC database) on an NT system, query some data, update it and then disconnect from the database.
In the first part of the script you have to import the DBI and DBD modules. In Perl 5 you do this using the use call. ie
use DBI;
It's also a good idea (especially when getting started) to use the strict module (use strict;). This just forces you to use a correct programmimg methodology, and ensures that you predeclare everything. While this can be a real pain for sloppy programmers, in the long run it is useful!
Connecting to the Database
To connect to the database you need to first provide a little information to DBI. This includes the dsn, user and password. The dsn provides information regarding the database, ie what type of database it is, and how it can be accessed - for Oracle this maps on to the SID. To perform the connection you use the callconnect. This returns a database handle back that you must always use. The database handles contains information about this session.
In the case of my local TEC database I could use the following code:
,my ($dsn) = "DBI:oracle:tec"; my ($user) = "tec"; my ($password) = "tectec"; my ($dbh) = DBI->connect($dsn, $user, $password);,This code will connect you to the local TEC database. There are also a number of other useful options that you can give the connect call. The most useful include :
AutoCommit => 1 This automatically commits all database updates at the end of their calls, without you having to remember to provide the commit statement after each. RaiseError => 1 Raises all database errors via a diecall You can use these options in the connect statement
my ($dbh) = DBI->connect($dsn, $user, $password,
{ RaiseError => 1, AutoCommit => 1});Performing a Query
The most basic thing you're going to want to use Perl DBI for is extracting data from the database, using a sql statement. In this section we're going to retrieve various information from the TEC Event Repository. First of all we're going to count the number of events in the database, then we're going to get a list of all classes in the database.
To run a query using DBI there are three steps we have to take :- (i) prepare the query, (ii) execute the query and finally (iii) fetch the results from the query.
Preparing the Query
Preparing a query creates the query and assigns it a database query handle. You then use this handle to actually perform the query and get the data from the database. To prepare a query you perform the following:
my ($sth) = $dbh->prepare( 'select class, hostname, msg from tec_t_evt_rep' );
In the above the query we are going to run just retrieves the class, hostname and msg data from each record in the table tec_t_evt_rep (the event repository). The result of the $dbh->prepare is a statement handle ($sth). From this point on we use the statement handle to execute the query and access the results set of the query.
Executing a Query
Once the query is prepared, the query has to be executed against the database. Note that this step does not immediately return the results of the query to you - that is covered in a following step. To execute the query, perform the following:
$sth->execute();
Fetching Data
As we mentioned previously the execute statement only executes the SQL Query (in fact on very large tables it it may have only initiated the query). The result set is actually held in records that haven't yet been passed to your Perl program. To get at the result set you need to fetch the data that the query produced. There are three basic methods you can use for this, and each has it's own benefits. The methods you can use are:
fetchrow_array This returns a list of values you can use directly fetchrow_arrayref This returns reference to an array fetchrow_hashref This returns a reference to a hash Each of these methods return the data from a single row from the database. If you are expecting multiple rows of data in your result then you will have to put the statement in some kind of loop. It should be noted here that the data is being fetched from a cursor, and once each row of data has been retrieved the data is forgotten, so if you wish to use the data again later you need to store it in you own variables, arrays or hashes.
The simplest way to retrieve records is to use the fetchrow_array method. Using the query from the previous section, we will get multiple rows of data, therefore we will use the fetchrow_array in a while loop to print out all of the values. For example :
,while (my ($class, $hostname, $msg) = $sth->fetchrow_array) { printf("%20s %15s %s ", $class, $hostname, $msg); }As fetchrow->array produces a list, we could have retrieved the data into an array of our own - eg :
my (@data) = $sth->fetchrow_array;
Following this, we could then have accessed the data by referring to $array[0] through to $array[$#array].
A further point to remember is that when iterating through the rows, the result set is retrieved in the same order that it was retrieved from the database. This keeps the results consistent with the data (especially worth noting if you are grouping or ordering in your SQL statement).
Another method to retrieve the results set is to use the methodfetchrow_arrayref. This returns a reference to an array rather than the actual array itself. We could use the fetchrow_arrayref in our example as follows:
while (my ($arrayRef) = $sth->fetchrow_arrayref) { printf("%20s %15s %s ", $arrayRef->[0], $arrayRef->[1], $arrayRef->[2]); }This produces the same results as the example using fetchrow-array, but because the data remains in its original array, and is not copied to a new array, there is an efficiency and performance improvement.
Finally the result set can be retrieved into a hash array using fetchrow_hashref. Instead of producing a list (or reference to a list), this method produces a reference to a hash which is keyed on the column names (eg class, hostname and msg in the above example). Again using the previous example, our fetch statement could be re-written as follows:
while (my ($hashRef) = $sth->fetchrow_hashref) { printf("%20s %15s %s ", $hashRef->{class}, $hashRef->{hostname}, $hashRef->{msg}); }The results could also be dereferenced by using $$hashRef{class} as well.Finishing the Query
Finally, once you have retrieved all the data you need you have to de-allocate the statement handle. This is carried out via the finish method, ie :
$sth->finish();
Non-select queries
So far we have just talked about executing select queries, ie queries that retrieve data from the database. There are however other actions you will want to perform on the database (such as inserting and deleting rows of data) that do not return data. For these types of statements you can use the do method rather than preparing, executing and fetching via a statement handle. The following example deletes all records from the reception log that have a status of 4 (PARSING_FAILED) or a status of 2 (PROCESSED).
$rows = $dbh->do( "DELETE from tec_t_evt_rec_log WHERE status = 2 or status = 4" ); print "Deleted $rows from the reception logThe do method will perform the action straight away and will return the number of rows deleted. If the action completed succesfully (ie didn't fail due to an error) but did not delete any rows then the return code will be 0E0.Remember that if you do not include the AutoCommit = > 1 when creating the connection to the database, the action you have just performed will only be visible to this session. Other sessions will still see the data as it was originally.
Disconnecting from the Database
Once you have completed your work on the database you have to diconnect from it. To do this you can use the disconnect method :
$dbh->disconnect;
Error Handling
Most DBI methods return true or false. This means that you can perform your own error checking on each method. The error from a method is held in the DBI variable called errstr which can be included in your error checking. For example, to print a message and stop processing when you cannot connect to the TEC database you could perform something along the following lines:
my ($dbh) = DBI->connect($dsn, $user, $password) || die "Cannot connect to database. Reason $DBI::errstr ";If we couldn't contact the database we would get the error message and the script would end.
This is all very well but in large scripts it can be a real pain adding all these entires to each DBI method call. To solve this, DBI can also employ automatic error checking that will either stop the script where the error occurred and produce an error message (using die), or will allow the program to continue but still send an error message out (using warn).
To switch on this automatic error checking you need to include the attributes PrintError (utilises warn) andRaiseError (utilises die).
To switch on automatic error warnings, you must connect and add the attributes as follows:
my ($dbh) = DBI->connect($dsn, $user, $password, { PrintError => 1, RaiseError => 0});Within your script you can switch between automatic error routines from warn to die, just by reseting the value of the attributes. For instance in the following segment we want to create a new tec_log table, but drop it first if it already exists. If the table does not exist we want to send a warning out but continue, if we cannot create the table then we want to stop processing the script:$dbh->{PrintError} = 1; $dbh->do( "drop table TEC_LOG"); $dbh->{PrintError} = 0; $dbh->{RaiseError} = 1; $dbh->do( "CREATE TABLE TEC_LOG ( date_reception VARCHAR2(12) NOT NULL, class VARCHAR2(50) NOT NULL, msg VARCHAR2(256) NULL, hostname VARCHAR2(50) NULL, status INTEGER; severity INTEGER. date_entry DATE NOT NULL ) " );Example Script
To accompany this tip, I have created a very simple example script that extracts useful statistics from the TEC Database. The script perfoms a query against the TEC database every x seconds and writes the results to a specified logfile in CSV format. The query gets the following information:
- Number of WAITING events
- Number of PROCESSED events
- Number of QUEUED events
- Number of PARSING_FAILED events
- Total number of events in the reception log
- Number of OPEN events
- Number of ACK events
- Number of CLOSED events
- Total number of events in the event repository
The format of the file is not hugely readable in it's raw form, but this can be imported into Excel or the like to generate some trending
In this paper, Best Practice concepts are first defined, then specific high-impact technical issues common with Oracle in the Solaris[tm] Operating Environment are discussed.
Oracle UNIX Administration Changing Default File Permissions with umask
Oracle UNIX Administration Displaying the Number of CPU Processors
Oracle UNIX epc_disabled Environment Variable Administration
Oracle UNIX Monitoring RAM Memory Consumption Administration
The release extends Oracle's database clustering, data centre automation and workload management capabilities, and introduces a multitude of new features.
... ... ...
Oracle Total Recall enables administrators to query data in designated tables 'as of' times in the past. This is touted as an easy, practical way to add a time dimension to data for change tracking, auditing and compliance.
Oracle Flashback Transaction enables users more easily to back out of a transaction made in error, as well as any dependent transactions.
The system supports parallel backup and restore to help improve the performance of very large databases, and hot patching which improves system availability by allowing database patches to be applied without the need to shut databases down.
Oracle 11g also includes new security features including improved Oracle Transparent Data Encryption capabilities beyond column level encryption.
About:
check_oracle_health is a plugin for the Nagios monitoring software that allows you to monitor various metrics of an Oracle database. It includes connection time, SGA data buffer hit ratio, SGA library cache hit ratio, SGA dictionary cache hit ratio, SGA shared pool free, PGA in memory sort ratio, tablespace usage, tablespace fragmentation, tablespace I/O balance, invalid objects, and many more.Release focus: Major feature enhancements
Changes:
The tablespace-usage mode now takes into account when tablespaces use autoextents. The data-buffer/library/dictionary-cache-hitratio are now more accurate. Sqlplus can now be used instead of DBD::Oracle.
Oracle claims that it continues to pick up users for its Linux offering and now is set to add new clustering capabilities to the mix.
So how is Oracle doing with its Oracle Unbreakable Linux? Pretty well. According to Monica Kumar, senior director Linux and open source product marketing at Oracle, there are now 2,000 customers for Oracle's Linux. Those customers will now be getting a bonus from Oracle: free clustering software.
Oracle's Clusterware software previously had only been available to Oracle's Real Application Clusters (RAC) customers, but now will also be part of the Unbreakable Linux support offering at no additional cost.
Clusterware is the core Oracle (NASDAQ: ORCL) software offering that enables the grouping of individual servers together into a cluster system. Kumar explained to InternetNews.com that the full RAC offering provides additional components beyond just Clusterware that are useful for managing and deploying Oracle databases on clusters.
The new offering for Linux users, however, does not necessarily replace the need for RAC.
"We're not saying that this [Clusterware] replaces RAC," Kumar noted. "We are taking it out of RAC for other general purpose uses as well. Clusterware is general purpose software that is part of RAC but that isn't the full solution."
The Clusterware addition to the Oracle Unbreakable Linux support offering is expected by Kumar to add further impetus for users to adopt Oracle's Linux support program.
Oracle Unbreakable Linux was first announced in October 2006 and takes Red Hat's Enterprise Linux as a base. To date, Red Hat has steadfastly denied on its quarterly investor calls that Oracle's Linux offering has had any tangible impact on its customer base.
In 2007, Oracle and Red Hat both publicly traded barbs over Yahoo, which apparently is a customer of both Oracle's Unbreakable Linux as well as Red Hat Enterprise Linux.
"We can't comment on them [Red Hat] and what they're saying," Kumar said. "I can tell you that we're seeing a large number of Oracle customers who were running on Linux before coming to Unbreakable Linux. It's difficult to say if they're moving all of their Linux servers to Oracle or not."
That said, Kumar added that Linux customers are coming to Oracle for more than just running Oracle on Linux, they're also coming with other application loads as well.
"Since there are no migration issues we do see a lot of RHEL [Red Hat Enterprise Linux] customers because it's easy for them to transition," Kumar claimed.
Ever since Oracle's Linux first appeared, Oracle has claimed that it was fully compatible with RHEL and it's a claim that Kumar reiterated.
"In the beginning, people had questions about how does compatibility work, but we have been able to address all those questions," Kumar said. "In the least 15 months, Oracle has proved that we're fully compatible and that we're not here to fork Linux but to make it stronger."
Oracle has introduced Oracle Database 11g, claiming that the latest release boasts more than 400 new features, 15 million test hours and 36,000 person-months of development.The release extends Oracle's database clustering, data centre automation and workload management capabilities, and introduces a multitude of new features.
Oracle Data Guard enables simultaneous read and recovery of standby databases making them available for reporting, backup, testing and 'rolling' upgrades to production databases.
Real Application Testing uses virtualisation techniques to help customers test and manage changes to their IT environment.
Oracle Database 11g also offers a host of new data partitioning and compression capabilities that form part of information lifecycle management and storage management.
Oracle Total Recall enables administrators to query data in designated tables 'as of' times in the past. This is touted as an easy, practical way to add a time dimension to data for change tracking, auditing and compliance.
Oracle Flashback Transaction enables users more easily to back out of a transaction made in error, as well as any dependent transactions.
The system supports parallel backup and restore to help improve the performance of very large databases, and hot patching which improves system availability by allowing database patches to be applied without the need to shut databases down.
Oracle 11g also includes new security features including improved Oracle Transparent Data Encryption capabilities beyond column level encryption.
Oracle ACE Arup Nanda offers a tour of slightly more advanced Linux commands useful for Oracle users, whether developers or DBAs.
In this four-part series from Oracle ACE Arup Nanda, you will learn some not-so-well-known tricks for various routine Linux commands, as well as use cases for more sophisticated commands.
Guide to Linux Filesystem Mastery [05-Nov-2004] by Sheryl Calish
What is a "filesystem", anyway? Sheryl Calish explains the concept as well as its practical application.
Guide to Linux Archive Utility Mastery [30-July-2004]
by Sheryl Calish
Sheryl Calish continues her "Linux Mastery" series with an introduction to the effective
use of the tar, cpio, and rpm facilities for archiving and restoring files.
Are you using Vim, one of the most popular text editors among Linux sysadmins, in an Oracle environment? If so, here are some tips and tricks for getting the most out of the tool.
The sed editor is among the most useful assets in the Linux sysadmin's toolbox, so it pays to understand its applications thoroughly.
Learning Linux? This introduction to the invaluable AWK text-manipulation tool will be invaluable.
Installation Guides Note: not supported unless otherwise indicated! Oracle Database 11g on x86; generic (Oracle - supported) Oracle RAC 10g Rel 2 on Oracle Enterprise Linux and iSCSI (Jeff Hunter) Oracle Database 10g Rel 2 on x86; generic (Oracle - supported) Oracle RAC 10g Rel 2 on x86; RHEL4 and SLES9 (John Smiley) Oracle Database 10g Rel 2 on x86; RHEL3, RHEL4, SLES9 (John Smiley) Oracle Database 10g Rel 2 on SLES10 (Novell) More Install Guides...
In this paper, Best Practice concepts are first defined, then specific high-impact technical issues common with Oracle in the Solaris[tm] Operating Environment are discussed.
12 Dec 2006 | SearchOracle.comThe latest version of Oracle's flagship database -- Oracle Database 11g -- includes a slew of new XML-related features and enhancements, an Oracle executive said.
The main XML upgrades in Database 11g focus on XML DB, Oracle's XML storage and retrieval technology. They include a new binary XML data type, a new XML index and enhanced support for XQuery and other emerging standards, said Willie Hardie, Oracle vice president of database product marketing. Database 11g is currently in the beta testing phase and expected to be released commercially within the next year.
Oracle's database management system (DBMS) has long offered native XML support, meaning that XML data can be stored within the system itself in object-relational or character large object (CLOB) formats. Database 11g expands on this feature by adding the ability to store XML as a binary data type, Hardie said.
"What we're doing with 11g is giving customers more options in terms of how they want to store the data," he said.
Hardie said some of the benefits of native XML support include greater security and the ability to more quickly access the XML data.
"At the end of the day […] an end user doesn't really care too much about where that data sits," he said. "The importance is in how quickly they can get at that data."
On the standards front, Database 11g offers greater support for XQuery, a proposed standard that allows users to extract information from an XML file; the Content Repository API for Java Technology (JSR 170); and SQL XML, which defines a standardized mechanism for using SQL and XML together.
Database 11g also offers "duality" between SQL and XML, meaning that users have the ability to embed XML statements within PL/SQL and vice versa, Hardie said.
Meanwhile, Database 11g developers will have the choice of implementing schema-based or non-schema-based XML definitions, depending on the level of flexibility the application they're working on requires, he said.
"[With a] schema-based-type application, the application needs to know the structure of that piece of XML," he said. "Other times you might not want to know that and you'll store it in a non-schema-based format."
DBAHelper is a collection of scripts to ease the daily maintenance work of Oracle database administrators. Examples are moving objects between tablespaces, analyzing schemata, and rebuilding invalid indices.
Also included is a little framework to simplify the use of RMAN (this framework depends on the use of Oracle 10g with the Recovery Area enabled and properly sized, so all backups go there).
One thing I always needed for Unix was a way to run the same SQL*Plus command on every database, and even databases on other servers. I had a manager who wanted to know the default optimizer mode for every database at a shop that had over 150 databases on 30 database servers. The manager allotted me two days for this task, and he was quite surprised when I provided the correct answer in ten minutes. I did it using the following script:
# Loop through each host name . . . for host in `cat ~oracle/.rhosts|\ cut -d"." -f1|awk '{print $1}'|sort -u` do echo " " echo "************************" echo "$host" echo "************************" # loop from database to database for db in `cat /etc/oratab|egrep ':N|:Y'|\ grep -v \*|grep ${db}|cut -f1 -d':'"` do home=`rsh $host "cat /etc/oratab|egrep ':N|:Y'|\ grep -v \*|grep ${db}|cut -f2 -d':'"` echo "************************" echo "database is $db" echo "************************" rsh $host " ORACLE_SID=${db}; export ORACLE_SID; ORACLE_HOME=${home}; export ORACLE_HOME; ${home}/bin/sqlplus -s /<<! set pages 9999; set heading off; select value from v"\\""$"parameter where name='optimizer_mode'; exit !" done doneThis script requires the Unix remote shell (rsh) privilege so that it can bounce quickly between servers. You do this by making entries into your .rhosts file. The script will loop though all of the server names defined in the .rhosts file on your system, and will then loop through each database listed in each server's /etc/oratab file.
You can use this script to check any database values or to run any SQL*Plus script. You quickly can get user reports, performance statistics, and a wealth of information on every database in your enterprise. I have also used variations on this script to delete old trace files from the Oracle directories and to check free space in archived redo log filesystems. This script has saved me many hours of repetitive work executing the same command against many databases.
The Oracle TNS protocol authentication mechanism fails to properly sanitize authentication requests, possibly allowing a remote attacker to execute arbitrary SQL statements with elevated privileges.Overview
I. Description
Oracle databases authenticate and manage database connections via Oracle Transparent Network Substrate (TNS ) Listeners. According to a report by Imperva, Inc.,The standard authentication mechanism requires a client to supply a valid pair of user name and password. During the login process an Oracle user with no more than "create session" privileges can execute commands in the context of the special database user SYS. This grants any user the highest administrative privileges possible.
The authentication part of the protocol is comprised of two steps, including two different client requests and two server responses respectively. The first request (message code 0x76) contains only the user name while the second (message code 0x73) contains the user name and an obfuscated password.
This second request also contains a list of name-value pairs describing various attributes of the client. The value named "AUTH_ALTER_SESSION" is intended for setting up session attributes related to the locale and language, in the form of an ALTER SESSION SQL statement.
It turns out that this value can contain any SQL statement. Moreover, this command is executed in the context of the SYS user, which operates outside of the Oracle access control mechanism. Thus, by setting the value of "AUTH_ALTER_SESSION" to an arbitrary SQL statement an attacker can execute any arbitrary command in the database. In particular, the attacker can create a new database account and create DBA privileges to the new account.
Note that valid login credentials are needed
to exploit this vulnerability.
Based on research into public information, we believe that this issue is Oracle
vuln# DB18 in the Oracle CPU for January 2006. However, there is not sufficient
information to authoritatively relate Oracle vulnerability information to information
provided by other parties.
A remote attacker, with valid login credentials may be able to execute arbitrary SQL statements with elevated privileges.
Apply patches
This issue is corrected in the Oracle Critical Patch Update for January 2006.
Draft: Feb 10th, 2005This book is dedicated to the memory of my hero, Bob Larson,
who gave more to the UNIX community than most will ever know.
[PDF] Oracle10g for UNIX : Integrating with a Network Appliance Filer
Configuring Databases Using Soft Links (January 2003) by Carlos Godinez
This article explains the advantages of using symbolic (soft) links when configuring databases and provides techniques and examples for using them. This article presents information that will enable you to manage database configuration efficiently and accurately.
[Jan 6, 2006] Oracle 'Worm' Exploit Gets Ominous Tweak by Ryan Naraine (see also Analysis Oracle Worm Voyager)
Exploit code for a malicious worm capable of wreaking havoc through Oracle databases has been tweaked and published, prompting a new round of warnings that an actual attack is inevitable.
Two months after an anonymous researcher released the first public example of an Oracle database worm, the code has been advanced and republished on the Full Disclosure mailing list, adding additional techniques to attack databases.
"It's still very theoretical right now, but I don't think any DBA should be underestimating the risk," said Alexander Kornbrust, CEO of Red-Database-Security GmbH. "If you're running a large company with hundreds of valuable databases, a worm can be very destructive. It is very possible to use this code to release a worm. I can do this right now if I wanted to."
Kornbrust, renowned for his research work around security in Oracle products, claims he has already created an actual exploit that uses default usernames and passwords to target Oracle databases.
In an interview with eWEEK, Kornbrust said the tweaked exploit takes the attack beyond the use of known default username/password schemes. "This exploit connects to the Oracle listener and renames the log file. By doing this, he can create a new database account and set up a scenario where the next time the user connects to the database, the code executes," he explained.
Click here to read more about the first public example of an Oracle database worm."Depending on the payload, if one of these worms gets out, a business under attack can lose every database within 1 or 2 minutes. This is a very serious issue," he added.
Aaron Newman, chief technology officer at Application Security Inc., described the modified code as "more advanced" than the original proof-of-concept that included an apparent taunt aimed at Oracle Corp. CEO Larry Ellison.
"[It is] still lacking the actual implementation to propagate-although it does have the capability. Change one line of code, and this thing would propagate," Newman said in an e-mail note.
According to Red-Database-Security's Kornbrust, database administrators should be fearful of a targeted attack that combines workstation vulnerabilities with a working Oracle exploit. "A successful attack can take aim at the DBA workstation through a Windows vulnerability, gain access to that local machine and use the Oracle worm as a payload to cause damage."
Oracle's security troubles continue to mount. Click here to read more.For the most part, Oracle is an innocent bystander, since the proof-of-concept is not using an actual product flaw to propagate. Instead, Kornbrust said customers are responsible for using strong password schemes in database products. "In this environment, it is not acceptable to have databases with default defaults."
Kornbrust has published his own analysis of the modified exploit to explain the risks. He also warns that the code can be used to create database links and try to guess passwords for additional databases on a network.
Check out eWEEK.com's Security Center for the latest security news, reviews and analysis. And for insights on security coverage around the Web, take a look at eWEEK.com Security Center Editor Larry Seltzer's Weblog.
[Nov 17, 2005] Oracle taps Solaris 10 as 'preferred development platform'
dSQL is an SQL query tool for MySQL, Oracle, Postgres, MS- SQL, ODBC drivers, and all supported Perl DBI drivers. It uses Glade and GTK-Perl.
"Oracle is the latest database vendor to put its weight behind the PHP scripting language for business, with a new tool that integrates PHP applications with its databases.
"Oracle and PHP tool developer Zend Technologies have developed a PHP engine called Zend Core for Oracle. The tool, to be released for free in the summer, will integrate Oracle's databases and Zend's PHP environment..."
Oracle: Open source hucksters and challenge
Oracle Vice President of Technology Marketing Robert Shimp, whose company is among the only database providers not trending toward open source in some way, was critical of some open source moves by database makers in an interview with NewsForge. Shimp did not name names, but he noted that while Oracle welcomes the market growth and competition from open source databases, much of the open source database noise is centered on "orphanware."
Shimp cites companies "using open source because they see it as a marketing mechanism -- a tool for creating hype or awareness of older products. This is 'orphanware' -- software they want to abandon that has no real commercial value, so they put it out and see what happens."
Shimp elaborated by dividing open source database strategies into two categories: "serious" open source databases that provide transparency, allowing developers and users to learn and share; and the "hucksters" putting out abandonware.
In terms of competition from open source, Shimp said Oracle views the other databases as an asset in bringing new database users to the market, calling Oracle's biggest competitor the filing cabinet. Quite often, users are introduced to databases through a free or open source database, then move to Oracle as their needs become greater, according to Shimp, who called innovation Oracle's challenge and advantage.
"I'm confident we'll be able to create cool things that will get people to use Oracle," he said. "But I love the challenge the open source guys are providing."
Pricing:
[Nov 8, 2004] Open-Source Path Not an Option for Oracle, Exec Says - Computerworld
... ... ...
Does Oracle still believe that the typical open-source user is price-sensitive and therefore can't afford Oracle products? We have extremely competitive pricing on our entry-level products, like the Standard Edition One product, that are at a list price of $149 per user (Minimum 5 users so this actually $750 - nnb) This price is highly competitive with open-source databases, which charge a great deal more for their support services.
Yet haven't companies like MySQL been cutting into your market share at the low end with open-source databases? MySQL does not claim the same database market as Oracle. Their product is used typically in the middle tier for storing data such as catalogs or Web sites and things like that. In fact, open-source database products are a good thing for Oracle, because they give a lot of users their first exposure to relational databases and give them an opportunity to learn about the technologies.
Why do you think companies like CA are open-sourcing databases? There are more than two dozen different database companies out there. Some are open-sourcing very old technologies in an effort to rejuvenate their business and grow shrinking market share. I don't see that as very viable.
Now that Red Hat has released Sistina Global File System under the GNU General Public License, do you need to continue updating your cluster file system? We believe that by providing the complete technology infrastructure, including the cluster file system, it is easier to install and maintain our products. The cluster file system is an important component of our clustering technology. In order to make it easier and simpler for our customers to install their products and maintain them, we want to provide a complete technology stack.
... ... ...
Re:I'm sure Oracle's nice and all, but... (Score:3, Insightful)
by dsplat (73054) on Wednesday December 22, @12:43PM (#11160273)He was also critical of "orphanware". While there are reasons to be critical of orphanware announced as if it is a live project, it has some benefits. It is certainly possible for a product to reach a point in its lifecycle at which its residual value to its owner is small, or even negative if support is continued. However, at the same time, it may still be valuable to a small group of customers. Releasing it as open source at that point permits customers to make other arrangements for bug fixes and even new features. Let's not pretend that orphanware is something that it's not. Nonetheless, there are still reasons to be pleased to see it.
Re:I'm sure Oracle's nice and all, but... (Score:5, Insightful)
by tanguyr (468371) on Wednesday December 22, @12:44PM (#11160287)
(http://www.newmediatwins.net/)I think most "typical" Oracle customers are much less sticker-price sensitive than you'd think, since they realize that the cost of developers and DBAs you need to actually do something with your shiny new DB usually far outweighs the cost of the software. If anything, Oracle wins a lot of business in the DB world just like Microsoft wins a lot of business in the productivity suite world: most corporate customers think "Database" = "Oracle" and never really go out there to investigate the alternatives. Re:I'm sure Oracle's nice and all, but... (Score:3, Insightful)
by Sycraft-fu (314770) on Wednesday December 22, @12:59PM (#11160445)There's also the fact that Oracle has a real, proven track record of reliability and scaliblity. There are bunches of companies that run huge Oracle databases on mainframe-supercomptuer hardware that can't ever be down, not even for a minute, and have done so for years. Can something like MySQL do the same? Well, I honestly don't know. However if you are in a position where there will be extreme losses from an outage, you don't want to be the one to test and maybe find out that no, indeed it can't.
By Rick Greenwald, David C. Kreines
December 2002, ISBN 0-596-00336-6
926 pages, $49.95 US. Table of Contents,Chapter 17: Performance (PDF Format)
No more hunting around through voluminous docs, January 9, 2003
Reviewer: Calvin Goodrich (see more about me) from Redwood Shores, CA USA Finally, a single place to go for questions like: "What goes in that tnsnames.ora file?", "What does the init.ora parameter BUFFER_POOL_RECYCLE do?", and "What's the format for creating a PL/SQL function?". An excellent quick reference (If you can call a book with 912 pages "quick".)
Google matched content |
Oracle Database - Wikipedia, the free encyclopedia
Oracle9i Release 2 (9.2) Documentation
The Cuddletech SAs Guide to Oracle ebook by Ben Rockwood
Draft: Feb 10th, 2005This book is dedicated to the memory of my hero, Bob Larson,
who gave more to the UNIX community than most will ever know.
OraFAQ, a technical portal. Includes the archives of the ORACLE-L email list
Solaris™Operating System and ORACLE Relational Database Management System Performance Tuning -- Sun's blueprint (2003)
Installing and configuring Oracle on Solaris -- a nice guide. From the Database Specialists web site.
Oracle Installing Oracle 8 Solaris-Sparc Tutorial This technical document will take you through a step by step process for installing Oracle 8 / EE on Solaris for Sun Sparc boxes.
VERITAS NetBackup 5.x for Oracle for Solaris (VT-269)
Quick start on Oracle8i & Solaris The oracle documentation for installs is horrendous. So is the install proceedure. There are a lot of steps that oracle could have automated, but didn't. So here's a very simple checklist of how to get oracle running on solaris. (There are also a few random oracle tips at the bottom)
Optimizing Solaris for Oracle 8.x 5/22/2001
Using Oracle on Solaris.
Dale Strickland-Clak dale at riverhall.NOSPAM.co.uk Tue Mar 23 03:10:54
EST 2004. Previous message: Using Oracle on Solaris ... mail.python.org/pipermail/ python-list/2004-March/213290.html - 4k - |
Sun Fire E25K Server Running Oracle 10g, Solaris 10 Sets Record
Sun Fire E25K Server Running Oracle
10g, Solaris 10 Sets Record. news.taborcommunications.com/ msgget.jsp?mid=334227&xsl=story.xsl - 7k - |
OpenNET: статья - [Solaris] Настройка параметров Oracle (oracle ...
[Solaris] Настройка параметров Oracle
(oracle tune solaris) ... [Solaris] Настройка
параметров Oracle > Машина 2 CPU SPARC, 1GB RAM, 2 SCSI диска,
Solaris 8 ... www.opennet.ru/base/sys/oracle_option.txt.html - 20k - Nov 17, 2005 - |
[PDF] Sizing Memory for Oracle on Solaris George Schlossnagle.
File Format:
PDF/Adobe Acrobat -
View as HTML Sizing Memory for Oracle on Solaris. George Schlossnagle. [email protected]. 0.1 Introduction. Anyone who manages or owns an Oracle database needs to know ... www.omniti.com/~george/sizing_wp.pdf - |
EvDBT.Com - White Papers and Presentations
Sun/Oracle Best Practices (January 2001) by Bob Sneed
In this paper, Best Practice concepts are first defined, then specific high-impact
technical issues common with Oracle in the Solaris Operating Environment are discussed.
Configuring Databases Using Soft Links (January 2003) by Carlos Godinez
This article explains the advantages of using symbolic (soft) links when configuring
databases and provides techniques and examples for using them. This article presents
information that will enable you to manage database configuration efficiently and
accurately.
Solaris Operating System and ORACLE Relational Database Management System Performance
Tuning (October 2003)
-by Ramesh Radhakrishna
This article focuses on the performance problems at the Resource Tier (database
server). The assumption is that the database server is a Sun server running an ORACLE
Relational Management System (RDBMS). The article requires a general knowledge of
Solaris Operating System (Solaris OS) and Oracle RDBMS system administration. It
is written for beginner- and intermediate-level system administrators responsible
for Sun systems, and for Sun's customer engineers, and database administrators responsible
for tuning Oracle databases.
Solaris Operating System and ORACLE Relational Database Management System Performance
Tuning (October 2003)
-by Ramesh Radhakrishna
This article focuses on the performance problems at the Resource Tier (database
server). The assumption is that the database server is a Sun server running an ORACLE
Relational Management System (RDBMS). The article requires a general knowledge of
Solaris Operating System (Solaris OS) and Oracle RDBMS system administration. It
is written for beginner- and intermediate-level system administrators responsible
for Sun systems, and for Sun's customer engineers, and database administrators responsible
for tuning Oracle databases.
Avoiding Common Performance Issues When Scaling RDBMS Applications With Oracle9i
Release 2 And Sun Fire Servers (March 2003)
-byGlenn Fawcett
There are a handful of common performance issues that arise when trying to scale Oracle database applications on Solaris Operating Enironment. These issues are sometimes difficult to identify and address. This paper incorporates the experiences of Sun's Strategic Application Engineering group in tuning Oracle RDBMS systems on a variety of workloads. There are accompanying document, Avoiding Common Performance Issues When Scaling RDBMS Applications With Oracle9i Release 2 And Sun Fire Servers Appendices, that supplements the information in this article.
Understanding the Benefits of Implementing Oracle RAC on Sun Cluster Software
(January 2005)
-by Kristien Hens and Michael Loebmann
In solutions that implement Oracle RAC and Sun Cluster software, the flexibility
and power of Sun's cluster solution can add structure and maintainability to various
underlying hardware components. This article describes the benefits of an Oracle
RAC and Sun Cluster solution.
This article is the complete second chapter of the Sun BluePrints book, "Creating Highly Available Database Solutions: Oracle Real Application Clusters (RAC) and Sun Cluster 3.x Software," by Kristien Hens and Michael Loebmann, is now available at our Sun BluePrints publication page, amazon.com, and Barnes & Noble bookstores. This article targets an intermediate audience.
Memory Hierarchy in Cache-Based Systems (November 2002)
-by Ruud Van Der Pas
This article will help the reader understand the architecture of modern microprocessors
by introducing and explaining the most common terminology and addressing some of
the performance related aspects. Written for programmers and people who have a general
interest in microprocessors, this article presents introductory information on caches
and is designed to provide understanding on how modern microprocessors work and
how a cache design impacts performance.
Despite improvements in technology, microprocessors are still much faster than main memory. Memory access time is increasingly the bottleneck in overall application performance. As a result, an application might spend a considerable amount of time waiting for data. This not only negatively impacts the overall performance, but the application cannot benefit much from a processor clock-speed upgrade either. One method for overcoming this problem is to insert a small high-speed buffer memory between the processor and main memory. Such a buffer is generally referred to as cache memory, or cache for short.
Drill-Down Monitoring of Database Servers - Chapter 21 (June 2002)
-by Allan N. Packer
Database expert, Allan N. Packer, shares database best practices from his recently-released
book,
"Configuring and Tuning Databases on the Solaris Platform", ISBN# 0-13-083417-2.
In this article, Allen presents a process for identifying and resolving problems
with the performance of database servers.
Monitoring and Tuning Oracle - Chapter 22, Part II (August 2002)
-by Allan N. Packer
Building on his July 2002 Sun BluePrints OnLine article, Allan continues to provide
more best practices for Oracle monitoring using utlbstat/utlestat scripts
and to recommend parameter settings for OLTP and DSS environments. Issues ranging
from load performance to dynamic reconfiguration and Oracle recovery are also examined.
Additional Oracle monitoring and tuning recommendations are available in his recently
released book
"Configuring and Tuning Databases on the Solaris Platform."
Monitoring and Tuning Oracle - Chapter 22, Part II (August 2002)
-by Allan N. Packer
Building on his July 2002 Sun BluePrints OnLine article, Allan continues to provide
more best practices for Oracle monitoring using utlbstat/utlestat scripts
and to recommend parameter settings for OLTP and DSS environments. Issues ranging
from load performance to dynamic reconfiguration and Oracle recovery are also examined.
Additional Oracle monitoring and tuning recommendations are available in his recently
released book
"Configuring and Tuning Databases on the Solaris Platform."
Oracle Tutorial - A Beginners Guide
Oracle Tutorial - A Beginners Guide (Part 2)
Quick start on Oracle8i & Solaris
create user username identified by password_here; grant connect, resource to username;
create table pubtable (value1 int, value2 char); create public synonym pubtable for pubtable;
- Finding primary/nonprimary keys for a table
select * from user_constraints where TABLE_NAME = "yourtable";
- Finding column names/types for a table(in sqlplus only)
desc tablename;
- Finding oracle session id (SID) from a unix process id
select SPID,SID,ADDR from v$process,v$session where ADDR = PADDR and SPID={UNIX pid} ;
cdemo82.sql has a very special and interesting line in it, if you have access to the oracle account, but get locked out of the database. PS: system/manager, sys/change_on_install
Society
Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers : Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism : The Iron Law of Oligarchy : Libertarian Philosophy
Quotes
War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda : SE quotes : Language Design and Programming Quotes : Random IT-related quotes : Somerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose Bierce : Bernard Shaw : Mark Twain Quotes
Bulletin:
Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 : Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law
History:
Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds : Larry Wall : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOS : Programming Languages History : PL/1 : Simula 67 : C : History of GCC development : Scripting Languages : Perl history : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history
Classic books:
The Peter Principle : Parkinson Law : 1984 : The Mythical Man-Month : How to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite
Most popular humor pages:
Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor
The Last but not Least Technology is dominated by two types of people: those who understand what they do not manage and those who manage what they do not understand ~Archibald Putt. Ph.D
Copyright © 1996-2021 by Softpanorama Society. www.softpanorama.org was initially created as a service to the (now defunct) UN Sustainable Development Networking Programme (SDNP) without any remuneration. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.
FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.
This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...
|
You can use PayPal to to buy a cup of coffee for authors of this site |
Disclaimer:
The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the Softpanorama society. We do not warrant the correctness of the information provided or its fitness for any purpose. The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.
Last modified: March 12, 2019