OCI -CLONE(ONPREM/CLOUD)

EC2-EC2-CLONE

EC2 TO RDS (DATAPUMP)

 How To Import A Schema on Amazon RDS

As you know, there are two types of cloud services AWS provides (EC2 & RDS) while EC2 let you have the full control over the Operating System OS including root access, RDS doesn't give you any kind of OS access. Because RDS instance is managed by AWS they provide you a master admin user , this user has limited admin privileges (neither a SYSDBA nor DBA), making regular DBA tasks such as importing a schema a bit challenging.

Without having an OS access you won't be able to use commands like: exp ,expdp, imp, impdp and rman.


Below are the stAPPS how to import a schema into RDS using Oracle built-in packages. Luckily Oracle provides many built-in packages enable you to perform lots of tasks without the need to have an OS access.


Below is the Amazon document importing a schema into RDS:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Oracle.Procedural.Importing.html


Task Summary:

Export a schema with name "APPS_TRX" on an 11.2.0.3 database resides on AWS EC2 Linux instance and upload the export dump file to S3 bucket, then import the dump file into a 12.2.0.1 AWS RDS database along with changing the schema name to "APPS.


Prerequisites:

- An AWS S3 bucket must be created and Both Source EC2 and Target RDS must have RW access to it through a role. [S3 bucket is a kind of a shared storage between AWS cloud systems where you can upload/download the files to/from it, it will be used during this demo to transfer the export dump file between EC2 source instance and RDS target instance].


Step1: Export the schema on Source [EC2 instance]:

I've already an OS access to oracle user on the source EC2 instance so I used exportdata script to export APPS_TRX schema.


Note: In case you are importing from Enterprise Edition DB to Standard Edition DB make sure to reset all tables having COMPRESSION option enabled to NOCOMPRESS before exporting the data:

i.e.

alter table APPS_TRX.compressed_table NOCOMPRESS;


This is because Standard Edition doesn't have COMPRESSION feature. Otherwise the table creation will fail with ORA-39083 error during the import on the Standard Edition DB.



Step2: Upload the export file to S3 Bucket from Source [EC2 instance]:

In case the bucket is not yet configured on the source machine you can use the following AWSCLI command to configure it providing the bucket's "Access Key" and "Secret Access Key":


  # aws configure

  AWS Access Key ID [None]: XXXXXXXXXXXXXXXX

  AWS Secret Access Key [None]: XXXXXXXXXXXXXXXXX

  Default region name [None]: 

  Default output format [None]: 


Note: The keys above are dummy ones, you have to put your own bucket key.


 Upload the export dump files to the S3 bucket:

  # cd /backup

  # aws s3 cp EXPORT_APPS_TRX_STG_04-03-19.dmp  s3://APPS-bucket


In case you are using S3 Browser from a Windows machine, configure the bucket using this flow:

Open S3 Browser -> Accounts -> Add New Account:

<you will use your bucket details here I'm just giving an example>

Account Name:   APPS-bucket

Account Type:   Amazon S3 Storage

Access Key ID:  ***********

Secret Access Key: ************

Click "Add New Account"

Accounts -> click "APPS-bucket" -> Click "Yes" to add 'External bucket' -> Bucket Name: "APPS-bucket"


Note: S3 Browser is a Windows GUI tool provided by AWS that help you deal with uploading/downlading the file to/from S3 bucket. you can download it from here:

https://s3browser.com/download.aspx


Step2: Download the export file from the S3 Bucket to the Target [RDS instance]:

Remember, there is no OS access on RDS, so we will connect to the database using any tools such as SQL Developer using the RDS master user credentials.


Use the AWS built-in package "rdsadmin.rdsadmin_s3_tasks" to download the dump file from S3 bucket to DATA_PUMP_DIR:


Warning: The following command will download all the files in the bucket, so make sure before running this command to remove all the files except the export dump files.


SELECT rdsadmin.rdsadmin_s3_tasks.download_from_s3(

      p_bucket_name    =>  'APPS-bucket',       

      p_directory_name =>  'DATA_PUMP_DIR') 

   AS TASK_ID FROM DUAL; 


