Showing posts with label SQL SCRIPTS. Show all posts
Showing posts with label SQL SCRIPTS. Show all posts

Wednesday, 28 November 2018

How to take Apps Tier backup using gtar command in R12

Hi DBA-Mates, Topic: Backup Apps Tier using gtar command in R12
We would like to share this command because sometimes we got confused while taking backup for Apps Tier in real time scenario.
The confusion is that current APPS directory should not get zipped, really many times such situation came with our junior.

So, I thought lets prepare a document and share with them as well as you all here.
So, hope this may useful and helpful for future references.

One more thing should be noted that, we can take backups for apps tier when the services are up & running.
So, please don't get confused with it, especially for juniors...

Backup can taken in two ways either screen or nohup command. Both are used for backend running process.

How to use screen command:
1. screen -ls  ## it will give output for list of screen which earlier people has used.

2. screen -l   ## this command is used to start new screen, once you type the this command it means you are in New screen where you can perform your activities.

3. Ctrl+a+d    ##  Always use this command to exit from current screen i.e. Press together Ctrl,a,d otherwise your screen will terminated/closed.

4. screen -r screen_name ## this command is used for re-attached old screen, screen_name you can get from screen -ls command.

Note: Before using old screen_name , make sure there should not be running old command or scripts.

If you want to use nohup command then:
nohup < your command for backup > &

Now, let's see the command:
Syntax:  $gtar -czvf </path/backup_filename_date.tar.gz> <directory which you want to be zipped>

Example: $gtar -czvf /u01/backup/apps_12June2018.tar.gz apps

Explanation:
/u01/backup/apps_12June2018.tar.gz -- file backup for cloning.
apps -- we want backup for this directory.

applmgr@ora-data:/u01/ebs->ps -ef|grep gtar
 applmgr  7366  6943   1 23:56:42 pts/15      0:37 gtar -czvf /u01/backup/apps_12June2018.tar.gz apps
 applmgr  7996  9516   1 00:00:43 pts/6       0:03 gtar -czvf /u01/backup/inst_12June2018.tar.gz inst
 applmgr  8007 21175   0 00:00:59 pts/1       0:00 grep gtar
applmgr@ora-data:/u01/ebs->

SCP command syntax with example:
Syntax:
scp user@host:/<source file path> <destination path>  ## running on destination host

Example:
scp oracle@host:/u01/PROD/backup/PROD_20170719_1105702_1_FULL ./

Note: It will ask for password, please provide username's password like oracle user.

Some more important Points:
Oracle Deadlocks
Regards,

Tuesday, 4 April 2017

Crontab Concepts and details with examples

                               Crontab Concepts and details:
Hey BDA-Mates,
As we know that CRON is a Linux program and it is very helpful and useful for a programmer or DBA.

Crontab allows a task to be run automatically in background at mentioned date/time.
For example: 
We can schedule cron for backups, schedules update, synchronize files, Getting messages for completion tasks, getting alerts such as tablespace size details, blocking sessions, temp usage etc.

There are 5 entries in crontab.

For example:
1 2 3 4 5 /bin/ora-data.blogspot.com/scriptname.sh

Here:
1 : Minute (from 0 to 59)
2 : Hour (from 0 to 23)
3 : Date of the month ( from 1 to 31)
4 : Month ( from 1 to 12)
5 : Day of week (from 0 to 7, here 0 and 7 are Sunday)

If we want to check which crontabs are currently running on our server? We have to login to our server and run the below command:

$hostname;id
ora-data.blogspot;ora-data

$crontab -l
1 2 3 4 5 /bin/ora-data.blogspot.com/scriptname.sh

If you want to make changes or edit in crontab, follow below command:

$crontab -e
1 2 3 4 5 /bin/ora-data.blogspot.com/scriptname.sh

From above command, we will get all the crontab entries in which we have to find out the script name and edit or change the date and time as per your requirements, Save and then exit.

Note: Always be careful during edit the crontab on PROD.

Please find the below examples for references:

1. Suppose we want to execute any scripts every minute then we can use below commands:

* * * * * /bin/ora-data.blogspot.com/scriptname.sh

Here, * asterisk or start means every. So, this above command will run for every minute, every hour, and every date of month, every month and every day of week.

2. Example for execute on Friday at 7 AM, each date and every month.

0 7 * * 5 /bin/ora-data.blogspot.com/ora-data.sh

3. Suppose, we want to execute our scripts only on Friday and Saturday at 5 AM.

0 5 * * 5-6 /bin/ora-data.blogspot.com/ora-data.sh

4. Suppose, we want to execute at every 10 min.

0,10,20,30,40,50 * * * * /bin/ora-data.blogspot.com/ora-data.sh

5. Suppose, we want to check a particular running crontab.

$crontab -l |grep crontabname

Some more useful links:

Hope this will be useful and helpful. For any suggestion please write to us either in comment box or @Contact us: https://ora-data.blogspot.in/

