Skip to main content

Posts

Showing posts from February, 2014

Database links without TNSNAMES.ora

So, you step a test database on another server, and you don't want to wait for PUPPET 1 to push out an update to your managed TNSNAMES.ora file with the database connection information. So how to you create a database link? The short answer can be summed up like so: " Don't overthink the problem. " Normally we create database links like so: SQL> create database link devdb connect to scott identified by tiger using 'DEVDB';   where DEVDB is an entry in your TNSNAMES.ora file. In the absence of such entries, a close approximation of the TNSNAMES.ora entry so we have this instead: SQL> create database link devdb connect to scott identified by tiger using '(DESCRIPTION = (ADDRESS= (PROTOCOL=TCP)(HOST=devhost.domain.com)(PORT=1521))(CONNECT_DATA=(SID=DEVDB)))'; 1 because you manage TNSNAMES files with a configuration tool, like Puppet, right? RIGHT!

Oracle log monitoring from a shell script

I found this rather old article when looking up some shell scripting syntax. Occasionally there is gold to be found: search_log.sh.  A variety of logs are generated by Oracle products, and you might be interested in monitoring them. The database alert log contains messages that are critical to database operations. Log files are also generated when products are installed or deinstalled and when patches are applied. The following script iterates over a file passed to it as an argument. If any lines are found that contain ORA-, an e-mail message is sent to a designated recipient. cat $1 | grep ORA- > alert.err if [ ‘cat alert.err|wc -l‘ -gt 0 ] then mail -s "$0 $1 Errors" administrator@yourcompany.com < alert.err fi The specific test being performed is a count of the number of words that exist in the file alert.err, which is written when you redirect to alert.err. If the word count (  wc ) is greater than (  -gt ) zero, the contents of the if block