In case you have the export files stored under a specific directory, you can tell the download procedure to download all the files under that specific directory by using p_s3_prefix parameters like this: [don't forget the slash / after the directory name]


SELECT rdsadmin.rdsadmin_s3_tasks.download_from_s3(

      p_bucket_name    =>  'APPS-bucket',      

      p_s3_prefix          =>  'export_files/', 

      p_directory_name =>  'DATA_PUMP_DIR') 

   AS TASK_ID FROM DUAL;


Or, in case you only want to download one named file at a time under a specific directory, just provide that file name as shown to p_prefix parameter:


SELECT rdsadmin.rdsadmin_s3_tasks.download_from_s3(

      p_bucket_name    =>  'APPS-bucket',      

      p_s3_prefix          =>  'export_files',

      p_prefix                =>  'EXPORT_APPS_TRX_STG_04-03-19.dmp',

      p_directory_name =>  'DATA_PUMP_DIR')

   AS TASK_ID FROM DUAL; 


Above command will return a TASK ID:


TASK_ID                                                                        

--------------------------

1866786876865468-797  


Use that TASK_ID to monitor the download progress by running this statement:

SELECT text FROM table(rdsadmin.rds_file_util.read_text_file('BDUMP','dbtask-1866786876865468-797.log'));


In case you get this error:

ORA-00904: "RDSADMIN"."RDSADMIN_S3_TASKS"."DOWNLOAD_FROM_S3": invalid identifier


This means S3 integration is not configured with your RDS.

To configure S3 integration: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/oracle-s3-integration.html


##################STEPS TO CREATE POLOCY,ROLE AND ASSIGN ROLE DB##############

FROM CONSOLE

============

Open the IAM Management Console: https://console.aws.amazon.com/iam/home?#/home

In the navigation pane, choose Policies -> Create policy On the Visual editor tab, choose Choose a service, and then choose S3 -> Check All S3 actions

Choose Resources, and choose Add ARN for the bucket -> Enter the Bucket name: APPS-bucket

Click Review Policy -> Give it a name "APPS-s3-integration" -> Create Policy

Associate your IAM role with your RDS DB:

Sign in to the AWS Management Console: https://console.aws.amazon.com/rds/

Choose the Oracle DB instance name -> On the Connectivity & security tab -> Manage IAM roles section:

IAM roles to this instance: -> "APPS-s3-integration"

Feature -> S3_INTEGRATION

Click "Add role"

Make sure that your database is running with "rds-s3-integration" option group parameters.

FROM CLI

========


POLICY CREATION:

The following AWS CLI command creates an IAM policy named rds-s3-integration-policy with these options. It grants access to a bucket named your-s3-bucket-arn.

aws iam create-policy \

   --policy-name rds-s3-integration-policy \

   --policy-document '{

     "Version": "2012-10-17",

     "Statement": [

       {

         "Sid": "s3integration",

         "Action": [

           "s3:GetObject",

           "s3:ListBucket",

           "s3:PutObject"

         ],

         "Effect": "Allow",

         "Resource": [

           "arn:aws:s3:::your-s3-bucket-arn", 

           "arn:aws:s3:::your-s3-bucket-arn/*"

         ]

       }

     ]

   }'                        

ROLE CREATION:

The following AWS CLI command creates the rds-s3-integration-role for this purpose.


aws iam create-role \

   --role-name rds-s3-integration-role \

   --assume-role-policy-document '{

     "Version": "2012-10-17",

     "Statement": [

       {

         "Effect": "Allow",

         "Principal": {

            "Service": "rds.amazonaws.com"

          },

         "Action": "sts:AssumeRole"

       }

     ]

   }'                            

ATTACH ROLE TO POLICY:

The following AWS CLI command attaches the policy to the role named rds-s3-integration-role.


aws iam attach-role-policy \

   --policy-arn your-policy-arn \

   --role-name rds-s3-integration-role                             

ADD ROLE TO DB INSTANCE:

The following AWS CLI command adds the role to an Oracle DB instance named mydbinstance.


aws rds add-role-to-db-instance \

   --db-instance-identifier mydbinstance \

   --feature-name S3_INTEGRATION \

   --role-arn your-role-arn                           

   

   

   

Once the download is complete, query the downloaded files under DATA_PUMP_DIR using this query:

select * from table(RDSADMIN.RDS_FILE_UTIL.LISTDIR('DATA_PUMP_DIR')) order by mtime;


Any file having "incomplete" keyword, means it still getting downloaded.


Now the AWS related tasks are done, let's jump to the import part which is purely Oracle's.


Step3: Create the tablespace and the target schema user on the Target [RDS instance]:

In case the target user does not yet exist on the target RDS database, you can go ahead and create it along with its tablespace.


-- Create a tablespace: [Using Oracle Managed Files OMF]

CREATE SMALLFILE TABLESPACE "TBS_APPS" DATAFILE SIZE 100M AUTOEXTEND ON NEXT 100M LOGGING EXTENT MANAGEMENT LOCAL AUTOALLOCATE SEGMENT SPACE MANAGEMENT AUTO;


-- In case you need to create a Password Verify Function on RDS:

Note: As you cannot create objects under SYS in RDS you have to use the following ready made procedure by AWS to create the Verify Function:

Note: The verify function name should contains one of these keywords: "PASSWORD", "VERIFY", "COMPLEXITY", "ENFORCE", or "STRENGTH"


begin

    rdsadmin.rdsadmin_password_verify.create_verify_function(

        p_verify_function_name     => 'CUSTOM_PASSWORD_VFY_FUNCTION',

        p_min_length                      => 8,

        p_max_length                     => 256,

        p_min_letters                      => 1,

        p_min_lowercase                => 1,

        p_min_uppercase                => 1,

        p_min_digits                       => 3,

        p_min_special                     => 2,

        p_disallow_simple_strings => true,

        p_disallow_whitespace       => true,

        p_disallow_username         => true,

        p_disallow_reverse             => true,

        p_disallow_db_name          => true,

        p_disallow_at_sign             => false);

end;

/

-- In case you want to create a new profile:

create profile APP_USERS limit

LOGICAL_READS_PER_SESSION DEFAULT

PRIVATE_SGA          DEFAULT

CPU_PER_SESSION         DEFAULT

PASSWORD_REUSE_TIME      DEFAULT

COMPOSITE_LIMIT         DEFAULT

PASSWORD_VERIFY_FUNCTION CUSTOM_PASSWORD_VFY_FUNCTION

PASSWORD_GRACE_TIME      DEFAULT

PASSWORD_LIFE_TIME     90

SESSIONS_PER_USER     DEFAULT

