Oracle database migration from Windows to Linux

I just wanted to make a post for this:

I had a task to migrate an oracle database (11.2.0.1) from Windows to Linux. On linux I have 11.2.0.3 software version.

First I did some checks:

First I checked the endian:

On Windows I get this:

SQL> SELECT A.platform_id, A.platform_name, B.endian_format
  2   FROM   v$database A, v$transportable_platform B
  3  WHERE  B.platform_id (+) = A.platform_id;


PLATFORM_ID PLATFORM_NAME                  ENDIAN_FORMAT
----------- ------------------------------ --------------
         12 Microsoft Windows x86 64-bit   Little

SQL>

And on Linux I get this:

SQL > SELECT A.platform_id, A.platform_name, B.endian_format
 FROM   v$database A, v$transportable_platform B
WHERE  B.platform_id (+) = A.platform_id;  2    3  

 PLATFORM_ID PLATFORM_NAME                  ENDIAN_FORMAT
------------ ------------------------------ --------------
          13 Linux x86 64-bit               Little

Elapsed: 00:00:00.01
SQL > 

As you can see, I’m lucky today as on both platforms the endian is the same (“Little”) which means no conversion needed. What I’m going to do is just a full export and import using data pump.

On Windows:

expdp  \'/ as sysdba\' full=Y directory=DATA_PUMP_DIR dumpfile=DB_full_exp.dmp logfile=DB_full_exp.log

I’m going to copy the export file over to Linux box.

On Linux:

First I’m going to create an empty database and then I’m going to run the import:

impdp   \'/ as sysdba\' directory=DATA_PUMP_DIR dumpfile=DB_FULL_EXP.DMP exclude=statistics 

I’m getting a lot of ORA-39111 which means that the object exists. This is about the objects which are created already within default schemas like SYS,SYSTEM…. I just ignored them and in the end I compiled everything and all looks good.

sqlplus / as sysdba
@$ORACLE_HOME/rdbms/admin/utlrp.sql
Advertisements

Shutdown hangs due to E000 processes

I had this several times and these are the possible solutions:

Shutdown hangs while EMON slaves are spawned for notification (Doc ID 1394945.1)

In short, you either apply the patch described on the document or just kill the e000 process. In my case is this:

oracle   10371     1  0 Jan28 ?        00:00:03 ora_e000_TESTDB

 

Virtualbox automation scripts

As I’m trying to speed up things while I’m creating my ORACLE environments I started to build up some scripts to help me on doing it faster.
1. Adapt the network and the hosts file
Note: I’m running this script from my local server and not from VM, like this:

# root>ssh root@192.168.1.130 < $script_location/adapt_network.sh
================================== START =========================================
#!/bin/bash

################################################
# Adapting the /etc/sysconfig/network-scripts 

################################################

# Regenerate the IP rules
#mv /etc/udev/rules.d/70-persistent-net.rules ~/70-persistent-net.rules.bck
#/sbin/udevadm trigger --type=devices --action=add

### adapt the IPADDR 
cd /etc/sysconfig/network-scripts
grep -q '^IPADDR' ifcfg-eth1 && sed -i 's/^IPADDR.*/'IPADDR=192.168.100.10'/' ifcfg-eth1 || echo 'IPADDR=192.168.100.10' >> ifcfg-eth1
grep -q '^IPADDR' ifcfg-eth2 && sed -i 's/^IPADDR.*/'IPADDR=192.168.101.11'/' ifcfg-eth2 || echo 'IPADDR=192.168.101.10' >> ifcfg-eth2

### adapt the Name
grep -q '^NAME' ifcfg-eth1 && sed -i 's/^NAME.*/NAME="eth1"/' ifcfg-eth1 || echo 'NAME="eth1"' >> ifcfg-eth1
grep -q '^NAME' ifcfg-eth2 && sed -i 's/^NAME.*/NAME="eth2"/' ifcfg-eth2 || echo 'NAME="eth2"' >> ifcfg-eth2

### adapt the BOOTPROTO and remove the UUID
for f in ifcfg-eth{1..2}; do
grep -q '^BOOTPROTO' $f && sed -i 's/^BOOTPROTO.*/BOOTPROTO=none/' $f || echo 'BOOTPROTO=none' >> $f
sed -i '/UUID/d' $f
done

==================================== END =========================================

Note: I’m still searching for a way to use variables instead the “fixed” IP addresses; didn’t find a way yet.
Looking forwards for your comments.

How to change the network device name from eth5 to eth0

As I’m using a lot Virtualbox, I have often encountered the situation where I had to adapt the network adapters to follow some naming standards (to match my scripts 🙂 of course).

I’ve created some time ago a BASE VM where I deployed all the packages that I would possibly need for any ORACLE installation. On this BASE VM I have created 3 network adapters (1 bridged one and 2 host-only ones). Each time I need to create a VM, I’m just cloning the BASE VM – it saves A LOT of time. However, I still need to apply some changes, such as the hostname and network adapters.

So, here is what I did:

After the new VM is up&running, grab the MAC addresses first:

[root@base rules.d]# ifconfig | grep HWadd
eth3      Link encap:Ethernet  HWaddr 08:00:27:50:9C:9D
eth4      Link encap:Ethernet  HWaddr 08:00:27:B6:B4:99
eth5      Link encap:Ethernet  HWaddr 08:00:27:B1:8F:0A
[root@base rules.d]#

Go to /etc/udev/rules.d/ and edit 70-persistent-net.rules

This is what I have:

[root@base rules.d]# cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:22:74:f9", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:b2:5c", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:89:47:fd", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:50:9c:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b6:b4:99", ATTR{type}=="1", KERNEL=="eth*", NAME="eth4"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:8f:0a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth5"
[root@base rules.d]#

As you can see, the new names are eth3 – eth4 – eth5. I’m going to delete the previous ones and rename the new ones as eth0 – eth1 – eth2. My file is going to look like this:

[root@base rules.d]# cat 70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:50:9c:9d", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b6:b4:99", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x8086:0x100e (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:b1:8f:0a", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"
[root@base rules.d]#

The second step is to go here “/etc/sysconfig/network-scripts” and adapt the ifcfg-eth* files accordingly.

[root@base network-scripts]# ll ifcfg-eth*
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth0
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth1
-rw-r--r--. 1 root root 231 Jun 18  2014 ifcfg-eth2
[root@base network-scripts]#

Delete in each file the UUID line, replace the MAC address with the one u get with “ifconfig | grep HW” and adapt the Name with a proper one.

The last step is to REBOOT the server and check the network adapters.