阿里云ORACLE RAC共享磁盘组扩容实战笔记

一、问题需求

某项目一套RAC共享ASM磁盘组空间不足,导致无法完成归档,数据库无法正常使用

二、过程

2.1 新购共享块存储并挂载

1、阿里云上新购共享块存储并挂载到两rac节点上

image-20220217160357283

2、登陆到两rac节点查看是否挂载成功

用如下命令查看磁盘是否成功挂载到rac节点

fdisk -l

2.2 新建ASM磁盘

1、对新磁盘进行分区操作

 [root@stage ~]# fdisk /dev/sde

Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel

Building a new DOS disklabel with disk identifier 0x185ef87e.

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)

 WARNING: DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') and change display units to

         sectors (command 'u').

 Command (m for help): n

Command action

   e   extended

   p   primary partition (1-4)

p

Partition number (1-4): 1

First cylinder (1-8192, default 1):

Using default value 1

Last cylinder, +cylinders or +size{K,M,G} (1-8192, default 8192):

Using default value 8192

 Command (m for help): w

The partition table has been altered!

 Calling ioctl() to re-read partition table.

Syncing disks.

 [root@stage ~]#  partprobe /dev/sde

 [root@stage ~]#  fdisk -l

Disk /dev/sdc: 1073 MB, 1073741824 bytes

34 heads, 61 sectors/track, 1011 cylinders

Units = cylinders of 2074 * 512 = 1061888 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x6dab55b0

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdc1               1        1011     1048376+  83  Linux

 

Disk /dev/sdd: 6442 MB, 6442450944 bytes

199 heads, 62 sectors/track, 1019 cylinders

Units = cylinders of 12338 * 512 = 6317056 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x9904376c

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sdd1               1        1019     6286180   83  Linux

 

Disk /dev/mapper/VolGroup00-root: 24.2 GB, 24201134080 bytes

255 heads, 63 sectors/track, 2942 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

  

Disk /dev/mapper/VolGroup00-swap: 2113 MB, 2113929216 bytes

255 heads, 63 sectors/track, 257 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x00000000

 Disk /dev/sde: 8589 MB, 8589934592 bytes

64 heads, 32 sectors/track, 8192 cylinders

Units = cylinders of 2048 * 512 = 1048576 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x185ef87e

 

   Device Boot      Start         End      Blocks   Id  System

/dev/sde1               1        8192     8388592   83  Linux

2、查询磁盘组的资源使用情况

通常我们关注FREE_MB字段

SQL> SELECT GROUP_NUMBER,NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TYPE TOTAL_MB,FREE_MB FROM V$ASM_DISKGROUP;

image-20220217162747988

3、创建asm磁盘

[root@oracle1 ~]# /etc/init.d/oracleasm createdisk DATA_0001 /dev/sde1

Marking disk "DATA_0001" as an ASM disk:                   [  OK  ]

[root@oracle1 ~]# /usr/sbin/oracleasm listdisks   #查看asm的磁盘的创建情况

[root@oracle1 ~]# /usr/sbin/oracleasm scandisks  #一个节点创建磁盘后,另一个节点扫描磁盘即可

[grid@stageoem1 ~]$ asmcmd -p

ASMCMD [+] > lsdsk

Path

ORCL:DATA_0000

ORCL:DATA_0001

ORCL:INDX_0000

ASMCMD [+] >

4、查询已新创建的ASM磁盘信息

SQL> SELECT
     NVL(a.name, '[CANDIDATE]')      disk_group_name
     , b.path                          disk_file_path
     , b.name                          disk_file_name
     , b.failgroup                     disk_file_fail_group
FROM  v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY a.name;

image-20220217163358458

5、添加asm disk到asm磁盘组 DATA (you need to login as sysasm not sysdba)

SQL> ALTER DISKGROUP DATA ADD DISK 'ORCL:DATA_0001';
Diskgroup altered.
SQL> SELECT
     NVL(a.name, '[CANDIDATE]')      disk_group_name
     , b.path                          disk_file_path
     , b.name                          disk_file_name
     , b.failgroup                     disk_file_fail_group
FROM v$asm_diskgroup a RIGHT OUTER JOIN v$asm_disk b USING (group_number)
ORDER BY a.name;

image-20220217163747992

2.3 结果验证

1、验证asm磁盘组

SQL> SELECT GROUP_NUMBER,NAME,SECTOR_SIZE,BLOCK_SIZE,ALLOCATION_UNIT_SIZE,STATE,TYPE TOTAL_MB,FREE_MB FROM V$ASM_DISKGROUP;

image-20220217163944528

2、验证asm磁盘

SQL> SELECT MOUNT_STATUS,HEADER_STATUS,MODE_STATUS,STATE,TOTAL_MB,FREE_MB,NAME,PATH,LABEL FROM V$ASM_DISK;

image-20220217164023640

三、小结

扩容磁盘组的大概步骤如下:

1、新增共享磁盘到两rac节点

2、对共享磁盘进行分区

3、创建asm磁盘,并加入到asm磁盘组

4、验证结果

posted @ 2022-02-17 17:05  雪竹子  阅读(706)  评论(0编辑  收藏  举报