CONNECT_TIME         DEFAULT

CPU_PER_CALL         DEFAULT

FAILED_LOGIN_ATTEMPTS     6

PASSWORD_LOCK_TIME     DEFAULT

PASSWORD_REUSE_MAX     12

LOGICAL_READS_PER_CALL     DEFAULT

IDLE_TIME         DEFAULT;

 -- Create the user: [Here the user as per my business requirements will be different than the original user on the Source DB]

CREATE USER APPS IDENTIFIED  BY "test123" DEFAULT TABLESPACE TBS_APPS TEMPORARY TABLESPACE TEMP QUOTA UNLIMITED ON TBS_APPS PROFILE APP_USERS;

GRANT CREATE SESSION TO APPS;

GRANT CREATE JOB TO APPS;

GRANT CREATE PROCEDURE TO APPS;

GRANT CREATE SEQUENCE TO APPS;

GRANT CREATE TABLE TO APPS;


Step4: Import the dump file on the Target [RDS instance]:

Open a session from SQL Developer and make sure this session will not disconnect as far as the import is running, by the RDS master user execute the following block of code which will keep running in the foreground allowing you to monitor the import job on the fly and see any incoming errors:


DECLARE

  ind NUMBER;                      -- Loop index

  h1 NUMBER;                       -- Data Pump job handle

  percent_done NUMBER;     -- Percentage of job complete

  job_state VARCHAR2(30);  -- To keep track of job state

  le ku$_LogEntry;         -- For WIP and error messages

  js ku$_JobStatus;        -- The job status from get_status

  jd ku$_JobDesc;         -- The job description from get_status

  sts ku$_Status;            -- The status object returned by get_status

BEGIN


  h1 := DBMS_DATAPUMP.OPEN( operation => 'IMPORT', job_mode => 'SCHEMA', job_name=>null);


-- Specify the single dump file and its directory   DBMS_DATAPUMP.ADD_FILE(handle => h1, directory => 'DATA_PUMP_DIR', filename => 'EXPORT_APPS_TRX_STG_04-03-19.dmp');

-- Specify the logfile for the import process: [Very important to read it later after the completion of the import]  DBMS_DATAPUMP.ADD_FILE(handle => h1, directory => 'DATA_PUMP_DIR', filename => 'import_APPS_TRX_STG_04-03-19.LOG', filetype => DBMS_DATAPUMP.KU$_FILE_TYPE_LOG_FILE);


-- Disable Archivelog for the import: [12c new feature]  DBMS_DATAPUMP.metadata_transform ( handle => h1, name => 'DISABLE_ARCHIVE_LOGGING', value => 1);


-- REMAP SCHEMA:

--  DBMS_DATAPUMP.METADATA_REMAP(h1,'REMAP_SCHEMA','APPS_TRX','APPS');

-- If a table already exists: [SKIP, REPLACE, TRUNCATE]

  DBMS_DATAPUMP.SET_PARAMETER(h1,'TABLE_EXISTS_ACTION','SKIP');


-- REMAP TABLESPACE:  DBMS_DATAPUMP.METADATA_REMAP(h1,'REMAP_TABLESPACE','APPS','TBS_APPS');


-- Start the job. An exception is returned if something is not set up properly.  DBMS_DATAPUMP.START_JOB(h1);


-- The following loop will monitor the job until it get complete.meantime the progress information will be displayed:

 percent_done := 0;

  job_state := 'UNDEFINED';

  while (job_state != 'COMPLETED') and (job_state != 'STOPPED') loop

    dbms_datapump.get_status(h1,

           dbms_datapump.ku$_status_job_error +

           dbms_datapump.ku$_status_job_status +

           dbms_datapump.ku$_status_wip,-1,job_state,sts);

    js := sts.job_status;


-- If the percentage done changed, display the new value.     if js.percent_done != percent_done

    then

      dbms_output.put_line('*** Job percent done = ' ||

                           to_char(js.percent_done));

      percent_done := js.percent_done;

    end if;


-- If any work-in-progress (WIP) or Error messages were received for the job, display them.       if (bitand(sts.mask,dbms_datapump.ku$_status_wip) != 0)

    then

      le := sts.wip;

    else

      if (bitand(sts.mask,dbms_datapump.ku$_status_job_error) != 0)

      then

        le := sts.error;

      else

        le := null;

      end if;

    end if;

    if le is not null

    then

      ind := le.FIRST;

      while ind is not null loop

        dbms_output.put_line(le(ind).LogText);

        ind := le.NEXT(ind);

      end loop;

    end if;

  end loop;


-- Indicate that the job finished and gracefully detach from it.   dbms_output.put_line('Job has completed');

  dbms_output.put_line('Final job state = ' || job_state);

  dbms_datapump.detach(h1);

END;

/

In case you have used wrong parameters or bad combination e.g. using METADATA_FILTER instead of METDATA_REMAP when importing to a schema having a different name, you will get a bunch of errors similar to the below cute vague ones:


ORA-31627: API call succeeded but more information is available

ORA-06512: at "SYS.DBMS_DATAPUMP", line 7143

ORA-06512: at "SYS.DBMS_SYS_ERROR", line 79

ORA-06512: at "SYS.DBMS_DATAPUMP", line 4932

ORA-06512: at "SYS.DBMS_DATAPUMP", line 7137


ORA-06512: at line 7


You can also monitor the execution of the import job using this query:

