oracle 创建asm三种方法

教程发布:风哥 教程分类:ITPUX技术网 更新日期:2022-02-12 浏览学习:1040

a.配置裸设备映射,修改/etc/udev/rules.d/60-raw.rules文件
[color=#362e2b]使用root帐户修改/etc/udev/rules.d/60-raw.rules 按如下方式添加磁盘
[color=#362e2b][root@oradb ~]# cat /etc/udev/rules.d/60-raw.rules --查看添加的内容
[color=#362e2b]ACTION=="add", KERNEL=="sdd1", RUN+="/bin/raw /dev/raw/raw1 %N"
[color=#362e2b]ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw1 %M %m"
[color=#362e2b]ACTION=="add", KERNEL=="sde1", RUN+="/bin/raw /dev/raw/raw2 %N"
[color=#362e2b]ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="17", RUN+="/bin/raw /dev/raw/raw2 %M %m"
[color=#362e2b][root@oradb ~]# start_udev #重启udev服务
[color=#362e2b]Starting udev: [ OK ]
[color=#362e2b][root@oradb ~]# ll /dev/raw
[color=#362e2b]total 0
[color=#362e2b]crw------- 1 root root 162, 1 Nov 10 18:50 raw1
[color=#362e2b]crw------- 1 root root 162, 2 Nov 10 18:50 raw2
[color=#362e2b][root@oradb ~]# chown oracle:dba /dev/raw/raw[1-2] --修改属主,否则创建磁盘组时提示权限不够
b.也可以采用下面的方式来增加磁盘,即直接修改/etc/sysconfig/rawdevices (root帐户)
[color=#362e2b][root@oradb ~]# vim /etc/sysconfig/rawdevices
[color=#362e2b][root@oradb ~]# cat /etc/sysconfig/rawdevices --查看增加的内容为raw3,raw4
[color=#362e2b]/dev/raw/raw3 /dev/sdf1
[color=#362e2b]/dev/raw/raw4 /dev/sdg1
[color=#362e2b][root@oradb ~]# chown oracle:dba /dev/raw/raw[3-4] --修改属主,否则创建磁盘组时提示权限不够
[color=#362e2b][root@oradb ~]# ll /dev/raw/
[color=#362e2b]total 0
[color=#362e2b]crw------- 1 oracle dba 162, 1 Nov 10 20:12 raw1
[color=#362e2b]crw------- 1 oracle dba 162, 2 Nov 10 20:12 raw2
[color=#362e2b]crw------- 1 oracle dba 162, 3 Nov 10 20:12 raw3
[color=#362e2b]crw------- 1 oracle dba 162, 4 Nov 10 20:12 raw4
[color=#362e2b]重启裸设备服务
[color=#362e2b][root@oradb ~]# /sbin/service rawdevices restart
[color=#362e2b]Assigning devices:
[color=#362e2b]/dev/raw/raw3 --> /dev/sdf1
[color=#362e2b]/dev/raw/raw3: bound to major 8, minor 81
[color=#362e2b]/dev/raw/raw4 --> /dev/sdg1
[color=#362e2b]/dev/raw/raw4: bound to major 8, minor 97
[color=#362e2b]done
[color=#362e2b]SQL> select instance_name,status from v$instance;
[color=#362e2b]INSTANCE_NAME STATUS
[color=#362e2b]---------------- ------------
[color=#362e2b]+ASM STARTED
[color=#362e2b]SQL> create diskgroup DG1 normal redundancy disk '/dev/raw/raw1','/dev/raw/raw2'; --创建磁盘组DG1
[color=#362e2b]SQL> select * from v$fixed_table where name like '%ASM%'; --查看和asm相关的视图
[color=#362e2b]SQL> select name,allocation_unit_size,state,type,
[color=#362e2b]2 free_mb,required_mirror_free_mb req_mi_fr_mb,usable_file_mb
[color=#362e2b]3 from v$asm_diskgroup;
[color=#362e2b]NAME ALLOCATION_UNIT_SIZE STATE TYPE FREE_MB REQ_MI_FR_MB USABLE_FILE_MB
[color=#362e2b]--------------- -------------------- ----------- ------ ---------- ------------ --------------
[color=#362e2b]DG1 1048576 MOUNTED NORMAL 296 0 148
[color=#362e2b]SQL> create diskgroup DG2 normal redundancy disk '/dev/raw/raw3','/dev/raw/raw4'; --创建磁盘组DG2
[color=#362e2b]SQL> select name,state,free_mb,required_mirror_free_mb,usable_file_mb --查看磁盘组的状态及信息
[color=#362e2b]2 from v$asm_diskgroup;
[color=#362e2b]NAME STATE FREE_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB
[color=#362e2b]--------------- ----------- ---------- ----------------------- --------------
[color=#362e2b]DG1 MOUNTED 296 0 148
[color=#362e2b]DG2 MOUNTED 296 0 148
[color=#362e2b]SQL> select disk_number,total_mb,free_mb from v$asm_disk;
[color=#362e2b]DISK_NUMBER TOTAL_MB FREE_MB
[color=#362e2b]----------- ---------- ----------
[color=#362e2b]1 199 148
[color=#362e2b]0 199 148
[color=#362e2b]1 199 148
[color=#362e2b]0 199 148
[color=#362e2b]重新启动Linux 主机后
[color=#362e2b]SQL> startup --重新启动ASM实例,收到了磁盘组insufficient信息
[color=#362e2b]ASM instance started
[color=#362e2b]ORA-15032: not all alterations performed
[color=#362e2b]ORA-15063: ASM discovered an insufficient number of disks for diskgroup "DG2"
[color=#362e2b]ORA-15063: ASM discovered an insufficient number of disks for diskgroup "DG1"
[color=#362e2b]SQL> ho ls -hlt /dev/raw # LINUX主机重新启动之后属主性质已发生变化
[color=#362e2b]total 0
[color=#362e2b]crw------- 1 root root 162, 4 Nov 10 20:28 raw4
[color=#362e2b]crw------- 1 root root 162, 3 Nov 10 20:28 raw3
[color=#362e2b]crw------- 1 root root 162, 2 Nov 10 20:28 raw2
[color=#362e2b]crw------- 1 root root 162, 1 Nov 10 20:28 raw1
[color=#362e2b]原因:原始设备在引导时会重新映射。默认情况下,在引导时原始设备的拥有者将更改为root 用户
[color=#362e2b]将下面的内容增加到/etc/rc.local文件(root帐户),重新启动主机,使得属主变为oracle,则不再出现类似的提示
[color=#362e2b]chown oracle:dba /dev/raw/raw1
[color=#362e2b]chown oracle:dba /dev/raw/raw2
[color=#362e2b]chown oracle:dba /dev/raw/raw3
[color=#362e2b]chown oracle:dba /dev/raw/raw4
[color=#362e2b]chmod 660 /dev/raw/raw1
[color=#362e2b]chmod 660 /dev/raw/raw2
[color=#362e2b]chmod 660 /dev/raw/raw3
[color=#362e2b]chmod 660 /dev/raw/raw4
[color=#362e2b]SQL> drop diskgroup dg1; --将刚才创建的两个磁盘组删除
[color=#362e2b]SQL> drop diskgroup dg2;
[color=#362e2b]使用root帐户清除/etc/udev/rules.d/60-raw.rules /etc/sysconfig/rawdevices 以及/etc/rc.local刚刚增加的记录
[color=#362e2b]便于下面使用asmlib来创建asm磁盘
c.使用root帐户配置ASMLib驱动及创建ASM磁盘,Oracle建议使用ASMLIB驱动来配置ASM磁盘
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm configure
[color=#362e2b]Configuring the Oracle ASM library driver.
[color=#362e2b]This will configure the on-boot properties of the Oracle ASM library
[color=#362e2b]driver. The following questions will determine whether the driver is
[color=#362e2b]loaded on boot and what permissions it will have. The current values
[color=#362e2b]will be shown in brackets ('[]'). Hitting without typing an
[color=#362e2b]answer will keep that current value. Ctrl-C will abort.
[color=#362e2b]Default user to own the driver interface []: oracle
[color=#362e2b]Default group to own the driver interface []: dba
[color=#362e2b]Start Oracle ASM library driver on boot (y/n) [n]: y
[color=#362e2b]Scan for Oracle ASM disks on boot (y/n) [y]: y
[color=#362e2b]Writing Oracle ASM library driver configuration: done
[color=#362e2b]Initializing the Oracle ASMLib driver: [ OK ]
[color=#362e2b]Scanning the system for Oracle ASMLib disks: [ OK ]
[color=#362e2b]--注意下面创建磁盘前本人重新对磁盘分过区
[color=#362e2b][root@oradb ~]# ls /dev/oracleasm/disks
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdd1
[color=#362e2b]Marking disk "VOL1" as an ASM disk: [ OK ]
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd2
[color=#362e2b]Marking disk "VOL2" as an ASM disk: [ OK ]
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
[color=#362e2b]Marking disk "VOL3" as an ASM disk: [ OK ]
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde2
[color=#362e2b]Marking disk "VOL4" as an ASM disk: [ OK ]
[color=#362e2b][root@oradb ~]# /etc/init.d/oracleasm listdisks
[color=#362e2b]VOL1
[color=#362e2b]VOL2
[color=#362e2b]VOL3
[color=#362e2b]VOL4
[color=#362e2b][root@oradb ~]# su - oracle
[color=#362e2b][oracle@oradb ~]$ export ORACLE_SID=+ASM
[color=#362e2b][oracle@oradb ~]$ sqlplus /nolog
[color=#362e2b]SQL> conn / as sysdba
[color=#362e2b]SQL> startup
[color=#362e2b]ASM instance started
[color=#362e2b]ORA-15110: no diskgroups mounted
[color=#362e2b]SQL> create diskgroup DG1 normal redundancy
[color=#362e2b]2 failgroup FG1 disk '/dev/oracleasm/disks/VOL1' name VOL1
[color=#362e2b]3 failgroup FG2 disk '/dev/oracleasm/disks/VOL2' name VOL2;
[color=#362e2b]create diskgroup DG1 normal redundancy
[color=#362e2b]*
[color=#362e2b]ERROR at line 1:
[color=#362e2b]ORA-15018: diskgroup cannot be created --下面提示磁盘路径未在discovery set中设置
[color=#362e2b]ORA-15031: disk specification '/dev/oracleasm/disks/VOL2' matches no disks
[color=#362e2b]ORA-15014: location '/dev/oracleasm/disks/VOL2' is not in the discovery set
[color=#362e2b]ORA-15031: disk specification '/dev/oracleasm/disks/VOL1' matches no disks
[color=#362e2b]ORA-15014: location '/dev/oracleasm/disks/VOL1' is not in the discovery set
[color=#362e2b]SQL> show parameter asm_diskstring
[color=#362e2b]NAME TYPE VALUE
[color=#362e2b]------------------------------------ ----------- ------------------------------
[color=#362e2b]asm_diskstring string
[color=#362e2b]SQL> alter system set asm_diskstring='/dev/oracleasm/disks/VOL*';
[color=#362e2b]SQL> create diskgroup DG1 normal redundancy --设置asm_diskstring后重新创建磁盘DG1成功
[color=#362e2b]2 failgroup FG1 disk '/dev/oracleasm/disks/VOL1' name VOL1
[color=#362e2b]3 failgroup FG2 disk '/dev/oracleasm/disks/VOL2' name VOL2;
[color=#362e2b]SQL> select name,state,free_mb,required_mirror_free_mb,usable_file_mb
[color=#362e2b]2 from v$asm_diskgroup;
[color=#362e2b]NAME STATE FREE_MB REQUIRED_MIRROR_FREE_MB USABLE_FILE_MB
[color=#362e2b]--------------- ----------- ---------- ----------------------- --------------
[color=rgb(54, 46, 43)][font=NSimSun][size=13px]DG1 MOUNTED 2964 0 1482

[color=rgb(54, 46, 43)][font=NSimSun][size=13px]注释:
[color=rgb(54, 46, 43)][font=NSimSun][size=13px]查看major和minor
[color=rgb(54, 46, 43)][font=NSimSun][size=13px][root@dbserver dev]# cat /proc/partitions
[color=rgb(54, 46, 43)][font=NSimSun][size=13px]major minor #blocks name

[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 0 25165824 sda
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 1 104391 sda1
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 2 25061400 sda2
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 16 41943040 sdb
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 17 10008463 sdb1
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 18 10008495 sdb2
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 19 10008495 sdb3
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 20 11912197 sdb4
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 32 10485760 sdc
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 33 1959898 sdc1
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 34 1 sdc2
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 37 1959898 sdc5
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 38 1959898 sdc6
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 39 1959898 sdc7
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 8 40 1959898 sdc8
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 253 0 18939904 dm-0
[color=rgb(54, 46, 43)][font=NSimSun][size=13px] 253 1 6094848 dm-1

本文标签:
网站声明:本文由风哥整理发布,转载请保留此段声明,本站所有内容将不对其使用后果做任何承诺,请读者谨慎使用!
【上一篇】
【下一篇】