database spfile created in wrong place under ASM

SYMPTOMS

DBA is trying to create a new spfile from a pfile as following :

SQL> create SPFILE='+DATAC1/TESTDB/' from pfile='/home/oracle/testdb.pfile';
File created.

Under ASM , the spile is link to the wrong location under ASM:

ASMCMD> ls -alr
Type Redund Striped Time Sys Name
N spfile =>
+DATAC1/DB_UNKNOWN/PARAMETERFILE/SPFILE.272.613162051
ASMCMD>

OR

ASMCMD> ls -alr
Type Redund Striped Time Sys Name
N spfile =>
+DATAC1/ASM/PARAMETERFILE/spfile.4186.1126528877
ASMCMD>

CAUSE

This is because the database instance has no open client session to the ASM instance at the time of the ‘create spfile’ command. That is, the ASM instance is not aware of the db name and therefore uses “DB_UNKNOWN” or ‘ASM’.

SOLUTION

When database in OPEN or MOUNT status, make sure  there is at least one connection to the ASM instance. 

SQL>select * from v$asm_client;

GROUP_NUMBER INSTANCE_NAME
------------ ----------------------------------------------------------------
DB_NAME  CLUSTER_NAME                    STATUS
-------- ------------------------------- ------------
SOFTWARE_VERSION
------------------------------------------------------------
COMPATIBLE_VERSION                                               CON_ID
------------------------------------------------------------ ----------
           0 +ASM1
TESTDB_ usa1234clu07cb8                 CONNECTED
19.0.0.0.0
19.0.0.0.0                                                            0

— Create spfile from a pfile

SQL>  create spfile='+datac1' from pfile='/home/oracle/testdb.pfile';

File created.

— check spfile is created in the right directory now

ASMCMD> pwd
+datac1
ASMCMD> cd TESTDB/
ASMCMD> ls PARAMETERFILE/
spfile.4186.1126530135

— configure TESTDB database with new spfile

$ srvctl modify  database -d TESTDB -spfile  '+DATAC1/TESTDB/PARAMETERFILE/spfile.4186.1126530135'
Advertisement

asmcmd pwcopy password file into ‘DB_UNKNOWN’ directory

When trying to copy password file of primary databases for standby database, unfortunately the password file was located into a directory called “DB_UNKNOWN”.

$ asmcmd pwcopy /tmp/orapwTESTDB +DATAC1/TESTDB/PASSWORD/
copying /tmp/orapwTESTDB -> +DATAC1/TESTDB/PASSWORD/orapwTESTDB
$ asmcmd
ASMCMD> cd +DATAC1/TESTDB/PASSWORD/
ASMCMD> ls -lt
Type      Redund  Striped  Time             Sys  Name
PASSWORD  HIGH    COARSE   JUL 16 14:00:00  Y    pwdtestdb.372.1078064659
PASSWORD  HIGH    COARSE   JUL 16 17:00:00  N    orapwtestdb => +DATAC1/DB_UNKNOWN/PASSWORD/pwddb_unknown.266.1078077567

SOLUTION

Subscribe to get access

Read more of this content when you subscribe today.

Finally you need modify the database configuration to use the new password file:

$ srvctl modify database -d TESTDB  -pwfile +DATAC1/TESTDB/PASSWORD/pwdtestdb.372.1078078773

How to Relocate ASM ControlFiles

After database name has been changed, the controlfiles are still staying in the directory of old database, so we need relocate them into directory of new database name.

Subscribe to get access

Read more of this content when you subscribe today.

How to Increase ASM Disk Size in VirtualBox

FRA diskgroup has two ASM disks, we just want to have one disk and also need increase the FRA diskgroup size, here are the steps.

  • Drop ASM disk
  • Clone the disk, because ASM disk file is “Format variant: fixed default”. After cloning, the format changes to “Format variant: dynamic default”.
  • Resize the disk
  • Clone back the disk
  • Partition the disk
  • Create ASM disk
  • Add back into Disk Group

1)Check ASM disks in FRA diskgroup.

SQL>  select GROUP_NUMBER, STATE, TOTAL_MB,FREE_MB,NAME,PATH  
       from  v$asm_disk 
       where GROUP_NUMBER in ( select GROUP_NUMBER 
                                from v$asm_diskgroup 
                               where name='FRA');

GR STATE    TOTAL_MB FREE_MB  NAME      PATH
-- -------- ----- -------- ---------- ------------------------------
2  NORMAL   5119      4954 FRA_0001  /dev/oracleasm/disks/ASM_DISK6
2  NORMAL   5119      4958 FRA_0000  /dev/oracleasm/disks/ASM_DISK5

2) Drop asm disk  FRA_0001.

SQL> ALTER DISKGROUP FRA drop disk FRA_0001;

Diskgroup altered.
SQL> select * from v$asm_operation ;

no rows selected
SQL> select STATE, TOTAL_MB,FREE_MB,NAME,PATH 
      from v$asm_disk where GROUP_NUMBER=2;

STATE  TOTAL_MB FREE_MB NAME     PATH
----- -------- ------- -------- -------------------------------------
NORMAL 5119   4795  FRA_0000 ASM_DISK5 /dev/oracleasm/disks/ASM_DISK5

