oracle 12c move all database files to new mount point

existing mount point usage is near %100, so we need to extend mont point.
but because of technical reasons we cannot extend mount point, so er have to move all oracle files in old mount point to new created mount point.
then we will drop old mount point.

step: change db_create_file_dest
alter system set db_create_file_dest='/new_dest' scope=both; 
step:  move all datafiles online,
OMF is enabled so I do not give the new destination.
with "keep" option old files remain at old location.

alter database move datafile   2 keep;
alter database move datafile   3 keep;
alter database move datafile   4 keep;
alter database move datafile   5 keep;
alter database move datafile   7 keep;
alter database move datafile   8 keep;
alter database move datafile   9 keep;
alter database move datafile  10 keep;
alter database move datafile  11 keep;
alter database move datafile  12 keep;
alter database move datafile  13 keep;
alter database move datafile  14 keep;
alter database move datafile  15 keep;
alter database move datafile  16 keep;
alter database move datafile  17 keep;
alter database move datafile  18 keep;
alter database move datafile  19 keep;
alter database move datafile  20 keep;
alter database move datafile  21 keep;
alter database move datafile  22 keep;
alter database move datafile  23 keep;
step: remove old temp tablespace and create new tablespace.
create new temp tablespace. new tablespace will be created in new location because of new "db_create_file_dest".  If you do not use OMF please sepicify new location imlicitly.
change default temp tablespace as newly created.
find and kill sessions that using old temp tablespace.
drop old temp tablespace.

create temporary tablespace temp2;

alter database default  temporary tablespace TEMP2;


SELECT 'alter system kill session '''||sid||','||serial#||''' immediate;'
FROM v$session a,v$sort_usage b
WHERE a.saddr = b.session_addr;


DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;
step: move controlfiles in old destination to new destination
change control_files location as new parameter in spfile. If you have more than one copy of control files like me you can only change required files. retype controlfile copy as same that do not require any change.
And then shutdown the db. move controlfile from old location to new location with linux move command. 
startup database then check "control_files" parameter.


select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/old_dest/MYDB/controlfile/o1_mf_ggf7lh18_.ctl
/u02/MYDB/controlfile/o1_mf_ggf7lh4j_.ctl


alter system set control_files='/new_dest/MYDB/controlfile/o1_mf_ggf7lh18_.ctl', '/u02/MYDB/controlfile/o1_mf_ggf7lh4j_.ctl' scope=spfile;

shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down


linux shell# mv /old_dest/MYDB/controlfile/o1_mf_ggf7lh18_.ctl /new_dest/MYDB/controlfile/o1_mf_ggf7lh18_.ctl

select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
/new_dest/MYDB/controlfile/o1_mf_ggf7lh18_.ctl
/u02/MYDB/controlfile/o1_mf_ggf7lh4j_.ctl
step: relocate redolog members
shutdown database and move redolog file/member to new location.
start database in mount mode and run "alter database rename file" command
open database.


select group#, member from v$logfile
    GROUP# MEMBER
---------- ------------------------------------------------------------------------------------------
         3 /old_dest/MYDB/onlinelog/o1_mf_3_ggf7lklb_.log
         3 /u02/MYDB/onlinelog/o1_mf_3_ggf7lrmb_.log
         2 /old_dest/MYDB/onlinelog/o1_mf_2_ggf7lkkr_.log
         2 /u02/MYDB/onlinelog/o1_mf_2_ggf7lpys_.log
         1 /old_dest/MYDB/onlinelog/o1_mf_1_ggf7lkk6_.log
         1 /u02/MYDB/onlinelog/o1_mf_1_ggf7lm5h_.log

6 rows selected.

shu immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

mv /old_dest/MYDB/onlinelog/o1_mf_3_ggf7lklb_.log /new_dest/MYDB/onlinelog/o1_mf_3_ggf7lklb_.log
mv /old_dest/MYDB/onlinelog/o1_mf_2_ggf7lkkr_.log /new_dest/MYDB/onlinelog/o1_mf_2_ggf7lkkr_.log
mv /old_dest/MYDB/onlinelog/o1_mf_1_ggf7lkk6_.log /new_dest/MYDB/onlinelog/o1_mf_1_ggf7lkk6_.log


startup mount;
ORACLE instance started.

Total System Global Area 4966055936 bytes
Fixed Size                  8630856 bytes
Variable Size            1040190904 bytes
Database Buffers         3909091328 bytes
Redo Buffers                8142848 bytes
Database mounted.

Leave a comment