12c RAC Flex ASM
ASMCMD> showclustermode
ASM cluster : Flex mode disabled
ASMCMD>
Convert to Flex ASM
[root@rac1 scripts]# more converttoFlexASM.sh
#!/bin/sh
cd /u01/app/grid/cfgtoollogs/asmca/scripts
/u01/app/12.1.0/grid_1/srvm/admin/srvmhelper -updateDepASM
if [ "$?" != "0" ]; then
echo "Error updating ASM resource dependencies"
exit 1
fi
for node in rac1 rac2
do
/u01/app/12.1.0/grid_1/bin/crsctl stop cluster -n $node
if [ "$?" != "0" ]; then
echo "Error stopping Oracle Grid Infrastructure in node $node"
exit 1
fi
/u01/app/12.1.0/grid_1/bin/crsctl start cluster -n $node
stat=1
cmd="/u01/app/12.1.0/grid_1/bin/crsctl status server $node"
while [ $stat = 1 ]
do
sleep 5
op=`$cmd`
op=`echo $op | /bin/cut -d' ' -f2 | /bin/cut -d'=' -f2`
if [ "$op" = "ONLINE" ]
then
stat=0
echo "Oracle Grid Infrastructure restarted in node $node"
fi
done
if [ "$node" = rac1 ]; then
for lsnr in ASMNET1LSNR_ASM
do
/u01/app/12.1.0/grid_1/bin/srvctl start listener -listener $lsnr
lsnrret=$?
if [ "$lsnrret" = "2" ]; then
echo "ASM listener $lsnr running already"
elif [ "$lsnrret" != "0" ]; then
echo "Error starting ASM listener $lsnr"
exit 1
fi
done
fi
done
/u01/app/12.1.0/grid_1/bin/srvctl modify asm -count 3
[oracle@rac1 ~]$ asmcmd
ASMCMD> showclustermode
ASM cluster : Flex mode enabled
ASMCMD>
[oracle@rac1 ~]$ srvctl config asm
ASM home:
Password file: +DATA/orapwASM
ASM listener: LISTENER
ASM instance count: 3
Cluster ASM listener: ASMNET1LSNR_ASM
[oracle@rac1 ~]$
[oracle@rac1 ~]$ oifcfg getif
eth0 192.168.56.0 global public
eth1 192.168.10.0 global cluster_interconnect,asm
A new listener gets configured on both nodes
oracle 20086 1 0 22:46 ? 00:00:00 /u01/app/12.1.0/grid_1/bin/tnslsnr ASMNET1LSNR_ASM -no_crs_notify -inherit
[oracle@rac1 grid]$ crsctl stat res ora.asm -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.asm
1 ONLINE ONLINE rac1 Started,STABLE
2 ONLINE ONLINE rac2 Started,STABLE
3 OFFLINE OFFLINE STABLE
--------------------------------------------------------------------------------
[oracle@rac1 grid]$ srvctl modify asm -count 2
[oracle@rac1 grid]$
[oracle@rac1 grid]$ crsctl stat res ora.asm -t
--------------------------------------------------------------------------------
Name Target State Server State details
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.asm
1 ONLINE ONLINE rac1 Started,STABLE
2 ONLINE ONLINE rac2 Started,STABLE
--------------------------------------------------------------------------------
Check how ASM instances are connected to DB instance
1* select distinct i.instance_name, c.instance_name , c.db_name fro m gv$Instance i , gv$asm_client c where i.inst_id=c.inst_id
SQL> /
INSTANCE_NAME INSTANCE_NAME DB_NAME
---------------- ---------------------------------------------------------------- --------
+ASM1 +ASM1 +ASM
+ASM1 -MGMTDB _mgmtdb
+ASM1 test12c1 test12c
+ASM2 +ASM2 +ASM
+ASM2 test12c2 test12c
Now we will kill -9 asm background process (for +ASM1) and we will see that the query that started on test12c1 still keeps running on test12c1 as internally it connects to ASM2
INSTANCE_NAME INSTANCE_NAME DB_NAME STATUS
---------------- ---------------------------------------------------------------- -------- ------------
+ASM2 +ASM2 +ASM CONNECTED
+ASM2 -MGMTDB _mgmtdb CONNECTED
+ASM2 test12c1 test12c CONNECTED
+ASM2 test12c2 test12c CONNECTED
It was observed that even when first instance came up, ASM does not automatically re-distribute database client connections when the ASM instance is added.
We will now manually relocate the ASM client
Before
INSTANCE_NAME INSTANCE_NAME DB_NAME STATUS
---------------- ---------------------------------------------------------------- -------- ------------
+ASM2 +ASM2 +ASM CONNECTED
+ASM2 -MGMTDB _mgmtdb CONNECTED
+ASM2 test12c1 test12c CONNECTED
+ASM2 test12c2 test12c CONNECTED
SQL> l
1* selec t distinct i.instance_name, c.instance_name , c.db_name, c.status fro m gv$Instance i , gv$asm_client c wher e i.inst_id=c.inst_id
SQL>
SQL> alte r syste m relocat e client 'test12c1:test12c';
System altered.
After
SQL> selec t distinct i.instance_name, c.instance_name , c.db_name, c.status fro m
gv$Instance i , gv$asm_client c wher e i.inst_id=c.inst_id
2
SQL> /
INSTANCE_NAME INSTANCE_NAME DB_NAME STATUS
---------------- ---------------------------------------------------------------- -------- ------------
+ASM1 test12c1 test12c CONNECTED
+ASM2 +ASM2 +ASM CONNECTED
+ASM2 -MGMTDB _mgmtdb CONNECTED
+ASM2 test12c2 test12c CONNECTED
Lets see how the alert log of the database looks like, when the asm1 went down
1980-Sun Dec 11 19:32:06 2016
1981:NOTE: ASMB registering with ASM instance as Flex client 0x10005 (reg:2850413050) (reconnect)
1982:NOTE: ASMB connected to ASM instance +ASM2 osid: 26869 (Flex mode; client id 0x10005)
1983:NOTE: ASMB rebuilding ASM server state
1984:NOTE: ASMB rebuilt 1 (of 1) groups
1985:NOTE: ASMB rebuilt 23 (of 23) allocated files
--
1987-NOTE: 0 locks established; 0 pending writes sent to server
1988:SUCCESS: ASMB reconnected & completed ASM server state
--
2002-Sun Dec 11 19:50:07 2016
2003:NOTE: ASMB relocating fro m
ASM instance +ASM2 (ASM-initiated)
2004:NOTE: ASMB registering with ASM instance as Flex client 0x10005 (reg:1370596387) (reconnect)
2005:NOTE: ASMB connected to ASM instance +ASM1 osid: 18132 (Flex mode; client id 0x10005)
2006:NOTE: ASMB rebuilding ASM server state
2007:NOTE: ASMB rebuilt 1 (of 1) groups
2008:NOTE: ASMB rebuilt 23 (of 23) allocated files
--
2010-NOTE: 0 locks established; 0 pending writes sent to server
2011:SUCCESS: ASMB reconnected & completed ASM server state
first it shows, that the database got connected to +ASM2, then when we relocated the instance , it got connected to +ASM1.
Happy Learning !!!
DB Alchemist Academy
You may explore our E-Learning Page to have an insight into our High Rated Courses on Udemy
Share you comments
{{ errorMessage }}