Change redo logs from filesystem to RAW

There is one thing I particularly like, but it is possible that we find people who say that if the database performance is greatly improved with raw redo in front of a filesystem (ext4 for example).

To find out for sure we can work with RAW mode redologs very easily. Let’s take an example made in Red Hat 4, with a test BDD with 3 redologs of 51 MB each:

Source   
[oracle@clu01 DBU]$ ls -l
total 1502076
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:38 control01.ctl
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:38 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Jun 12 11:36 control03.ctl
-rw-r-----  1 oracle oinstall  52429312 Jun 25 11:06 redo01.log
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo02.log
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo03.log
-rw-r-----  1 oracle oinstall 545267712 Jun 25 20:38 sysaux01.dbf
-rw-r-----  1 oracle oinstall 744497152 Jun 25 20:38 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Jun 23 21:22 temp01.dbf
-rw-r-----  1 oracle oinstall  36708352 Jun 25 20:38 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Jun 25 20:38 users01.dbf

Let’s use an HD of the incredible capacity of 1GB and we will make three partitions (to 52MB) being:

Source   
[root@clu01 ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130): +52M
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (8-130, default 8):
Using default value 8
Last cylinder or +size or +sizeM or +sizeK (8-130, default 130): +52M
Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (15-130, default 15):
Using default value 15
Last cylinder or +size or +sizeM or +sizeK (15-130, default 130): +52M
Command (m for help): p
Disk /dev/sdb: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1           7       56196   83  Linux
/dev/sdb2               8          14       56227+  83  Linux
/dev/sdb3              15          21       56227+  83  Linux
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.

With devices:

Source   
[oracle@clu01 DBU]$ ls -l /dev/sdb*
brw-rw----  1 root disk 8, 16 Jun 25  2013 /dev/sdb
brw-rw----  1 root disk 8, 17 Jun 25  2013 /dev/sdb1
brw-rw----  1 root disk 8, 18 Jun 25  2013 /dev/sdb2
brw-rw----  1 root disk 8, 19 Jun 25  2013 /dev/sdb3

Change the owner to oracle:oinstall all devices (note that the changes are not permanent in the next restart lose them):

Source   
chown oracle:oinstall /dev/sdb1
chown oracle:oinstall /dev/sdb2
chown oracle:oinstall /dev/sdb3

As a result:

Source   
brw-rw----  1 oracle oinstall   817 Jun 25 20:31 /dev/sdb1
brw-rw----  1 oracle oinstall   818 Jun 25 20:31 /dev/sdb2
brw-rw----  1 oracle oinstall   819 Jun 25 20:31 /dev/sdb3

With DB shutdown rename the redologs (as backup), create symbolic links and copy the content in the raw of the redo files.

Source   
[oracle@clu01 DBU]$ ls
control01.ctl  control02.ctl  control03.ctl  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf
[oracle@clu01 DBU]$ mv redo01.log redo01.log.ori
[oracle@clu01 DBU]$ mv redo02.log redo02.log.ori
[oracle@clu01 DBU]$ mv redo03.log redo03.log.ori
[oracle@clu01 DBU]$ ls -l
total 1502076
-rw-r-----  1 oracle oinstall   9748480 Jun 25 11:06 control01.ctl
-rw-r-----  1 oracle oinstall   9748480 Jun 25 11:06 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Jun 12 11:36 control03.ctl
-rw-r-----  1 oracle oinstall  52429312 Jun 25 11:06 redo01.log.ori
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo02.log.ori
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo03.log.ori
-rw-r-----  1 oracle oinstall 545267712 Jun 25 11:06 sysaux01.dbf
-rw-r-----  1 oracle oinstall 744497152 Jun 25 11:06 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Jun 23 21:22 temp01.dbf
-rw-r-----  1 oracle oinstall  36708352 Jun 25 11:06 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Jun 25 11:06 users01.dbf
[oracle@clu01 DBU]$ ln -s /dev/sdb1 redo01.log
[oracle@clu01 DBU]$ ln -s /dev/sdb2 redo02.log
[oracle@clu01 DBU]$ ln -s /dev/sdb3 redo03.log
[oracle@clu01 DBU]$ ls -l
total 1502076
-rw-r-----  1 oracle oinstall   9748480 Jun 25 11:06 control01.ctl
-rw-r-----  1 oracle oinstall   9748480 Jun 25 11:06 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Jun 12 11:36 control03.ctl
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:34 redo01.log -> /dev/sdb1
-rw-r-----  1 oracle oinstall  52429312 Jun 25 11:06 redo01.log.ori
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:34 redo02.log -> /dev/sdb2
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo02.log.ori
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:35 redo03.log -> /dev/sdb3
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo03.log.ori
-rw-r-----  1 oracle oinstall 545267712 Jun 25 11:06 sysaux01.dbf
-rw-r-----  1 oracle oinstall 744497152 Jun 25 11:06 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Jun 23 21:22 temp01.dbf
-rw-r-----  1 oracle oinstall  36708352 Jun 25 11:06 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Jun 25 11:06 users01.dbf
[oracle@clu01 DBU]$ dd if=redo01.log.ori of=/dev/sdb1
102401+0 records in
102401+0 records out
[oracle@clu01 DBU]$ dd if=redo02.log.ori of=/dev/sdb2
102401+0 records in
102401+0 records out
[oracle@clu01 DBU]$ dd if=redo03.log.ori of=/dev/sdb3
102401+0 records in
102401+0 records out