Regards,
ora-data Team

Sunday, 11 December 2016

CMCLEAN.sql




Hi Friends,

When we do cloning, almost time we use cmclean.sql at the end. And for this we need a query which today I would like to share with you all.
We use cmclean.sql to cleanup the running and pending requests , If we stop concurrent managers using abort options then concurrent requests will be in running state Then when next time we will start the concurrent manager the processes will not start properly, which may cause some errors.

Specially, CMCLEAN.sql will update the following below tables:
1) FND_CONCURRENT_QUEUES
2) FND_CONCURRENT_PROCESSES
3) FND_CONCURRENT_REQUESTS
4) FND_CONFLICTS_DOMAIN
5) FND_CONCURRENT_CONFLICT_SETS


Please find the below steps to run the cmclean.sql.

Steps:
1. Copy this below script in the Wordpad and save as cmclean.sql. There should now be any space any junk char.
2. Then ftp through winSCP to the server.
3. Goto that location, where you have kept the cmclean.sql file.
5. Follow below as:
SQL>@cmclean.sql;

SQL SCRIPTS:
============

REM
REM FILENAME
REM cmclean_query.sql
REM DESCRIPTION
REM Selects data on the concurrent manager tables the cmclean script updated.
REM
REM NOTES
REM Usage: sqlplus @cmclean_query.sql
REM
REM
REM $Id: cmclean_query.sql,v 1.0 2014/04/01 15:00:00 bkerr Exp $
REM
REM
REM +======================================================================+

spool cmclean_query.txt
set verify off;
set head off;
set timing off
set pagesize 1000

column manager format a20 heading 'Manager short name'
column pid heading 'Process id'
column pscode format a12 heading 'Status code'
column ccode format a12 heading 'Control code'
column request heading 'Request ID'
column pcode format a6 heading 'Phase'
column scode format a6 heading 'Status'


set feed on


REM Select process status codes that are TERMINATED

prompt
prompt ------------------------------------------------------------------------

prompt -- Select invalid process status codes in FND_CONCURRENT_PROCESSES
set feedback off
set head on
break on manager

SELECT concurrent_queue_name manager,
concurrent_process_id pid,
process_status_code pscode
FROM fnd_concurrent_queues fcq, fnd_concurrent_processes fcp
WHERE process_status_code not in ('K', 'S')
AND fcq.concurrent_queue_id = fcp.concurrent_queue_id
AND fcq.application_id = fcp.queue_application_id;


REM List invalid control codes

prompt
prompt ------------------------------------------------------------------------

prompt -- Listing invalid control_codes in FND_CONCURRENT_QUEUES
set feedback off
set head on
SELECT concurrent_queue_name manager,
control_code ccode
FROM fnd_concurrent_queues
WHERE control_code not in ('E', 'R', 'X')
AND control_code IS NOT NULL;


REM List Target Node for All Managers

prompt
prompt ------------------------------------------------------------------------


REM Identify the target_node for all managers
prompt -- Identify the target_node for all managers
set feedback off
set head on
select target_node from fnd_concurrent_queues;


REM List Running or Terminating requests

prompt
prompt ------------------------------------------------------------------------

prompt -- Select Running or Terminating requests
set feedback off
set head on
SELECT request_id request,
phase_code pcode,
status_code scode
FROM fnd_concurrent_requests
WHERE status_code = 'T' OR phase_code = 'R'
ORDER BY request_id;


prompt
prompt ------------------------------------------------------------------------

prompt Review complete.
prompt ------------------------------------------------------------------------

prompt
spool off
set feedback on


If you are facing any type of problem, kindly contact us @https://ora-data.blogspot.in/ or write to us, we will send you file through email.


Some more useful links:







 

Thanks,

Friday, 2 December 2016

Interviews Questions And Answers for Oracle Apps


Hi DBA-Mates,
As per experiences some real time questions and answers are found, which may useful to all specially for Oracle Apps DBA.
Below are some important and useful Oracle Application Questions and Answers:
Q) How to check if your system is SSL enabled?  
Answer: 
For quick check: If your context file contains the values of
s_url_protocol / s_local_url_protocol set to https, then
your environments has to be SSL-enabled. If the rest of config is
absent but these are set to https, then URL does not resolve
- which is an indirect check of incomplete config. 
And also you can use this query to check 
SELECT PROFILE_OPTION_VALUE 
FROM applsys.fnd_profile_option_values 
WHERE PROFILE_OPTION_VALUE like 'http%';
Q) Query to find who and when update an Oracle Application user's 
profile?

Answer:

SELECT t.user_profile_option_name, profile_option_value,v.creation_date,
v.last_update_date, v.creation_date - v.last_update_date "Change Date", 
(SELECT UNIQUE user_name 
FROM fnd_user 
WHERE user_id = v.created_by) "Created By", 
(SELECT user_name 
FROM fnd_user 
WHERE user_id = v.last_updated_by) "Last Update By" 
FROM fnd_profile_options o, 
fnd_profile_option_values v,
fnd_profile_options_tl t
WHERE o.profile_option_id = v.profile_option_id
AND o.application_id = v.application_id
AND start_date_active <= SYSDATE
AND NVL (end_date_active, SYSDATE) >= SYSDATE
AND o.profile_option_name = t.profile_option_name
AND level_id = 10001
AND t.LANGUAGE IN (SELECT language_code
FROM fnd_languages
WHERE installed_flag = 'B'
UNION
SELECT nls_language
FROM fnd_languages
WHERE installed_flag = 'B')
ORDER BY user_profile_option_name;

Q)How to check product installation Information Version of Apps ?
Answer:

Select * from fnd_product_groups; 
Q) Query for Information about concurrent requests?
Answer:

Select * from fnd_concurrent_requests; 
Q)How to check Information about particular concurrent request ?
Answer:

Select logfile_name, logfile_node_name, outfile_name, outfile_node_name 
from fnd_concurrent_requests where request_id =<request id> ;
Q) How to fetch Stores values for various profile options?
Answer:

Select * from FND_PROFILE_OPTION_VALUES; 
Q) How to get Information about various profile options?
Answer:

Select * from FND_PROFILE_OPTIONS; 
Q) How to Find database version?
Answer:

Select * from v$version; 

Q) How to find Oracle Workflow Cartridge Release Version? 
Answer:

Select wf_core.translate ('WF_VERSION') from dual; 

Q)How to Find out Invalid number of Objects  ?
Answer:

Select count (*) from dba_objects where status ='INVALID' ;

Q) How to Check which node is running what service? 
Answer:

Select * from fnd_nodes; 

Q) How to find out Package Header?
Answer:

Select name, text from dba_source where text like ‘%Header: %’ and owner = ‘APPS’
and name =‘INVALID_OBJECT_NAME’;

Q)How to get Information about the bugs fixed in Installation ?
Answer:

Select * from ad_bugs; 

Q) How to backup the definition of a View before dropping a view?
Answer:

Select dbms_metadata.get_ddl (’VIEW’,'RG_View’,'APPS’) from dual; 

Q) Fetching Information about the applied patches ?
Answer:

Select * from ad_applied_patches;

Q)How to check if the partitions of a table are set to LOGGING?
Answer:
Select partition_name, logging
from dba_tab_partitions where table_name=’WF_LOCAL_ROLES’;

Q)How to find out version of a package?
Answer:
select text from dba_source where line=2 and name=’AP_IMPORT_INVOICES_PKG’;

Q)How to check whether the product is install, shared and Not installed in Apps?
Answer:
select t.application_name
, t.application_id
, i.patch_level
, decode(i.status,’I',’Fully Installed’,
‘N’,'Not Installed’,'S’,'Shared’,'Undetermined’) status
from fnd_product_installations i
, fnd_application_vl t
where i.application_id = t.application_id
order by t.application_id;

Q)How to check which object is corrupted?

Answer:
SELECT tablespace_name, segment_type, owner, segment_name
FROM dba_extents WHERE file_id = 64 and 1 between block_id AND block_id + blocks-1;

Q)Which users logged in to the system longer than 6 months ago ?Answer:
select a.user_id,a.user_name,b.user_id,b.start_time
from FND_USER a, FND_LOGINS b
where a.user_id = b.user_id
and b.start_time = (select max(start_time) from FND_LOGINS where user_id = b.user_id)
and START_TIME < SYSDATE - 180;

Q)To see how many distinct users are connected to my system, at particular time ?

Answer:
select distinct fu.user_name User_Name,fr.RESPONSIBILITY_KEY
Responsibility,fu.LAST_LOGON_DATE from fnd_user fu,
fnd_responsibility fr, icx_sessions ic;

Q) If a database is running in NOARCHIVELOG mode which type of backups you can take?

Answer: In no archive log mode, you have to take cold backup only, it means your database should be down and then take backup.
For this, you can right shell script in order:
(a) shutdown the database
(b) copy all the files
(c) startup the database.

Q) How to see DB size at OS level command?

Answer: By Issuing the following command in Unix: 
$ ipcs -pmb
ipcs: invalid option -- b
usage : ipcs -asmq -tclup
ipcs [-s -m -q] -i id
ipcs -h for help.

Q) What are the Different Shutdown options in database?

Answer: 
1) shut (for normal shutdown) -à It will wait until all the users to logout from database.
2) Shut immediate-
à It will roll forwards the committed data and rollback the uncommitted data.
3) shut transactional -
à It will wait until all the transactions to be complete by a commit or
rollback.
4) Shut abort-
à It will not check for users, transations etc... Just it will abort from database by shutting down the instance.
Some more useful links:


For any query or suggestions please write to our comment box or contact us @ora-data.blogspot.com.

Regards,
ora-data Team