ITPUX技术网

交流 . 资讯 . 分享
Make progress together!
Linux操作系统下Oracle11g R2 RAC 安装配置教程
Oracle数据库培训-备份恢复-性能优化-集群容灾
Oracle数据库DBA高级工程师培训视频

oracle 创建asm三种方法

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


注释:
查看major和minor
[root@dbserver dev]# cat /proc/partitions
major minor  #blocks  name


   8     0   25165824 sda
   8     1     104391 sda1
   8     2   25061400 sda2
   8    16   41943040 sdb
   8    17   10008463 sdb1
   8    18   10008495 sdb2
   8    19   10008495 sdb3
   8    20   11912197 sdb4
   8    32   10485760 sdc
   8    33    1959898 sdc1
   8    34          1 sdc2
   8    37    1959898 sdc5
   8    38    1959898 sdc6
   8    39    1959898 sdc7
   8    40    1959898 sdc8
253     0   18939904 dm-0
253     1    6094848 dm-1



上一篇:VMware 中使用 scsi_id 查询磁盘UUID
下一篇:oracle 60-raw.rules和99-oracle-asmdevices.rules区别
回复

使用道具 举报

1框架
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表