Well now we have copied the redo log in the raw, they are targeted by symbolic links. We can now start the database without problems and all the relevant performance tests.

To undo this step simply do the reverse. Remove the symbolic links and copy the content of the RAW in redos.

Source   
[oracle@clu01 DBU]$ ls -l
total 1502076
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:57 control01.ctl
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:57 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Jun 12 11:36 control03.ctl
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:34 redo01.log -> /dev/sdb1
-rw-r-----  1 oracle oinstall  52429312 Jun 25 11:06 redo01.log.ori
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:34 redo02.log -> /dev/sdb2
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo02.log.ori
lrwxrwxrwx  1 oracle oinstall         9 Jun 25 20:35 redo03.log -> /dev/sdb3
-rw-r-----  1 oracle oinstall  52429312 Jun 25 10:39 redo03.log.ori
-rw-r-----  1 oracle oinstall 545267712 Jun 25 20:38 sysaux01.dbf
-rw-r-----  1 oracle oinstall 744497152 Jun 25 20:38 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Jun 23 21:22 temp01.dbf
-rw-r-----  1 oracle oinstall  36708352 Jun 25 20:38 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Jun 25 20:38 users01.dbf
[oracle@clu01 DBU]$ rm redo01.log
[oracle@clu01 DBU]$ rm redo02.log
[oracle@clu01 DBU]$ rm redo03.log
[oracle@clu01 DBU]$ dd if=/dev/sdb1 of=redo01.log.ori
112392+0 records in
112392+0 records out
[oracle@clu01 DBU]$ dd if=/dev/sdb2 of=redo02.log.ori
112455+0 records in
112455+0 records out
[oracle@clu01 DBU]$ dd if=/dev/sdb3 of=redo03.log.ori
112455+0 records in
112455+0 records out
[oracle@clu01 DBU]$ mv redo01.log.ori redo01.log
[oracle@clu01 DBU]$ mv redo02.log.ori redo02.log
[oracle@clu01 DBU]$ mv redo03.log.ori redo03.log
[oracle@clu01 DBU]$ ls -l
total 1517128
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:57 control01.ctl
-rw-r-----  1 oracle oinstall   9748480 Jun 25 20:57 control02.ctl
-rw-r-----  1 oracle oinstall   7061504 Jun 12 11:36 control03.ctl
-rw-r-----  1 oracle oinstall  57544704 Jun 25 21:33 redo01.log
-rw-r-----  1 oracle oinstall  57576960 Jun 25 21:34 redo02.log
-rw-r-----  1 oracle oinstall  57576960 Jun 25 21:34 redo03.log
-rw-r-----  1 oracle oinstall 545267712 Jun 25 20:38 sysaux01.dbf
-rw-r-----  1 oracle oinstall 744497152 Jun 25 20:38 system01.dbf
-rw-r-----  1 oracle oinstall  20979712 Jun 23 21:22 temp01.dbf
-rw-r-----  1 oracle oinstall  36708352 Jun 25 20:38 undotbs01.dbf
-rw-r-----  1 oracle oinstall   5251072 Jun 25 20:38 users01.dbf

And we started the DB without problems:

Source   
[oracle@clu01 DBU]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 25 21:35:33 2013
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area  464519168 bytes
Fixed Size            1345660 bytes
Variable Size          297797508 bytes
Database Buffers      159383552 bytes
Redo Buffers            5992448 bytes
Database mounted.
Database opened.

Leave a Reply