3)Release asm6.vdi disk file from menu “Host Media Manager”. It detached this file from both racnode1 &2 VMs.

4)Resize asm6.vdi from 5G to 50G.

We can just create a new vdi file. But here for practice purpose, we just choose hard way to resize the fixed size vdi file.

c:\Program Files\Oracle\VirtualBox>VBoxManage showhdinfo D:\virtuallab\asm6.vdi
UUID: 8a52a736-6f03-4766-b656-4e6496cce4eb
Parent UUID: base
State: created
Type: normal (base)
Location: D:\virtuallab\asm6.vdi
Storage format: VDI
Format variant: fixed default
Capacity: 5120 MBytes
Size on disk: 5122 MBytes
Encryption: disabled
Property: AllocationBlockSize=1048576

We must clone it into new one file, dynamically allocated.

c:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd 
                   d:\virtuallab\asm6.vdi d:\virtuallab\asm6_new.vdi
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'VDI'. UUID: e3f94421-f905-4dee-bc8e-91649d187d35
c:\Program Files\Oracle\VirtualBox>VBoxManage showhdinfo D:\virtuallab\asm6_new.vdi
UUID: e3f94421-f905-4dee-bc8e-91649d187d35
Parent UUID: base
State: created
Type: normal (base)
Location: D:\virtuallab\asm6_new.vdi
Storage format: VDI
Format variant: dynamic default
Capacity: 5120 MBytes
Size on disk: 168 MBytes
Encryption: disabled
Property: AllocationBlockSize=1048576

Resize asm6_new.vdi to 50GB, and change into fixed size for ASM disk purpose.

c:\Program Files\Oracle\VirtualBox>VBoxManage modifyhd 
                          d:\virtuallab\asm6_new.vdi --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

Remove asm6.vdi from “Host Media Manager”, and clone back with fixed size now.

c:\Program Files\Oracle\VirtualBox>VBoxManage.exe clonehd 
  d:\virtuallab\asm6_new.vdi d:\virtuallab\asm6.vdi --variant Fixed
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Clone medium created in format 'VDI'. UUID: d0875c78-ac96-49cc-a4d0-2e55422b2560


c:\Program Files\Oracle\VirtualBox>VBoxManage showhdinfo D:\virtuallab\asm6.vdi
UUID: d0875c78-ac96-49cc-a4d0-2e55422b2560
Parent UUID: base
State: created
Type: normal (base)
Location: D:\virtuallab\asm6.vdi
Storage format: VDI
Format variant: fixed default
Capacity: 50000 MBytes
Size on disk: 50002 MBytes
Encryption: disabled
Property: AllocationBlockSize=1048576

Partition disk.

[root@racnode1 ~]# fdisk /dev/sde
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.


Command (m for help): p

Disk /dev/sde: 52.4 GB, 52428800000 bytes, 102400000 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0xe5f3fc7c

Device Boot Start End Blocks Id System
/dev/sde1 2048 10485759 5241856 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 is deleted

Command (m for help): 1
1: unknown command
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): n
Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-102399999, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-102399999, default 102399999):
Using default value 102399999
Partition 1 of type Linux and of size 48.8 GiB is set

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@racnode1 ~]#
[root@racnode1 ~]# oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...
[root@racnode1 ~]# oracleasm listdisks
ASM_DISK1
ASM_DISK2
ASM_DISK3
ASM_DISK5
ASM_DISK6
ASM_OCR_VOTE1
[root@racnode1 ~]# oracleasm deletedisk ASM_DISK6;
Clearing disk header: done
Dropping disk: done