SQL> SELECT owner_name, job_name, operation, job_mode,DEGREE, state FROM dba_datapump_jobs where state='EXECUTING';


 In case you want to Kill the job: <Provide the '<JOB_NAME>','<OWNER>'>

 SQL> DECLARE

            h1 NUMBER;

        BEGIN

            h1:=DBMS_DATAPUMP.ATTACH('SYS_IMPORT_SCHEMA_01','APPS');

            DBMS_DATAPUMP.STOP_JOB (h1, 1, 0);

         END;

  / 


Once the job is complete compare the number of objects between source and target DBs:

SQL> select object_type,count(*) from dba_objects where owner='APPS' group by object_type;


Also you can view the import log on RDS using this query:

SQL> set lines 10000 pages 0

           SELECT text FROM table(rdsadmin.rds_file_util.read_text_file('DATA_PUMP_DIR','import_APPS_TRX_STG_04-03-19.LOG'));           


Or: You can upload the log to S3 bucket and get it from there:

SQL> select * from table(RDSADMIN.RDS_FILE_UTIL.LISTDIR('DATA_PUMP_DIR')) order by mtime;


SQL> SELECT rdsadmin.rdsadmin_s3_tasks.upload_to_s3( p_bucket_name => '<bucket_name>', p_prefix => '<file_name>', prefix => '', p_directory_name => 'DATA_PUMP_DIR') AS TASK_ID FROM DUAL;

   

Run the After Import script that generated by exportdata script at Step 1 after replacing the original exported schema name APPS_TRX with the target imported schema name APPS.


Check the invalid objects:

SQL> col object_name for a45

select object_name,object_type,status from dba_objects where owner='APPS' and status<>'VALID';


Compile invalid object: [If found]

SQL> EXEC SYS.UTL_RECOMP.recomp_parallel(4, 'APPS');


Step5: [Optional] Delete the dump file from the Target [RDS instance]:

Check the exist files under DATA_PUMP_DIR directory:

SQL> select * from table(RDSADMIN.RDS_FILE_UTIL.LISTDIR('DATA_PUMP_DIR')) order by mtime;

Generate delete script for all files:

SQL> select 'exec utl_file.fremove(''DATA_PUMP_DIR'','''||filename||''');' from table(RDSADMIN.RDS_FILE_UTIL.LISTDIR('DATA_PUMP_DIR')) order by mtime;

  Run the output script:

  e.g. exec utl_file.fremove('DATA_PUMP_DIR','EXPORT_APPS_TRX_STG_04-03-19.dmp');


For more reading on a similar common DBA tasks on RDS:

http://dba-tips.blogspot.com/2020/02/the-dba-guide-for-managing-oracle.html


References:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Oracle.Procedural.Importing.html

S3 Bucket creation:

https://docs.aws.amazon.com/AmazonS3/latest/gsg/CreatingABucket.html

DBMS_DATAPUMP:

https://docs.oracle.com/database/121/ARPLS/d_datpmp.htm#ARPLS356

RDS Master Admin User:

https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/UsingWithRDS.MasterAccounts.html

Import  


How to run AUTOCONFIG OR FNDLOAD COMMAND PATCH FILE SYSTEM IN R12.2

 1.      To run Autoconfig from the patch file system you must disable trigger ebs_login prior to running autoconfig.

SQL> show user;
USER is "SYSTEM"
SQL> alter trigger ebs_logon disable;

Trigger altered.

2.      Now run autoconfig with the patch env sourced

[appltest@test001]$ echo $FILE_EDITION
[appltest@test001]$patch
[appltest@test001]$ adautocfg.sh
Make sure Autoconfig completes ok
     3. Enable the login trigger “alter trigger ebs_logon enable”
                 SQL> conn system/Oracle4u
                 Connected.
               SQL> SQL> alter trigger ebs_logon enable;

                Trigger altered.

In the below case also you can use ebs_login triggger disable and try FNDLOAD FOR PATCH FS

FNDLOAD apps/********* 0 Y UPLOAD $FND_TOP/patch/115/import/afcpprog.lct $XBOL_TOP/fndload/CCP.ldt - WARNING=YES UPLOAD_MODE=REPLACE CUSTOM_MODE=FORCE
APP-FND-01564: ORACLE error 604 in AFPCOA
Cause: AFPCOA failed due to ORA-00604: error occurred at recursive SQL level 1
ORA-20099: E-Business Suite Patch Edition does not exist.
ORA-06512: at line 29
.The SQL statement being executed at the time of the error was:  and was executed from the file .


To Get Forms Runtime Diagnostics also know as FRD logs

 ######Tracing And Logging For Forms In Oracle Applications [ID 438652.1]######

How to check Forms are Implemented in socket mode or servlet mode. 

==================================================

 1. R12.1 Forms can be implemented in servlet mode or socket mode. Check file $FORMS_WEB_CONFIG_FILE (or $INST_TOP/ora/10.1.2/forms/server/appsweb.cfg) to find which mode forms runs:


In Servlet mode:
serverURL=/forms/lservlet
connectMode=servlet    

In Socket mode:
serverURL=(should be blank)
connectMode=Socket

This can be also verified by Profile option "ICX: Forms Launcher" value https://hostname.domain:port/forms/frmservlet on site level.

How To Enable FRD logs?

1: Obtain FRD Trace Using Appsweb.cfg
2: Obtain FRD Trace Using Profile Options
3: Obtain FRD in an ADHOC way

1) To enable FRD on Site level:
In appsweb.cfg, set "record=collect" as shown below (under ENVIRONMENT SPECIFIC PARAMETERS section)

# Sub argument for other params
record=collect

also can specify the log name
log=site1.log 

2) To enable FRD on User level:
Change Profile option "ICX: Forms Launcher" on user level to https://hostname.domain:port/forms/frmservlet?record=collect

Then, launch forms after logging onto EBS (usually without any services downtime, but may need to bounce Apache or clear cache). Forms shall popup a note "Forms Runtime Diagnostics is enabled, Please note this can affect performance." before forms shows up.

By default, trace file collect_<pid> gets written in folder $FORMS_TRACE_DIR, where <pid> is the process identifier.  "grep" the pid to find which os process created it.

Optionally, in appsweb.cfgs, specify the log name
log=user1.log
(Note: Log file site1.log or user1.log will be saved in folder $FORMS_TRACE_DIR. This folder may need manually cleaning from time to time.)

3) Enabling FRD (in R12.1) by URL https://hostname.domain:port/forms/frmservlet?record=collect ( or https://hostname.domain:port/forms/frmservlet?record=collect+log=user1.log )
Enter EBS userID/password to access forms directly. But it may give error:
APP-FND-01542: This Applications Server is not authorized to access this database.

To get this working, modify current context file by changing “s_appserverid_authentication” value from SECURE to OFF. Then shutdown apps and run Autoconfig.

3. When QA uses Vugen 12 for scripting and uses HP Performance Center (PC) 12 to run the scripts to test EBS R12.1.3 site performance, I was asked to change Profile option "ICX: Forms Launcher" on user level from https://hostname.domain:port/forms/frmservlet to
https://hostname.domain:port/forms/frmservlet?play=&record=names

I did not know what that profile value really does. But after the change, performance testing worked by PC 12 for our QA.

NOTES:  For JWS, do NOT use Method 2 of Option 1 in Doc ID 438652.1 or follow Doc ID 373548.1 (How To Collect And Use Forms Trace (FRD) in Oracle Applications Release 12) to enable FRD by setting up profile option Forms Runtime Parameters to "record=forms tracegroup=0-97". It will give error "FRM-90926: Duplicate Parameter on Command Line" without launching forms.


OUTPUT
=======
When a form is run with FRD enabled, a combination of external user-application interactions and internal Forms processing events are written in chronological order to a log file. These events can be analyzed to determine user actions and corresponding system responses, which aid in problem diagnosis and issue resolution. Kindly refer below display for a brief extract from a frd log file.


Extracts from a frd log file :

File Name: /oracle1/PROD/inst/apps/PROD_vkaria/logs/ora/10.1.2/forms/collect_32188
Process ID: 22334
Client IP: 141.19.111.99
Forms 10.1 (Forms Runtime) Version 10.1.2.0.2 (Production)
PL/SQL Version 10.1.0.5.0 (Production)
Oracle Virtual Graphics System Version 10.1.2.0.0 (Production)
Oracle Multimedia Version 10.1.2.0.2 (Production)
Oracle Tools Integration Version 10.1.2.0.2 (Production)
Oracle Tools Common Area Version 10.1.2.0.2
Oracle CORE 10.1.0.4.0 Production


Opened file: /oracle1/PROD/apps/apps_st/appl/fnd/12.0.0/forms/US/FNDSCSGN.fmx

ON-LOGON Trigger Fired:
Form: FNDSCSGN

State Delta:
FNDSCSGN, 1, Trigger, Entry, 2016355936, ON-LOGON

FNDSCSGN, 2, Prog Unit, Entry, 2017421936, /FNDSCSGN-1/P53_04_JAN_200703_41_43

FNDSCSGN, 3, Prog Unit, Entry, 2018075936, /FNDSCSGN-1/DO_LOGON


Executing DEFAULT_VALUE Built-in:
In Argument 0 - Type: String Value: NULL
In Argument 1 - Type: String Value: GLOBAL.FNDSCSGN_UNAME

Executing GET_APPLICATION_PROPERTY Built-in:
In Argument 0 - Type: Number Value: 73
Out Argument 0 - Type: String Value: NULL

Note:http://appsdbastuff.blogspot.com/2010/04/forms-runtime-diagnostics-frd-tracing.html

Multiple-opatch-automation

########################SCRIPT TO APPLY MULTIPLE OPATCHES################################
P=/testappl/APRILCPU2020/DB/SR_Patches
export P 
for Patch in 21321429 20123899 28682351 25139545 30216977 21967332 25099339 23604553 31179008 30614876
do 
cd $P/$Patch 
$ORACLE_HOME/OPatch/opatch apply -silent -local 
done 

multiple-dir-rename

for DIR in   xxxx09   xxxx10   xxxx11   xxxx14   
do
cd /$DIR
mv -i PRODUTION DEV
done

INVALID-BACKUP-AUTOMATION

#################SCRIPT FOR AUTOMATIC INVALID TABLE BACKUP###########

#!/usr/bin/bash
##rm pcount.log
##rm qcount.log
t=`date +"%Y%m%d%H%M%S"`
p="invalids$t"
pcount="pcount.$t"
qcount="qcount.$t"
a=`grep -o '[0-9]\+' pcount.log|sed -n 1p`
b=`grep -o '[0-9]\+' qcount.log|sed -n 1p`
sqlplus -s "/ as sysdba"  << EOF
create table $p as select * from dba_objects where status like 'INVALID';
spool pcount.log
select count (*) from $p;
exit;
EOF
sqlplus -s "/ as sysdba" << EOF
spool qcount.log
select count(*) from dba_objects where status like 'INVALID';
exit;
EOF
if [ $a == $b ]
then
echo "#########****INVALID TABLE BACKUP HAS BEEN TAKEN SUCESSFULLY****#######"
echo       "INVALID-BACKUP-TABLENAME:           $p"
echo       "INVALID-BACKUP-TABLECOUNT:          $a"
echo       "ACUTAL-INVALID-TABLE-COUNT:         $b"
else
sqlplus -s "/ as sysdba"  << EOF
spool drp.txt
drop table $p;
spool off;
exit;
EOF
echo "There is an issue with taking automated backup so please check and take the invalid count manually"
fi

NODE MANAGER INSTALL/CONFIG IN WEBLOGIC


***********Uninstall / Reinstall NodeManager Service on WINDOWS***

This needs to be done if you installed Node Manager with the standard installer because by default Node Manager binds to localhost. So as more OS instances are added, it will be required to have Node Manager instances on the network communicate to each other. This can only happen if Node Manager binds to an network interface that is available remotely.

open cmd prompt
run D:\Oracle\wls11g\wlserver_10.3\server\bin\setWLSEnv.cmd
run D:\Oracle\wls11g\wlserver_10.3\server\bin\uninstallNodeMgrSvc.cmd
Make backup copy of installNodeMgrSvc.cmd
edit installNodeMgrSvc.cmd to bind to hostname for remote starts
set NODEMGR_HOST=jbayer-us
run D:\Oracle\wls11g\wlserver_10.3\server\bin\installNodeMgrSvc.cmd
start the service – mine is called “Oracle WebLogic NodeManager…” but on older versions it’s likely will start with “BEA …”
starting the NodeManager process should create the nodemanager.properties file we will edit next
CrashRecovery and StartupScriptEnabled (updated 01/10/2010)
We want to Enable NodeManager to restore servers to their last known state after a reboot.
Open nodemanager.properties from the directory D:\Oracle\wls11g\wlserver_10.3\common\nodemanager\
Change the CrashRecoveryEnabled property from false to true:
CrashRecoveryEnabled=true
Also, because the domain’s \bin\startWebLogic script already has classpath configured, which is especially helpful for use with SmartUpdate that manages WebLogic patches as those classpath’s are not trivial to understand, I strongly recommend setting StartupScriptEnabled=true StartScriptEnabled=true in nodemanager.properties (Thanks to Ray T for the typo fix 6/29/10)
stop/start node manager after making changes to nodemanager.properties
Set up the Machines
Go to the domain's AdminServer console
http://localhost:7001/console
If you need to start it, run \bin\startWebLogic.cmd
With the console navigate to -> Environment -> Machines
Create a new machine – I named mine after the hostname of the server - jbayer-us
If you have more than one OS instance, create one machine for each.
nm_machines

In console go to -> Environment -> Servers
Create a new server, example: managedServer1
Put in the listen address to the hostname you want to bind to, in my case jbayer-us
Change the port to 8001or another available port so as not to conflict with the 7001 port of the AdminServer
Assign managedServer1 it to the jbayer-us machine you just created - -> Enviornment -> Servers -> managedServer1
There should be a dropdown you can use to select the machine
Click the save button on this settings page (don't forget this step)
Now activate changes if required
We need to assign the machine for the AdminServer, this cannot be done while the AdminServer is running.

Stop AdminServer
Open the domain config, example - D:\Oracle\wls11g\user_projects\domains\my_domain\config\config.xml
Find the element used to assign the machine for managedServer1
jbayer-us
Copy that and paste that element right after the AdminServer element
If it is not already set, also specify the AdminServer listen address to be the hostname to bind to, by default it is blank which means bind to all network interfaces.
After these changes my config.xml snippet for the AdminServer looks like this:


AdminServer

jbayer-us

jbayer-us



Start the AdminServer again with the domain directory’s bin\startWebLogic.cmd
Check the console page -> Environment -> Servers to see that the servers are defined correctly as expected

Enroll the domain with Node Manager (updated 01/10/2010)
Navigate with a command prompt go to the domain directory
run bin\setDomainEnv.cmd
run java weblogic.WLST
connect to the AdminServer with your credentials:
connect('weblogic','welcome1','t3://jbayer-us:7001')
Make sure you use forward slashes instead of backslashes in Windows:
nmEnroll(domainDir='D:/Oracle/wls11g/user_projects/domains/my_domain',nmHome='D:/Oracle/wls11g/wlserver_10.3/common/nodemanager')
Now go back to the web console - http://localhost:7001, for each server in the environment, go to the server start tab and put in the appropriate values.
serverStartTabIf you are using StartScriptEnabled=true in nodemanager.properties, then the classpath and jvm arguments from the script will be used first and the values you specify on the Server Startup tab will get added to the end, so you only need to enter values that are unique to each server in the classpath and arguments section.
If you’re using Sun JDK instead of JRockit, then use –Xrs instead of –Xnohup refer to the official docs for more on this, but it has to do with handling OS signals properly.
7-2-10 update: Reader Ray T writes in with another tip:
“After some testing: starting, stopping servers, killing processes, rebooting etc after the configuration, I also found that I could not get the managed servers to shutdown cleanly - or at least the console would not recognize that they had. This had the added side effect of then not letting me start/restart a managed server via the console.

I found that also adding StopScriptEnabled=true solved that final problem.”



Click the image to enlarge – actual text values below:

Java Home

D:\Oracle\wls11g\jrockit_160_14_R27.6.5-32

Java Vendor

Oracle

BEA Home

D:\Oracle\wls11g

Root Directory

D:\Oracle\wls11g\user_projects\domains\my_domain

Classpath is empty as the script values are sufficient

Arguments

-Xnohup

Security Policy File

D:\Oracle\wls11g\wlserver_10.3\server\lib\weblogic.policy

User Name

weblogic

Password

welcome1

Confirm Password

welcome1

Save
Now do the same thing for each managed server.
Activate the changes if required

Node Manager Domain Username and Password
Set the Node Manager username/password for the domain in the console
Click in the console navigator
Select Security tab
Expand to the "Advanced" options about half-way down the page
Choose a Node Manager username/password and put it in the username/password/confirm boxes your credentials, these could be unique from your user used to start the AdminServer, but I chose to keep mine the same weblogic/welcome1.  If you change this user name and password, then you’ll need to specify both when using the command nmConnect().  Thanks Ray T for the catch - 6/29/10.

Decrease Log Verbosity For Standard OutnmCriticalLogSetting
In console, go to each server's Logging -> General page
Expand to the Advanced section half-way down the page
Change the standard out notice level to "Critical"
This log file that captures Standard Out does not roll over while a server is running, so it's really important to make sure this file doesn't get too large. Note that this is not the server log file, this is only standard out.



Have NodeManager Start and Stop the Servers
If it is running, shutdown the AdminServer
Start the AdminServer with NodeManager
Go to domain dir
run bin\setDomainEnv.cmd
run java weblogic.WLST
nmConnect(domainName='my_domain')  nmConnect(domainName=’my_domain’, username=’weblogic’, password=’welcome1’)  6/29/10 Updated thanks to Ray T who noticed that if you change the domain’s Node Manager user and password in the section above called “Node Manager Username and Password” that you’ll need to specify those values here otherwise the defaults of weblogic/welcome1 are used, which worked in my case, but not for others.
nmStart('AdminServer')
Go to console -> Environment -> Servers control tab and start the managed server from the console. It will send a command to Node Manager which actually performs the operation on the console's behalf.
Gotcha! – If you have never started the managed server ever before and you try to start it from Node Manager, you might get an error.  In the server log it mjght say something like: Booting as admin server, but servername, managedServer1, does not match the admin server name, AdminServer  To get around this, simply start the Managed Server for the first time using either the Admin Console Servers->Control tab or the startManagedWebLogic.cmd script.  Subsequent nmStart commands should not have this issue any longer.

Test Killing and Restarting
If the servers are started successfully by Node Manager, try and kill a process from task manager and see if it restarts.

Looking at the Node Manager directory in the domain for each Managed Server, you will be able to see the state - below is a screenshot of managedServer1's files. The PID and .state files should tell you what you need to know to see if the server recovered.  If it did not, the .out file in the server log directory should hopefully give you a clue why.

nmDir

If manual killing of the process restarts a Server then you are ready to test an operating system reboot. Reboot the machine without stopping the WebLogic Servers. Each server should be restored to the state that it was in when the OS was rebooted.

How to Enroll a Node Manager in weblogic?
========================================================================
Applies to:
Weblogic: 10.3.6 and later
========================================================================
nmEnroll is used to enroll a machine or a domain with the node manager.
Few of us may forget to configure NodeManager after installing Weblogic server. Follow below steps to enroll nodemanager manually in weblogic.
1. Create a Machine:
     • Login to weblogic console
     • Click on Lock & Edit button in change center.
     • Go to Environment -> Machines -> click New
     • Provide name and select machine OS
     • Click Next
     • Select type, provide host and port details for node manager and click Finish
     • Click Activate Changes.

2. Configure node manager username and password:
     • Login to weblogic console and take lock & edit.
     • Under domain Structure click on domain_name on left hand side.
     • Go to security tab and click on Advanced.
     • Configure/update NodeManager Username and password.
     • Click save and click Active Changes.

3. Enroll Node Manager:
     • Make sure admin server is up and running.
     • Login to host
     • Go to $ORACLE_HOME/oracle_common/common/bin and run ./wlst.sh
     • Use Connect command to connect to admin server
        connect('','','t3://:')
     • Run nmEnroll
        nmEnroll('', '')
        E.g.
        nmEnroll('/u01/Oracle/Middleware/user_projects/domains/base_domain',                '/u01/Oracle/Middleware/wlserver_10.3/common/nodemanager')
     • Once it is Successfully enrolled to machine with the domain directory check
        $WL_Home/common/nodemanager/nodemanager.domains file. It should have domain entry.
     • Set StartScriptEnabled=true and StopScriptEnabled=true in $WL_Home/common/nodemanager/nodemanager.properties file.
     • Restart the nodemanager and check the status in weblogic console if it is in active status or not.
     • Go to Environment -> Machines -> Click on Machine name
     • Go to Monitoring tab and verify Node Manager Status


Note 1 -

If you are getting below error during connect with node manager, then it means you haven't changed username,password for nodemanager from admin console ( above step 6 )

WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Access to domain 'base_domain' for user 'weblogic' denied

Note 2 -

If you are getting below error during connect of node manager then it mean you haven't followed above defined steps OR haven't added your domain on nodemanager.domains


WLSTException: Error occured while performing nmConnect : Cannot connect to Node Manager. : Configuration error while reading domain directory

OPENVPN AS BASTON HOST IN AWS

ref:https://www.freecodecamp.org/news/how-you-can-use-openvpn-to-safely-access-private-aws-resources-f904cd24f890/


STEPS:
Create Linux server(ec2) as a private node
Create Openvpn server along with adding the linux server subnet id rannge in Security group
Once your openvpn server is ready then you can able to ssh from openvpn to your linux server




automation-healthcheck

Problem for automation

[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ cat req.txt
Submitted request 4632124 for CONCURRENT FND FNDSCURS

[user@server lk]$ awk '{print $3}' req.txt
4632124


SQL> SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ > req.txt
[user@server lk]$ cat req.txt
[user@server lk]$ CONCSUB apps/passwordofuser SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
[user@server lk]$ cat req.txt
Submitted request 4632126 for CONCURRENT FND FNDSCURS

[user@server lk]$ sqlplus apps/passwordofuser << EOF
> spool healthcheck.txt
> set lines 300
> select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
> ,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
> from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
> where a.concurrent_program_id=b.concurrent_program_id
> and program_application_id=0
> and REQUEST_ID=4632126;
> spool off;
> exit;
> EOF

SQL*Plus: Release 8.0.6.0.0 - Production on Wed Apr 1 07:41:10 2020

(c) Copyright 1999 Oracle Corporation.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> SQL> SQL>   2    3    4    5    6
USER_CONCURRENT_PROGRAM_NAME                                                                                                               CONCURRENT_PROGRAM_ID REQUEST_ID R P S ACTUAL_ST
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------- ---------- - - - ---------
COMPLETION_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Active Users                                                                                                                               20641     4632126   C C 01-APR-20
Normal Running


***After few minits--we dont estimate the time***

SQL> SQL> SQL>   2    3    4    5    6
USER_CONCURRENT_PROGRAM_NAME                                                                                                               CONCURRENT_PROGRAM_ID REQUEST_ID R P S ACTUAL_ST
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ --------------------- ---------- - - - ---------
COMPLETION_TEXT
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Active Users                                                                                                                               20641     4632126   C C 01-APR-20
Normal completion


when it get the status like completion then we need to conculde that reqeust has been completed and application is running fine




########################SOLUTION IS #######healthcheck report for oracle apps

#!/bin/sh
username=$1;
password=$2;
> req.txt;
> healthcheck.txt;
sd=`echo $TWO_TASK`
CONCSUB $1/$2 SYSADMIN 'System Administrator' SYSADMIN WAIT=N CONCURRENT FND FNDSCURS > req.txt
requid=`awk '{print $3}' req.txt`
echo $requid;
sqlplus $1/$2 << EOF
spool healthcheck.txt
set lines 300
select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
where a.concurrent_program_id=b.concurrent_program_id
and program_application_id=0
and REQUEST_ID=$requid;
spool off;
exit;
EOF
####REQSTATUS####
a=`cat healthcheck.txt|grep Normal|wc -l`
while [ $a -le 1 ]
do
> healthcheck.txt
echo "$requid is running"
sleep 2
sqlplus $1/$2 << EOF
spool healthcheck.txt
set lines 300
select a.user_concurrent_program_name , a.CONCURRENT_PROGRAM_ID , REQUEST_ID
,REQUEST_TYPE,PHASE_CODE  , STATUS_CODE , ACTUAL_START_DATE ,COMPLETION_TEXT
from fnd_concurrent_programs_tl a, fnd_concurrent_requests b
where a.concurrent_program_id=b.concurrent_program_id
and program_application_id=0
and REQUEST_ID=$requid;
spool off;
exit;
EOF
a=`cat healthcheck.txt|grep Normal|wc -l`
done
rm -rf healthcheck.txt
>outfile.txt
echo REQUESTID=$requid > outfile.txt
echo PROGRAMNAME="Active users" >>outfile.txt
echo STATUS="COMPLETED" >> outfile.txt
echo PHASE="NORMAL" >> outfile.txt
###DBSTATUS#####
###spool DB.txt
sqlplus $1/$2 << EOF
spool DB.txt
conn $1/$2
select * from global_name;
spool off;
exit;
EOF
b=`cat DB.txt|grep Connected|wc -l`
if [$b -ge 1 ]
then
rm -rf DB.txt
echo DATABASENAME=$sd >> outfile.txt
echo DBSTATUS="UP AND RUNNING" >> outfile.txt
fi
########APACHE STATUS#############
as=`pwd`
rm -rf apache.txt
cd $COMMON_TOP/admin/scripts/$TWO_TASK*
rm -rf apache.txt
sh adapcctl.sh status > apache.txt
chmod -R 777 apache.txt
cp -r apache.txt $as
cd $as
p=`cat apache.txt|grep not|wc -l`
if [$p -ge 1 ]
then
echo APACHESTATUS="APACHE IS NOT RUNNING"  >> outfile.txt
else
echo APACHESTATUS="APACHE IS UP AND  RUNNING" >> outfile.txt
fi