Is there any trick to Resize LVM online that raw by UDEV rule without filesystem?
-
30-09-2020 - |
Question
Here is the Logic Volume for example:
lvcreate -L2G -n Lv_OraD1 vg_db lvcreate -L180G -n Lv_OraD2 vg_db lvdisplay /dev/mapper/Lv_OraD*
UDEV rule to raw the LV:
vi /etc/udev/rules.d/60-raw.rules ACTION=="add", ENV{MAJOR}=="253",ENV{MINOR}=="3", RUN+="/bin/raw /dev/raw/raw1 %N" ACTION=="add", ENV{MAJOR}=="253",ENV{MINOR}=="4", RUN+="/bin/raw /dev/raw/raw2 %N" ACTION=="add",KERNEL=="raw[1-9]",OWNER="grid",GROUP="dba",MODE="660" start_udev raw -qa
ASM Diskgroup maybe like this:
CREATE DISKGROUP DATA1 NORMAL REDUNDANCY FAILGROUP Fg1 DISK '/dev/raw/raw1' SIZE 2048M ,'/dev/raw/raw2' SIZE 184320M;
The effect: the size up 2G of DISKGROUP DATA1 cannot be used.
so any tricks to achieve this result online?
lvreduce -L90G /dev/mapper/Lv_OraD2 lvextend -L90G /dev/mapper/Lv_OraD1
Thanks.
Solution
First find the disk names and paths:
select name, failgroup, path, os_mb, total_mb, free_mb from v$asm_disk;
After you found the ASM generated name for the disk you want to shrink, reduce it in ASM to the desired size (I will assume it is called DATA1_0002
:
alter diskgroup data1 resize disk DATA1_0002 size 90G;
This starts a rebalance, wait until the rebalance completes, you can view its progress as:
select * from v$asm_operation;
After the rebalance, run this query again:
select name, failgroup, path, os_mb, total_mb, free_mb from v$asm_disk;
There you should see the original 184320 OS_MB
, and 92160 TOTAL_MB
for the disks you have just shrinked. Next use lvreduce to shrink the LV:
lvreduce -L 90G vg_db/Lv_OraD2
Make sure you do not reduce the size of LV below the ASM disk size TOTAL_MB
.
Once it is done, increase the other LV:
lvextend -L 90G g_db/Lv_OraD1
Go back to ASM, run this again:
select name, failgroup, path, os_mb, total_mb, free_mb from v$asm_disk;
Here the OS_MB
for the first disk should increase to 92160, but TOTAL_MB
still remain 2048.
The final step is to increase the first disk size in ASM:
alter diskgroup data1 resize all;
The above will resize all ASM disks in the diskgroup up to OS_MB
. This triggers another short rebalance, and when that finished, you should see 92160 for OS_MB
and TOTAL_MB
for both disks.