Author Archives: postgresdba
Check For Postgresql Replication Delay/Lag -Part2
Check For Postgresql Replication Delay/Lag
Check Replication Delay/Lag In Postgressql -Part1
Monitoring Approach For Streaming Replication With Hot Standby In Postgresql 9.3
Replication Synchronous_Commit Options Available In Postgrsql
Clearing Redo logfiles in Oracle
The following statement clears the log files in redo log group number 3:
ALTER DATABASE CLEAR LOGFILE GROUP 3;
This statement overcomes two situations where dropping redo logs is not possible:
If there are only two log groups
The corrupt redo log file belongs to the current group
If the corrupt redo log file has not been archived, use the UNARCHIVED keyword in the statement.
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;
This statement clears the corrupted redo logs and avoids archiving them. The cleared redo logs are available for use even though they were not archived.
If you clear a log file that is needed for recovery of a backup, then you can no longer recover from that backup. The database writes a messa
Renaming or Relocating Logfiles in oracle
1. Shutdown the database
SQL>shutdown immediate;
2. Move the logfile from Old location to new location using operating system command
$mv /u01/oracle/ica/log1.ora /u02/oracle/ica/log1.ora
3. Start and mount the database
SQL>startup mount
4. Now give the following command to change the location in controlfile
SQL>alter database rename file ‘/u01/oracle/ica/log1.ora’ to ‘/u02/oracle/ica/log2.ora’;
5. Open the database
SQL>alter database open;
Redo logfile Modification/Management in Oracle(add,delete,drop and resize redo logfile)
SQL>alter database add logfile group 3 ‘/u01/oracle/ica/log3.ora’ size 10M;
Adding Members to an existing group
SQL>alter database add logfile member ‘/u01/oracle/ica/log11.ora’ to group 1;
Dropping Members from a group
You can drop member from a log group only if the group is having more than one member and if it is not the current group. If you want to drop members from the current group, force a log switch or wait so that log switch occurs and another group becomes current. To force a log switch give the following command
SQL>alter system switch logfile;
the following command can be used to drop a logfile member
SQL>alter database drop logfile member ‘/u01/oracle/ica/log11.ora’;
Dropping Logfile Group
Similarly, you can also drop logfile group only if the database is having more than two groups and if it is not the current group.
SQL>alter database drop logfile group 3;
Resizing Logfiles
You cannot resize logfiles. If you want to resize a logfile create a new logfile group with the new size and subsequently drop the old logfile group.
moving and renaming datafiles –oracle
SQL> select tablespace_name, substr(file_name,1,70) from dba_data_files;
TABLESPACE_NAME SUBSTR(FILE_NAME,1,70)
—————————— ———————————————————————-
SYSTEM /home/oracle/OraHome1/databases/ora9/system.dbf
UNDO /home/oracle/OraHome1/databases/ora9/undo.dbf
DATA /home/oracle/OraHome1/databases/ora9/data.dbf
SQL> select member from v$logfile;
MEMBER
——————————————————————————–
/home/oracle/OraHome1/databases/ora9/redo1.ora
/home/oracle/OraHome1/databases/ora9/redo2.ora
/home/oracle/OraHome1/databases/ora9/redo3.ora
SQL> select name from v$controlfile;
NAME
——————————————————————————–
/home/oracle/OraHome1/databases/ora9/ctl_1.ora
/home/oracle/OraHome1/databases/ora9/ctl_2.ora
/home/oracle/OraHome1/databases/ora9/ctl_3.ora
Now, as the files to be moved are known, the database can be shut down:
SQL> shutdown
The files can be copied to their destination:
$ cp /home/oracle/OraHome1/databases/ora9/system.dbf /home/oracle/databases/ora9/system.dbf
$ cp /home/oracle/OraHome1/databases/ora9/undo.dbf /home/oracle/databases/ora9/undo.dbf
$ cp /home/oracle/OraHome1/databases/ora9/data.dbf /home/oracle/databases/ora9/data.dbf
$
$ cp /home/oracle/OraHome1/databases/ora9/redo1.ora /home/oracle/databases/ora9/redo1.ora
$ cp /home/oracle/OraHome1/databases/ora9/redo2.ora /home/oracle/databases/ora9/redo2.ora
$ cp /home/oracle/OraHome1/databases/ora9/redo3.ora /home/oracle/databases/ora9/redo3.ora
$
$ cp /home/oracle/OraHome1/databases/ora9/ctl_1.ora /home/oracle/databases/ora9/ctl_1.ora
$ cp /home/oracle/OraHome1/databases/ora9/ctl_2.ora /home/oracle/databases/ora9/ctl_2.ora
$ cp /home/oracle/OraHome1/databases/ora9/ctl_3.ora /home/oracle/databases/ora9/ctl_3.ora
The init.ora file is also copied because it references the control files. I name the copied file just init.ora because it is not in a standard place anymore and it will have to be named explicitely anyway when the database is started up.
$ cp /home/oracle/OraHome1/dbs/initORA9.ora /home/oracle/databases/ora9/init.ora
The new location for the control files must be written into the (copied) init.ora file:
/home/oracle/databases/ora9/init.ora
control_files = (/home/oracle/databases/ora9/ctl_1.ora,
/home/oracle/databases/ora9/ctl_2.ora,
/home/oracle/databases/ora9/ctl_3.ora)
$ sqlplus “/ as sysdba”
SQL> startup exclusive mount pfile=/home/oracle/databases/ora9/init.ora
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/system.dbf’ to ‘/home/oracle/databases/ora9/system.dbf’;
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/undo.dbf’ to ‘/home/oracle/databases/ora9/undo.dbf’;
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/data.dbf’ to ‘/home/oracle/databases/ora9/data.dbf’;
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/redo1.ora’ to ‘/home/oracle/databases/ora9/redo1.ora’;
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/redo2.ora’ to ‘/home/oracle/databases/ora9/redo2.ora’;
SQL> alter database rename file ‘/home/oracle/OraHome1/databases/ora9/redo3.ora’ to ‘/home/oracle/databases/ora9/redo3.ora’;
SQL> shutdown
SQL> startup pfile=/home/oracle/databases/ora9/init.ora
