The Below Link Contain Document Describe Step by Step how to Duplicate Database Using RMAN ,
Cloning Database / Duplicate Database Using RMAN
Enjoy
Thank you
Osama mustafa
For the people who think differently Welcome aboard
The Below Link Contain Document Describe Step by Step how to Duplicate Database Using RMAN ,
Cloning Database / Duplicate Database Using RMAN
Enjoy
Thank you
Osama mustafa
In order to set password on listener, follow the steps:
1) LSNRCTL> set current_listener
2) LSNRCTL> change_password
Old password:
New password: yourpassword
Reenter new password: yourpassword
3) LSNRCTL> save_config
4) LSNRCTL> status
Now Any One Want Start Administrating Listener Will be Asked for Password , After This you can manager Your Listener .
As the another user, enter the password to administer the listener:
1) LSNRCTL> set password
Password: yourpassword
2) LSNRCTL> stop
Thank you
Osama mustafa
Lets Get The Database Data Files :
1-See your Database Files :
SQL>select file_name from dba_data_files;
+DATA/test/datafile/undotbs1.301.697649965
+DATA/test/datafile/sysaux.300.697649963
+DATA/test/datafile/system.299.697649963
+DATA/test/datafile/users.302.697649965
+DATA/test/datafile/users.309.697650601
select tablespace_name,count(file_name) from dba_data_files group by tablespace_name ORDER BY 2
Use the above query to see how many data files under tablespace .
Now After see the DataFile , we need to create new Directory to copy the data file to it .
mkdir /app/oracle/TEST
sqlplus / as sysdba
set lines 120 pages 0
select ‘copy datafile ‘||file_id||’ to ‘||”’/app/oracle/TEST/’||substr(file_name,21,instr(file_name,’.’)-21)||’_01.dbf”’||’;’ from dba_data_files order by 1;
copy datafile 1 to ‘/app/oracle/TEST/system_01.dbf’;
copy datafile 2 to ‘/app/oracle/TEST/sysaux_01.dbf’;
copy datafile 3 to ‘/app/oracle/TEST/undotbs1_01.dbf’;
copy datafile 4 to ‘/app/oracle/TEST/users_01.dbf’;
copy datafile 5 to ‘/app/oracle/TEST/users_02.dbf’;
shutdown immediate;
startup mount;
exit
rman target /
copy datafile 1 to ‘/app/oracle/TEST/system_01.dbf’;
copy datafile 2 to ‘/app/oracle/TEST/sysaux_01.dbf’;
copy datafile 3 to ‘/app/oracle/TEST/undotbs1_01.dbf’;
copy datafile 4 to ‘/app/oracle/TEST/users_01.dbf’;
copy datafile 5 to ‘/app/oracle/TEST/users_02.dbf’;
exit
sql / as sysdba
select ‘alter database rename file ”’||file_name||”’ to ‘||”’/app/oracle/TEST/’||substr(file_name,21,instr(file_name,’.’)-21)||’_01.dbf”’||’;’ from dba_data_files order by 1;
alter database rename file ‘+DATA/test/datafile/sysaux.300.697649963’ to ‘/app/oracle/TEST/sysaux_01.dbf’;
alter database rename file ‘+DATA/test/datafile/system.299.697649963’ to ‘/app/oracle/TEST/system_01.dbf’;alter database rename file ‘+DATA/test/datafile/undotbs1.301.697649965’ to ‘/app/oracle/TEST/undotbs1_01.dbf’;alter database rename file ‘+DATA/test/datafile/users.302.697649965’ to ‘/app/oracle/TEST/users_01.dbf’;alter database rename file ‘+DATA/test/datafile/users.309.697650601’ to ‘/app/oracle/TEST/users_02.dbf’;
open database
select name from v$controlfile
union
select name from v$tempfile
union
select member from v$logfile
union
select filename from v$block_change_tracking;NAME
——————————————————————————–
+DATA/test/controlfile/current.303.697650047
+DATA/test/onlinelog/group_1.304.697650049
+DATA/test/onlinelog/group_2.305.697650049
+DATA/test/onlinelog/group_3.306.697650049
+DATA/test/tempfile/temp.307.697650095
+FRA/test/controlfile/current.260.697650047
+FRA/test/onlinelog/group_1.261.697650049
+FRA/test/onlinelog/group_2.262.697650049
+FRA/test/onlinelog/group_3.263.697650051alter database rename file ‘+DATA/test/datafile/sysaux.300.697649963’ to ‘/app/oracle/TEST/sysaux_01.dbf’;
alter database rename file ‘+DATA/test/datafile/system.299.697649963’ to ‘/app/oracle/TEST/system_01.dbf’;
alter database rename file ‘+DATA/test/datafile/undotbs1.301.697649965’ to ‘/app/oracle/TEST/undotbs1_01.dbf’;
alter database rename file ‘+DATA/test/datafile/users.302.697649965’ to ‘/app/oracle/TEST/users_01.dbf’;
alter database rename file ‘+DATA/test/datafile/users.309.697650601’ to ‘/app/oracle/TEST/users_02.dbf’;
ALTER DATABASE ADD LOGFILE GROUP 4 (‘/app/oracle/TEST/redo_04a.dbf’,’/app/oracle/TEST/redo_04b.dbf’) size 50M;
ALTER DATABASE ADD LOGFILE GROUP 5 (‘/app/oracle/TEST/redo_05a.dbf’,’/app/oracle/TEST/redo_05b.dbf’) size 50M;
ALTER DATABASE ADD LOGFILE GROUP 6 (‘/app/oracle/TEST/redo_06a.dbf’,’/app/oracle/TEST/redo_06b.dbf’) size 50M;
4-the Last Step for Control file and Spfile :
SQL>show parameter controlcontrol_files————————–+DATA/test/controlfile/current .303.697650047SQL > Create Pfile=” from spfile ;
After Creating Pfile , Open it modify Control File Location to Our New Location /app/oracle/TEST/…
*.control_files=’/app/oracle/TEST/control01.ctl’,’/app/oracle/TEST/control02.ctl’startup nomount
$rman target /
restore controlfile from ‘+DATA/test/controlfile/current.303.697650047’;
exit
create spfile=’/app/oracle/product/11.1.0/db_1/dbs/spfileTEST.ora’ from pfile=’/home/oracle/john.ora’;
File created.
shutdown immediate;
startupshow parameter control
control_files /app/oracle/TEST/control01.ctl , /app/oracle/TEST/control02.ctl
This Steps Without Using RMAN , I will Post Another Steps Using RMAN
Thank you
Osama mustafa
The following query will reveal the profile:
SQL> select profile, resource_name, limit
from dba_profiles
where resource_type='PASSWORD' order by 1,2;
The default 10.2.0.1.0 profile for SYSMAN has the following parameters:
PROFILE………..RESOURCE_NAME……………. LIMIT
———————————————————————————–
DEFAULT………..FAILED_LOGIN_ATTEMPTS…….. 10
DEFAULT………..PASSWORD_GRACE_TIME………. UNLIMITED
DEFAULT………..PASSWORD_LIFE_TIME……….. UNLIMITED
DEFAULT………..PASSWORD_LOCK_TIME……….. UNLIMITED
DEFAULT………..PASSWORD_REUSE_MAX………. . UNLIMITED
DEFAULT………..PASSWORD_REUSE_TIME……… UNLIMITED
DEFAULT………..PASSWORD_VERIFY_FUNCTION…..NULL
DBSNMP uses the MONITORING_PROFILE, which is defined the same except for the FAILED_LOGIN_ATTEMPTS, which is set to UNLIMITED.
The failing instance, in one case, showed the following for the DEFAULT profile:
PROFILE………..RESOURCE_NAME……..LIMIT
—————————— ——————————————-
DEFAULT………..FAILED_LOGIN_ATTEMPTS……… 4
DEFAULT………..PASSWORD_GRACE_TIME……….. 1
DEFAULT………..PASSWORD_LIFE_TIME………… 60
DEFAULT………..PASSWORD_LOCK_TIME……….. . 0138
DEFAULT………..PASSWORD_REUSE_MAX………… 100
DEFAULT………..PASSWORD_REUSE_TIME……….. UNLIMITED
DEFAULT………..PASSWORD_VERIFY_FUNCTION…… NULL
1. In SQL*Plus, logon as SYS and change DBSNMP’s MONITORING_PROFILE, for example:
ALTER PROFILE MONITORING_PROFILE
LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED
PASSWORD_GRACE_TIME UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_VERIFY_FUNCTION NULL;
2. Then modify SYSMAN’s DEFAULT:
ALTER PROFILE DEFAULT
LIMIT FAILED_LOGIN_ATTEMPTS 10
PASSWORD_GRACE_TIME UNLIMITED
PASSWORD_LIFE_TIME UNLIMITED
PASSWORD_LOCK_TIME UNLIMITED
PASSWORD_REUSE_MAX UNLIMITED
PASSWORD_REUSE_TIME UNLIMITED
PASSWORD_VERIFY_FUNCTION NULL;
After this Drop with following Steps :
SQL> drop role mgmt_user;
SQL> drop user sysman cascade;
SQL> drop user MGMT_VIEW cascade;
SQL> drop public synonym mgmt_target_blackouts;
SQL> drop public synonym setemviewusercontext;
-Recreate EM
emca -dbcontrol db -repos create ;
Thank you
Osama mustafa
DBSNMP Not Found On dba_users
So Simple run the following scripts :
@?/rdbms/admin/catnsnmp.sql@?/rdbms/admin/catsnmp.sql
Thank you
Osama mustafa
There’s Two Kind Of OCR Backup :
$ORA_CRS_HOME/cdata
Or
ocrconfig -showbackup
Want to change The Default Location for automatic backup :
ocrconfig -backuploc
$ocrconfig -export /u04/crs_backup/ocrbackup/exports/OCRFile_expBackup.dmp
$ocrconfig -export /u04/crs_backup/ocrbackup/exports/OCRFile_expBackup.dmp
$ocrconfig -showbackup
$srvctl -stop database -d ORCL (Shutdown all RAC instances and RAC database)
$crsctl stop crs (Shutdown Cluster)
#ocrconfig -restore /u02/apps/crs/cdata/crs/backup00.ocr
$crsctl start crs (After issuing start cluster check status of cluster using ‘crs_stat -t’)
$srvctl start database -d ORCL (Start Oracle RAC database and RAC instances)
$srvctl -stop database -d ORCL (Shutdown all RAC instances and RAC database)
$crsctl stop crs (Shutdown Cluster)SAME process should need to repeat for OCR mirror also.
ocrconfig -import /u04/crs_backup/ocrbackup/exports/OCRFile_exp_Backup.dmp (Import metadata of OCR using command)
$crsctl start crs (After issuing start cluster check status of cluster using ‘crs_stat -t’)
$srvctl start database -d ORCL (Start Oracle RAC database and RAC instances)
Thank you
Osama mustafa
select * from all_directories where directory_name = ‘DIRECTORY_NAME‘;select * from user_tab_privs
where table_name = ‘DIRECTORY_NAME‘;select * from user_sys_privs
where privilege = 'CREATE ANY DIRECTORY';
1) Create data-pump directory
CONN / AS SYSDBACREATE OR REPLACE DIRECTORY test_dir AS '';
2.) Grant permission now to this directory
GRANT READ, WRITE ON DIRECTORY test_dir TO ;
3.)Copy the desired dump-file at directory Location :
4.)Start import now .
Good Luck
Thank you
Osama mustafa
SQL>alter database backup controlfile to trace;
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE “OLDLSQ” NORESETLOGS
NOARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 2
MAXDATAFILES 240
MAXINSTANCES 1
MAXLOGHISTORY 113
LOGFILE
GROUP 1 (‘/u01/oradata/oldlsq/log1a.dbf’,
‘/u01/oradata/olslsq/log1b.dbf’) SIZE 30M,
GROUP 2 (‘/u01/oradata/oldlsq/log2a.dbf’,
‘/u01/oradata/oldlsq/log2b.dbf’) SIZE 30M
DATAFILE
‘/u01/oradata/oldlsq/system01.dbf’,
‘/u01/oradata/oldlsq/mydatabase.dbf’
;
# Recovery is required if any of the datafiles are restored
# backups, or if the last shutdown was not normal or immediate.
RECOVER DATABASE
# Database can now be opened normally.
ALTER DATABASE OPEN;
SQL>Shutdown immediate ;
Step-3 : Copy and Edit the Control file – Using the output syntax from STEP 1, modify the controlfile creation script by changing the following:
CREATE CONTROLFILE REUSE DATABASE “OLDLSQ” NORESETLOGSCREATE CONTROLFILE SET DATABASE “NEWLSQ” RESETLOGS
Step-4 :Remove the “recover database” and “alter database open” syntax
Step-5:Re-names of the data files location to new clone location in a dbclone_controlfile_creation.sql.
Old:
DATAFILE
‘/u01/oradata/oldlsq/system01.dbf’,
‘/u01/oradata/oldlsq/mydatabase.dbf’New:
DATAFILE
‘/u01/oradata/newlsq/system01.dbf’,
‘/u01/oradata/newlsq/mydatabase.dbf’
Step-6: Copy all data files into the new directories on the new server. You may change the file names if you want, but you must edit the controlfile to reflect the new data files names on the new server.
Step-7 : Create the bdump, udump and cdump directories
cd /u01/admin/
mkdir newlsq
cd newlsq
mkdir bdump
mkdir udump
mkdir cdump
mkdir pfile
Step-8 : Copy-over the old init.ora file
open the primary database pfile in a notepad or text editor and change the udump,bdump,pfile,controlfile destination and save it in new clone pfile location newlsq folder and save as newlsq.ora
eg: primary database location /u01/admin/oldlsq/pfile/oldlsq.ora
open that oldlsq.ora file in a text editor or notepad and change the required destinations cdump,udump,bdump,controlfile destinations and save as newlsq.ora in the below destination
/u01/admin/newlsq/pfile/newlsq.ora
Step-9 : Start the new database
SQL>startup nomount pfile=’ /u01/admin/newlsq/pfile/newlsq.ora ‘ ;SQL> @dbclone_controlfile_creation.sqlSQL>alter database open resetlogs;SQL>create spfile from pfile;
Step-10 : Place the new database in archivelog mode.
Thank you
osama mustafa
Check the below Steps to delete duplicate row :
SQL>select * from emp;
EMPID ENAME SAL DEPTNO
---------- -------------------- ---------- ----------
10005 palani 54544 10
10001 Scott Tiger 1000 40
10002 Frank Naude 500 20
10003 rajesh 21000 140
10004 ramesh 3500 220
10005 suresh 34567 123
delete duplicate rows in empid column in emp table
SQL>delete from emp where rowid not in (select max(rowid) from emp group by empid);
1 row deleted.
SQL>select * from emp;
EMPID ENAME SAL DEPTNO
---------- -------------------- ---------- ----------
10001 Scott Tiger 1000 40
10002 Frank Naude 500 20
10003 rajesh 21000 140
10004 ramesh 3500 220
10005 suresh 34567 123
to delete the old duplicate row from the table instead of max(rowid) replace min(rowid)
for exampl
SQL>insert into emp values(10005,’Osama’,54544,10);
1 row created.
SQL>select * from emp;
EMPID ENAME SAL DEPTNO
---------- -------------------- ---------- ----------
10005 Osama 54544 10
10001 Scott Tiger 1000 40
10002 Frank Naude 500 20
10003 rajesh 21000 140
10004 ramesh 3500 220
10005 suresh 34567 123
6 rows selected.
SQL>delete from emp where rowid not in (select min(rowid) from emp group by empid);
1 row deleted.
SQL>select * from emp;
EMPID ENAME SAL DEPTNO
---------- -------------------- ---------- ----------
10005 Osama 54544 10
10001 Scott Tiger 1000 40
10002 Frank Naude 500 20
10003 rajesh 21000 140
10004 ramesh 3500 220
thank you
Osama mustafa