Showing posts with label oracle database. Show all posts
Showing posts with label oracle database. Show all posts

Wednesday, July 8, 2015

Shell Script–Applying a command or a SQL script to all databases in the same host

Hello everyone,

This is my first post on the oracle blogs section!

I really hope the posts I will publish here help some of you to have a more dynamic and comfortable work.

This time I'm publishing a simple KSH script that can allow you to apply a single command or a SQL script to all running databases in a single host.

Now let's explain each part:

  • Functions
    • Utility Functions: refer to this post to check the utility functions I normally use.
      • You'll see debugPrint and msgPrint in most of my shell scripts. Those are used to give a nice format to the message I'm sending to the console/log.
    • Crawl
      • This is the main function that receives the command/sql file to be run in every instance.
  • Main Algorythm
    • for DBNAME in $(ps -ef | grep pmon | cut -d"_" -s -f3 | grep -v ASM)
      • Here, we cycle through all the running instances in the host. Looking for pmon processes and getting only the INSTANCE name from it.
    • crawl "@${2}"
      • In the SQL script mode see how the argument passed to the crawl function is appended to the @ sign, so that we don't have to check for it when running inside the function.
    • crawl "${2}"
      • In the command mode we pass the argument inside double quotes so that it is considered a single argument by the function while running.

With some light modifications, we can get this same schema to work with any of the command line utilities from Oracle. But that's a future project of mine. I will try to add support for RMAN in the next few months as my work allows me to.


Hope that some of you find this post useful.

Monday, July 6, 2015

Shell script–Quickly check Oracle listeners

Hello everyone,

Today I would like to share something with you. In my day to day work, I have encountered more than one place where DEV environments are spread through only some hosts. This normally leads to creating several databases on the same host and to create several listeners to be able to split communication through several ports.

Having this, after OS patches or any OS related activity that would require the database software to be shutdown, it's an usual case that people forget to start listeners.  For this I have this useful script:

Enjoy.

Hope this helps in making your job easier.

Tuesday, January 24, 2012

Configuring EM DB Console manually

Welcome, for the DBAs out there, any tool that helps understand the  metrics of the DB performance faster is a helping hand in his daily job, the Enterprise Manager (EM) is no exception to this rule.

For the Oracle Database 10g and over, the EM can be automatically configured during the installation using the Oracle Universal Installer (OUI).  Depending on a variety of circumstances, this installation/configuration may fail, and thus we will have to create, or recreate the EM repository and configuration manually, by using the Enterprise Manager Configuration Assistant.

Contrary to what many of you would expect, the EMCA is not a GUI tool, but a command-line tool and thus, it can take us some time to read the entire list of options and clauses that can be added to the command in order to fulfill the task of configuring the EM and creating the necessary repository within the Oracle instance.

So, here you go.  The basic instructions you’ll need to create or recreate your repository and configure the EM are these:

emca –repos drop

emca –repos create

emca –deconfig dbcontrol db

emca –config dbcontrol db

But be sure to have the complete information of your instance because you will need it to fill the blanks when running these commands.  You’ll need: SID, port, password for sysdba and/or sysoper accounts.

If you are still having trouble, check your time zone settings.  For linux, the TZ environment variable should be set and it must match the line agentTZRegion within the EMD.properties file.

Hope this can help you out there.

All your comments are welcome.