Oracle 11g Migration to a New Server
Migration Plan Old Oracle server, A: 192.168.221.23 (RHEL 6 x86_64) New Oracle server, B: 192.168.221.66 (RHEL 7 x86_64 with better hardware, disk subsystem and processor) Database…

Migration Plan
- Old Oracle server, A: 192.168.221.23 (RHEL 6 x86_64)
- New Oracle server, B: 192.168.221.66 (RHEL 7 x86_64 with better hardware, disk subsystem and processor)
- Database name/Oracle SID: dbmas
The migration plan is basically to copy the database from A to the new server B and take over the old IP address from A. Using this method, we will reduce downtime on the application with zero changes on the application side (the only downtime is to unplug A and bring up the older IP address on B). It also provides the fastest rollback time in case if something goes wrong (just plug in A back to the switch and remove the old IP on B). The steps mentioned below does not include the Oracle 11g installation on B, where you can find a lot of resources online for that particular part.
Preparation (1 hour before migration)
A: Check crontab for user oracle and root. Identify all scripts that required to be transferred to B:
$ crontab -lB: Create new IP address interface but do not activate it:
$ vim /etc/sysconfig/network-scripts/ifcfg-eth0:1B: Create new entry of the new IP and comment it inside
/etc/hosts:$ vim /etc/hosts # make sure shortname first, long name laterA & B: Double check all DB paths to be identical on both servers.
A: Check
/home/oracle directory. Sync all the scripts.$ ls /home/oracle $ scp /home/oracle/* 192.168.221.66:/home/oracle/A: Check RMAN script job via Enterprise Manager, bring it to the new server’s Enterprise Manager.
A: Create archivelog backup:
$ rman target / rman> list archivelog all; rman> backup as compressed backupset tag 'archivelog-103-144' format '/orabak/oradata/dbmas/migration/Archive_%T_%U' archivelog from sequence 103 until sequence 144;A: SCP the archivelog backup to the new server, B:
$ scp /orabak/oradata/dbmas/migration/Archive* 192.168.221.66:/orabak/oradata/dbmas/migration/B: Catalog rman:
rman> catalog start with '/orabak/oradata/dbmas/';B: Recover database:
rman> run { allocate channel ch1 device type disk; recover database until sequence 144; release channel ch1; }Compare the archivelog sequence number between A & B:
rman> list archivelog all;
Actual migration (downtime 1 hour)
Declare the start of maintenance.
A: Stop listener:
$ export ORACLE_SID=dbmas $ lsnrctl stopA: Clean up all running sessions:
$ sqlplus / as sysdba SQL> shutdown immediate; SQL> startup;A: Create migration table for verification called
sys.aa_migration_final:SQL> create table sys.aa_migration_final (description varchar(20),xdate datetime default sysdate not null); SQL> insert into sys.aa_migration_final (description) values ('migration started'); SQL> select * from sys.aa_migration_final;A & B: Shutdown database:
$ export ORACLE_SID=dbmas $ sqlplus / as sysdba SQL> shutdown immediate;A: Copy 2 controlfiles and redo logs to the new server, B:
$ cd /ora02/oradata/dbmas $ scp control* redo* 192.168.221.66:/ora02/oradata/dbmas/ $ cd /orafra/oradata/dbmas $ scp control* 192.168.221.66:/orafra/oradata/dbmas/B: Mount database:
SQL> startup mount;B: Recover database:
SQL> recover database;B: Open database:
SQL> alter database open;B: Tune processes,
target_memoryon the new server:SQL> alter system set processes=500 scope=spfile; SQL> alter system set sessions=555 scope=spfile; SQL> alter system set transactions=610 scope=spfile; SQL> show parameter memory_target; SQL> alter system set memory_target = 80G; SQL> alter system set memory_max_target = 100G scope=spfile;B: Restart database to load the new changes:
SQL> shutdown immediate; SQL> startup;Unplug old server. This is when the actual downtime starts.
B: Set iptables:
iptables -I INPUT -p tcp -s 127.0.0.1 --dport 1521 -m comment --comment "Allow local to Oracle" -j ACCEPT iptables -I INPUT -p tcp -s 192.168.221.0/24 --dport 1521 -m comment --comment "Allow server's network to Oracle" -j ACCEPT iptables -I INPUT -p tcp -s 130.2.88.174 --dport 1521 -m comment --comment "Allow PC A to Oracle" -j ACCEPT iptables -I INPUT -p tcp -s 130.2.51.206 --dport 1521 -m comment --comment "Allow PC B to Oracle" -j ACCEPT iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 1521 -m comment --comment "Drop others to Oracle" -j DROPB: Bring up new IP address:
$ nmtui $ systemctl restart networkTry ping and telnet to 1521 from another server/PC just to make sure the old IP 192.168.221.23 is up on B:
$ ping 192.168.221.23 $ telnet 192.168.221.23 1521B: Uncomment/comment new IP address inside
/etc/hosts:$ vim /etc/hostsB: Reboot the server.
$ rebootB: Start listener:
$ lsnrctl stop $ lsnrctl start $ lsnrctl statusDeclare server B is up for testing.
B: Perform app testing
B: Try to access Enterprise Manager, otherwise, re-configure Enterprise Manager:
Create the EM database user:
alter user DBSNMP identified by ora08928hjpklmn account unlock; alter user SYS identified by ora08927nncvshgf account unlock;Delete the old EM path:
rm -rf <ORACLE_HOME>/dbmas rm -rf <ORACLE_HOME>/oc4j/j2ee/OC4J_DBConsole_oracledb1.myserver.com_dbmasInside SQLplus, run the following procedure:
exec sysman.emd_maintenance.remove_em_dbms_jobs; exec sysman.setEMUserContext('',5); revoke dba from sysman; commit; declare cursor c1 is select owner, synonym_name name from dba_synonyms where table_owner='SYSMAN' ; begin for r1 in c1 loop if r1.owner='PUBLIC' then execute immediate 'DROP PUBLIC SYNONYM '||r1.name; else execute immediate 'DROP SYNONYM '||r1.owner||'.'||r1.name; end if; end loop; end; / drop user mgmt_view cascade; drop role mgmt_user; drop user sysman cascade; commit; /Recreate repository and start the DB console:
$ emca -config dbcontrol db -repos create $ emctl status dbconsole $ emctl status agentTry accessing Enterprise Manager from the browser. Use the details generated after the above installation has completed.
Declare migration completion.
Post migration checks (est: 1 hour)
B: Configure RMAN back up settings:
RMAN> SHOW ALL; CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default CONFIGURE BACKUP OPTIMIZATION OFF; # default CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default CONFIGURE CONTROLFILE AUTOBACKUP ON; CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/orabak/oradata/dbmas/%F'; CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET PARALLELISM 1; CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default CONFIGURE CHANNEL DEVICE TYPE DISK FORMAT '/orabak/oradata/dbmas/%U'; CONFIGURE MAXSETSIZE TO UNLIMITED; # default CONFIGURE ENCRYPTION FOR DATABASE OFF; # default CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO 'SBT_TAPE'; CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/ora00/oracle/product/112/dbhome/dbs/snapcf_dbmas.f'; # defaultB: Crosscheck archivelog:
$ rman target / rman> crosscheck archivelog all; rman> delete expired archivelog all;B: Perform a new backup:
rman> backup database plus archivelog;B: Login to Enterprise Manager and check if everything is okay.
B: Perform UAT.
At this point, the migration is completed and application can start performing tests.