[root@racnode1 ~]# oracleasm createdisk  ASM_DISK6  /dev/sde1
Writing disk header: done
Instantiating disk: done
[root@racnode1 ~]# blkid
/dev/sda1: UUID="fc21c76e-90ae-4d7f-9b1a-52412af3cf78" TYPE="xfs"
/dev/sda2: UUID="ifffmk-GSXU-NcKC-vww1-HMF6-Nc36-A6sewK" TYPE="LVM2_member"
/dev/sda3: UUID="DG6gQe-VQki-1oT2-V1wk-1etX-6qkp-7QP3cX" TYPE="LVM2_member"
/dev/sdb1: LABEL="ASM_DISK1" TYPE="oracleasm"
/dev/sdc1: LABEL="ASM_DISK2" TYPE="oracleasm"
/dev/sdd1: LABEL="ASM_DISK3" TYPE="oracleasm"
/dev/sde1: LABEL="ASM_DISK6" TYPE="oracleasm"
/dev/sdf1: LABEL="ASM_DISK5" TYPE="oracleasm"
/dev/sdg1: LABEL="ASM_OCR_VOTE1" TYPE="oracleasm"
/dev/sr0: UUID="2019-12-10-15-09-23-93" LABEL="VBox_GAs_6.1.0" TYPE="iso9660"
/dev/mapper/ol-root: UUID="b4379983-435f-4012-b054-89e6834c283a" TYPE="xfs"
/dev/mapper/ol-swap: UUID="3bfcff72-20c3-4e1e-ad38-20de7cca2050" TYPE="swap"
[root@racnode1 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sdf 8:80 0 5G 0 disk
└─sdf1 8:81 0 5G 0 part
sdd 8:48 0 5G 0 disk
└─sdd1 8:49 0 5G 0 part
sdb 8:16 0 5G 0 disk
└─sdb1 8:17 0 5G 0 part
sr0 11:0 1 56.8M 0 rom
sdg 8:96 0 50G 0 disk
└─sdg1 8:97 0 50G 0 part
sde 8:64 0 48.8G 0 disk
└─sde1 8:65 0 5G 0 part
sdc 8:32 0 5G 0 disk
└─sdc1 8:33 0 5G 0 part
sda 8:0 0 96G 0 disk
├─sda2 8:2 0 29.5G 0 part
│ ├─ol-swap 252:1 0 8G 0 lvm [SWAP]
│ └─ol-root 252:0 0 61G 0 lvm /
├─sda3 8:3 0 66G 0 part
│ ├─ol-swap 252:1 0 8G 0 lvm [SWAP]
│ └─ol-root 252:0 0 61G 0 lvm /
└─sda1 8:1 0 500M 0 part /boot

Add disk back into diskgroup FRA.

SQL> ALTER DISKGROUP FRA ADD DISK '/dev/oracleasm/disks/ASM_DISK6' 
                                               NAME FRA_ASM_DISK6;

Diskgroup altered.
SQL> select STATE, TOTAL_MB,FREE_MB,NAME,PATH
from v$asm_disk where GROUP_NUMBER=2; 

STATE  TOTAL_MB FREE_MB NAME          PATH
------ -------- ------- ------------- ------------------------------
NORMAL    5119  5086    FRA_0000      /dev/oracleasm/disks/ASM_DISK5
NORMAL   49999 49706    FRA_ASM_DISK6 /dev/oracleasm/disks/ASM_DISK6

Drop the small size asm disk ASM_DISK5.

SQL>  ALTER DISKGROUP FRA drop DISK FRA_0000;

Diskgroup altered.
[root@racnode1 ~]#  oracleasm deletedisk ASM_DISK5;
Disk "ASM_DISK5" defines an unmarked device
Dropping disk: done

[root@racnode1 ~]#  oracleasm scandisks
Reloading disk partitions: done
Cleaning any stale ASM disks...
Scanning system for ASM disks...

[root@racnode1 ~]#  oracleasm listdisks
ASM_DISK1
ASM_DISK2
ASM_DISK3
ASM_DISK6
ASM_OCR_VOTE1
[root@racnode1 ~]#
SQL>select STATE, TOTAL_MB,FREE_MB,NAME,PATH
    from v$asm_disk where GROUP_NUMBER=2;

STATE TOTAL_MB   FREE_MB NAME         PATH
------ -------- ------- ------------- ------------------------------
NORMAL 49999    49706   FRA_ASM_DISK6 /dev/oracleasm/disks/ASM_DISK6

ORA-15032 ORA-59303 ORA-15221: ASM operation requires compatible.asm of 11.1.0.0.0 or higher

For upgrading 12.1.0.2 GI to 12.2.0.1 GI, after running rootupgrade.sh, there are some disk groups are not mounted.

NAME                  STATE       COMPATIBILITY      V
-------------------- ----------- ------------------- -
GIMR                  DISMOUNTED  0.0.0.0.0          N
FRA                   DISMOUNTED  0.0.0.0.0          N
DATA                  MOUNTED     12.1.0.0.0         N
OCR_VOTE              MOUNTED     11.2.0.4.0         Y
SQL> alter diskgroup FRA mount;
alter diskgroup FRA mount
*
ERROR at line 1:
ORA-15032: not all alterations performed
ORA-59303: The attribute compatible.asm (10.1.0.0.0) of the 
           diskgroup being mounted should be 11.2.0.2.0 or higher.
ORA-15221: ASM operation requires compatible.asm of 11.1.0.0.0 
           or higher
SQL> alter diskgroup FRA mount restricted;

Diskgroup altered.

SQL> alter diskgroup FRA set attribute 'compatible.asm'='11.2.0.4';

Diskgroup altered.

SQL> alter diskgroup FRA dismount;

Diskgroup altered.

SQL> alter diskgroup GIMR mount restricted;

Diskgroup altered.

SQL> alter diskgroup GIMR set attribute 'compatible.asm'='11.2.0.4';

Diskgroup altered.

SQL> alter diskgroup GIMR dismount;

Diskgroup altered.

SQL> alter diskgroup FRA mount;

Diskgroup altered.

SQL> alter diskgroup GIMR mount;

Diskgroup altered.



SQL>   select NAME, STATE, COMPATIBILITY  from  v$asm_diskgroup;

NAME                           STATE       COMPATIBILITY
------------------------------ ----------- -------------------
DATA                           MOUNTED     12.1.0.0.0
FRA                            MOUNTED     11.2.0.4.0
OCR_VOTE                       MOUNTED     11.2.0.4.0
GIMR                           MOUNTED     11.2.0.4.0