Pages

Wednesday, February 27, 2013

AutoConfig Customization


Autoconfig is a very effective configuration management tool, but there are times when it falls short of meeting all our requirements and it becomes necessary to customize it. Following are some of the examples where you would need to customize autoconfig. You need to add another zone to the Jserv.  In this case you would have to customize oracle supplied autoconfig template which corresponds to jserv.properties configuration file, to add entries for another zone, you would also have to create a custom template for the properties file for this new custom zone. You may also need to add some custom context variables to the context file for this new custom template. You have some custom product tops. You would have to add these custom product top environment variables to the formservlet.ini file to access the custom forms. In this case you will have to customize the formservlet.ini’s autoconfig template to add your custom product top variables. You can construct these product tops based on the $APPL_TOP's context variable i.e.%s_at%/<custom_product_top> or you can create new context variable for each custom producttop. In that case you will have to add these to the context file as custom context variables. You have developed a custom application and you want autoconfig to maintain all the configuration files of this custom application. In this case you will have to create custom driver files, custom templates and probably some custom context variables. All the above examples show that there are three types of customizations that should satisfy most of the custom requirements:
Adding custom context variables to the context file
Customizing an AutoConfig template file delivered by Oracle.
Creating custom Autoconfig templates and custom Autoconfig driver.
Adding Custom Context Variables:
Adding a context variable to the context file means, adding a node in the context file with mandatory attribute oa_var and optional attributes oa_type, oa_enabled and scope. This node will have only one child node that will be a text node holding the value of the context variable. Autoconfig doesn’t care where or at what level this node is put in the file. So to make this work you can use any xml parser and add the node to the context file at any position you like and it will serve the purpose. But there are two drawbacks to this method. One this would cause maintenance problem since it will be difficult to differentiate between custom and seeded context variables and secondly oracle's software is not aware of this customization, which means whenever we run adbldxml.pl oradclonectx.pl to clone the context file, we will loose our custom entries. The first problem can be easily overcome by adding all custom context variables under a top level xml node oa_customized and starting all the custom node oa_var values from "c_". Now we can easily distinguish between custom and seeded context variables and it’s easy to maintain since we know where all the customizations lie in the context file. In the context file section, I mentioned that the context file is created by plugging in instance specific values into the context file template $AD_TOP/admin/adxmlctx.tmp. So adding xml node oa_customized and all our custom variables under oa_customized to this template would take care of the second problem too. Now let's look at different ways of adding custom context variables.

Oracle Application Manager:
Oracle Application Manager from version 2.1 onwards provides us with extensive ways to manipulate the context files. Updating the context variables is one of them, which we looked at earlier. It also provides us with the option of adding custom context variables. Adding custom context variables in OAM results in following sequence of events:
OAM saves the custom context variable details like name, attribute oa_var value, attribute oa_type value, title and description into table fnd_oam_context_custom.
OAM updates the existing row's status to 'H' (History) for adxmlctx.tmp infnd_oam_context_files.
OAM inserts a new row for adxmlctx.tmp with status 'S'. This new adxmlctx.tmp has ourcustom context variable added under node oa_customized.
OAM Requests FNDFS listener of the destination node to update the adxmlctx.tmp on thefile system.
OAM Repeats the process for all the context files with status='S' and context_type=’A’
Using perl module TXK::XML:
Oracle Application Manager is indeed a neat way to add custom context variables but there are a few problems. We have to add one variable at a time, so in our report server configuration file example, for replacing maxconnect, cachesize, maxidle, initengine and englife we will have to repeat the process 5 times. This can be quite cumbersome as the number of variables to be added increase. Secondly we need access to Oracle Applications but there are times (like configuring a clone) when we want to add custom context variables but OAM is unavailable. This calls for a programmatic method to add custom context variables.Using perl module TXK::XML we can write a small perl program to add many context variables atone shot without needing any access to Oracle Application Manager. For doing this we have to first load the context file and the context template file as TXK::XML object and then use add Node method of TXK::XML package(class for OOP enthusiasts) to add the custom nodes. The only thing to note is that add Node expects a reference to a hash containing all the information about the node to be added. I am going to show you a piece of code for adding custom variables. It will add the custom variables mentioned in the above example of reports server configuration file. Following table details the information about the context variables we are adding.
The only question that remains is, how do we know REP60_server.ora is the template for reportsserver configuration file. In this case I found out by “grepping” for the configuration file name in the driver files (mostly adtmpl.drv and fndtmpl.drv since they manage most of the configuration files).The third field in the template’s file entry in the product driver gives us the template name. Before ADX.F this was the only way to find template files for configuration files. With ADX.F, since oracle has decided to completely support autoconfig customizations, they have provided a script $AD_TOP/bin/adtmplreport.sh to find out the template names. This script in turn runs the javaclass oracle.apps.ad.tools.configuration.ATTemplateReport. This script is a generic script to generate report on all the autoconfig templates and corresponding configuration files. But it also provides a way to find out the template file from the given configuration file and vice versa. It alsoreports if there is a custom template for the given configuration file.

adtmplreport.sh contextfile=/u01/home/applHOPP/admin/HOPP_jinzo.xml \ target=/u01/app/oracle/product/config/HOPP_jinzo/8.0.6/reports60/server/REP60_HOPP.ora verbose#########################################################################Generating Report .....#########################################################################APPL_TOP Context[AD_TOP]TEMPLATE FILE : /u01/home/applHOPP/ad/11.5.0/admin/template/REP60_server.oraTARGET FILE : /u01/app/oracle/product/config/HOPP_jinzo/8.0.6/reports60/server/REP60_HOPP.ora

Monday, February 25, 2013

DBA related LINUX commands


Basic File Navigation
·         The "pwd" command displays the current directory.
root> pwd
/u01/app/oracle/product/9.2.0.1.0
·         The "ls" command lists all files and directories in the specified directory. If no location is defined it acts on the current directory.
    root> ls
    root> ls /u01
    root> ls -al
                The "-a" flag lists hidden "." files. The "-l" flag lists file details.
·         The "cd" command is used to change directories.
    root> cd /u01/app/oracle
·         The "touch" command is used to create a new empty file with the default permissions.
    root> touch my.log
·         The "rm" command is used to delete files and directories.
    root> rm my.log
    root> rm -R /archive
The "-R" flag tells the command to recurse through subdirectories.
·         The "mv" command is used to move or rename files and directories.
    root> mv [from] [to]
    root> mv my.log my1.log
    root> mv * /archive
    root> mv /archive/* .
The "." represents the current directory.

·         The "cp" command is used to copy files and directories.
    root> cp [from] [to]
    root> cp my.log my1.log
    root> cp * /archive
    root> cp /archive/* .
·         The "mkdir" command is used to create new directories.
    root> mkdir archive
·         The "rmdir" command is used to delete directories.
    root> rmdir archive
·         The "find" command can be used to find the location of specific files.
    root> find / -name dbmspool.sql
    root> find / -print | grep -i dbmspool.sql
The "/" flag represents the staring directory for the search. Wildcards such as "dbms*" can be used for the filename.
·         The "which" command can be used to find the location of an executable you are using.
    oracle> which sqlplus
The "which" command searches your PATH setting for occurrences of the specified executable.
File Permissions
·         The "umask" command can be used to read or set default file permissions for the current user.
    root> umask 022
The umask value is subtracted from the default permissions (666) to give the final permission.
    666 : Default permission
    022 : - umask value
    644 : final permission
·         The "chmod" command is used to alter file permissions after the file has been created.
    root> chmod 777 *.log
    Owner      Group      World      Permission
    =========  =========  =========  ======================
    7 (u+rwx)  7 (g+rwx)  7 (o+rwx)  read + write + execute
    6 (u+wx)   6 (g+wx)   6 (o+wx)   write + execute
    5 (u+Rx)   5 (g+Rx)   5 (o+Rx)   read + execute
    4 (u+r)    4 (g+r)    4 (o+r)    read only
    2 (u+w)    2 (g+w)    2 (o+w)    write only
    1 (u+x)    1 (g+x)    1 (o+x)    execute only

·         Character eqivalents can be used in the chmod command.
    root> chmod o+rwx *.log
    root> chmod g+r   *.log
    root> chmod -Rx   *.log
·         The "chown" command is used to reset the ownership of files after creation.
    root> chown -R oinstall.dba *
The "-R" flag causes the command ro recurse through any subdirectories.
OS Users Management
·         The "useradd" command is used to add OS users.
    root> useradd -G oinstall -g dba -d /usr/users/my_user -m -s /bin/ksh my_user
    The "-G" flag specifies the primary group.
    The "-g" flag specifies the secondary group.
    The "-d" flag specifies the default directory.
    The "-m" flag creates the default directory.
    The "-s" flag specifies the default shell.
·         The "usermod" command is used to modify the user settings after a user has been created.
    root> usermod -s /bin/csh my_user
·         The "userdel" command is used to delete existing users.
    root> userdel -r my_user
The "-r" flag removes the default directory.
·         The "passwd" command is used to set, or reset, the users login password.
    root> passwd my_user
·         The "who" command can be used to list all users who have OS connections.
    root> who
    root> who | head -5
    root> who | tail -5
    root> who | grep -i ora
    root> who | wc -l
    The "head -5" command restricts the output to the first 5 lines of the who command.
    The "tail -5" command restricts the output to the last 5 lines of the who command.
    The "grep -i ora" command restricts the output to lines containing "ora".
    The "wc -l" command returns the number of lines from "who", and hence the number of connected users.
Process Management
·         The "ps" command lists current process information.
    root> ps
    root> ps -ef | grep -i ora
·         Specific processes can be killed by specifying the process id in the kill command.
    root> kill -9 12345
uname and hostname
·         The "uname" and "hostname" commands can be used to get information about the host.
    root> uname -a
    OSF1 oradb01.lynx.co.uk V5.1 2650 alpha
                                    root> uname -a | awk '{ print $2 }'
    oradb01.lynx.co.uk
    root> hostname
    oradb01.lynx.co.uk
·         Error Lines in Files
You can return the error lines in a file using.
    root> cat alert_LIN1.log | grep -i ORA-
The "grep -i ORA-" command limits the output to lines containing "ORA-". The "-i" flag makes the comparison case insensitive. A count of the error lines can be returned using the "wc" command. This normally give a word count, but the "-l" flag alteres it to give a line count.
    root> cat alert_LIN1.log | grep -i ORA- | wc -l
    Alias
·         An alias is a named shortcut for a longer command using the following format.
    alias name='command'
For example, if you require sudo access for a specific command, you might want to include this as an alias so you don't have to remember to type it.
 alias myscript='sudo -u oracle /path/to/myscript'
Remove DOS CR/LFs (^M)
·         Remove DOS style CR/LF characters (^M) from UNIX files using.
    sed -e 's/^M$//' filename > tempfile
The newly created tempfile should have the ^M character removed.
Where available, it is probably better to use the dos2unix and unix2dos commands.
Compress Files
In order to save space on the filesystem you may wish to compress files such as archived redo logs. This can be using either the gzip or the compress commands. The gzip command results in a compressed copy of the original file with a ".gz" extension. The gunzip command reverses this process.
    gzip myfile
    gunzip myfile.gz
The compress command results in a compressed copy of the original file with a ".Z" extension. The uncompress command reverses this process.
    compress myfile
    uncompress myfile
General Performance
vmstat
Reports virtual memory statistics.
    # vmstat 5 3
    procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
     r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa st
     0  0      0 1060608  24372 739080    0    0  1334    63 1018 1571 14 11 66 10  0
     0  0      0 995244  24392 799656    0    0  6302   160 1221 1962 10 10 62 18  0
     0  0      0 992376  24400 799784    0    0     1    28  992 1886  3  2 95  0  0
    #
free
Reports the current memory usage. The "-/+ buffers/cache:" line represents the true used and free memory, ignoring the Linux file system cache.
    # free
                 total       used       free     shared    buffers     cached
    Mem:       8178884    4669760    3509124          0     324056    1717756
    -/+ buffers/cache:    2627948    5550936
    Swap:     10289148          0   10289148
    #
iostat
Reports I/O statistics.
    # iostat
    Linux 3.2.10-3.fc16.x86_64 (maggie.localdomain)          03/19/2012         _x86_64_(4 CPU)

    avg-cpu:  %user   %nice %system %iowait  %steal   %idle
               2.02    0.23    0.51    0.78    0.00   96.46
    Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
    sda               9.23       100.55        62.99    1796672    1125538
    dm-0             13.60       100.31        62.99    1792386    1125524
    dm-1              0.02         0.08         0.00       1432          0
CPU Usage
sar
On Linux systems sar (System Activity Reporter) is probably one of the simplest and most versatile tools for reporting system utilization including CPU, memory, disk and network activity. It automatically collects system activity statistics when installed using the following command.
    # yum install sysstat
The sar command syntax takes the following form.
    # sar [options] [interval [count]]
                top
Displays top tasks.
CRON
There are two methods of editing the crontab file. First you can use the "crontab -l > filename" option to list the contents and pipe this to a file. Once you've editied the file you can then apply it using the "crontab filename".
    Login as root
    crontab -l > newcron
                Edit newcron file.
 crontab newcron
Alternatively you can use the "crontab -e" option to edit the crontab file directly.
The entries have the following elements.
    field          allowed values
    -----          --------------
    minute         0-59
    hour           0-23
    day of month   1-31
    month          1-12
    day of week    0-7 (both 0 and 7 are Sunday)
    user           Valid OS user
    command        Valid command or script.
The first 5 fields can be specified using the following rules.
    *       - All available values or "first-last".
    3-4     - A single range representing each possible from the start to the end of the range inclusive.
    1,2,5,6 - A specific list of values.
    1-3,5-8 - A specific list of ranges.
    0-23/2  - Every other value in the specified range.
The following entry runs a cleanup script a 01:00 each Sunday. Any output or errors from the script are piped to /dev/null to prevent a buildup of mails to root.
    0 1 * * 0 /u01/app/oracle/dba/weekly_cleanup > /dev/null 2>&1