欢迎投稿

今日深度:

ASM下裸设备的路径更改是否会影响数据库的运行

ASM下裸设备的路径更改是否会影响数据库的运行,asm会影响


通过asm来存储数据库文件,在linux下可以通过asmlib的方式来管理块设备,也可以直接使用裸设备来建立asm磁盘。在asmlib方式下,磁盘设备启动顺序和名称的改变不会影响到asm的使用,但如果直接使用裸设备会怎么样那?我们知道asm会在磁盘中存储与asm有关的元数据,通过这些元数据asm可以了解磁盘的相关信息,因此理论上裸设备名称的改变不会影响asm的正常使用。下面,通过实验来验证一下。

首先看以下,裸设备的配置文件

node1

[root@node1 ~]# cat /etc/udev/rules.d/60-raw.rules 
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb5", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdb6", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdb7", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdb8", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdb9", RUN+="/bin/raw /dev/raw/raw7 %N"
node2:

[root@node2 rules.d]# cat 60-raw.rules 
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb5", RUN+="/bin/raw /dev/raw/raw3 %N"
ACTION=="add", KERNEL=="sdb6", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdb7", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdb8", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdb9", RUN+="/bin/raw /dev/raw/raw7 %N"
asm下的磁盘信息如下:

[oracle@node1 ~]$ export ORACLE_SID=+ASM1
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Aug 31 12:55:25 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> col name for a30
SQL> col label for a30
SQL> col path for a30
SQL> set linesize 200
SQL> /

NAME			       LABEL			      PATH
------------------------------ ------------------------------ ------------------------------
DG1_0000						      /dev/raw/raw3
DG2_0000						      /dev/raw/raw4
DG3_0000						      /dev/raw/raw5
DG3_0001						      /dev/raw/raw6
DG4_0000						      /dev/raw/raw7
							      /dev/raw/raw2
							      /dev/raw/raw1

7 rows selected.

SQL> ho ssh node2 
Last login: Sat Aug 30 17:56:54 2014 from node1
[oracle@node2 ~]$ export ORACLE_SID=+ASM2
[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Aug 31 12:56:38 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> col name for a30
SQL> col label for a30
SQL> col path for a30
SQL> set linesize 200
SQL> select name,label,path from v$asm_disk order by 1;

NAME			       LABEL			      PATH
------------------------------ ------------------------------ ------------------------------
DG1_0000						      /dev/raw/raw3
DG2_0000						      /dev/raw/raw4
DG3_0000						      /dev/raw/raw5
DG3_0001						      /dev/raw/raw6
DG4_0000						      /dev/raw/raw7
							      /dev/raw/raw2
							      /dev/raw/raw1

7 rows selected.


创建测试表:

SQL> select file_name,tablespace_name from dba_data_files;

FILE_NAME				     TABLESPACE_NAME
-------------------------------------------- ------------------------------
+DG4/easy/datafile/system.272.856543875      SYSTEM
+DG4/easy/datafile/undotbs1.273.856543885    UNDOTBS1
+DG4/easy/datafile/sysaux.274.856543891      SYSAUX
+DG4/easy/datafile/undotbs2.276.856543901    UNDOTBS2
+DG4/easy/datafile/users.277.856543905	     USERS

SQL> create table t1 (id number,name varchar2(20)) tablespace users;

Table created.

SQL> insert into t1 values(1,111);

1 row created.

SQL> insert into t1 select * from t1;

1 row created.

SQL> /

2 rows created.

SQL> /

4 rows created.

SQL> /

8 rows created.

SQL> /

16 rows created.

SQL> /

32 rows created.

SQL> /

64 rows created.

SQL> commit;

Commit complete.

SQL> select count(*) from t1;

  COUNT(*)
----------
       128

SQL> update t1 set id=rownum,name=rownum;

128 rows updated.

SQL> commit;

Commit complete.

修改裸设备的路径名称并重起集群

[root@node1 ~]# cat /etc/udev/rules.d/60-raw.rules 
# Enter raw device bindings here.
#
# An example would be:
#   ACTION=="add", KERNEL=="sda", RUN+="/bin/raw /dev/raw/raw1 %N"
# to bind /dev/raw/raw1 to /dev/sda, or
#   ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# to bind /dev/raw/raw2 to the device with major 8, minor 1.

ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdb2", RUN+="/bin/raw /dev/raw/raw2 %N"
ACTION=="add", KERNEL=="sdb5", RUN+="/bin/raw /dev/raw/raw7 %N"
ACTION=="add", KERNEL=="sdb6", RUN+="/bin/raw /dev/raw/raw6 %N"
ACTION=="add", KERNEL=="sdb7", RUN+="/bin/raw /dev/raw/raw5 %N"
ACTION=="add", KERNEL=="sdb8", RUN+="/bin/raw /dev/raw/raw4 %N"
ACTION=="add", KERNEL=="sdb9", RUN+="/bin/raw /dev/raw/raw3 %N"
[oracle@node1 ~]$ export ORACLE_SID=+ASM1
[oracle@node1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Aug 31 13:13:01 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> col name for a30
SQL> col lable for a33
SQL> col path for a33
SQL> set linesize 222
SQL> col label for a31
SQL> /

NAME			       LABEL			       PATH
------------------------------ ------------------------------- ---------------------------------
DG1_0000						       /dev/raw/raw7
DG2_0000						       /dev/raw/raw6
DG3_0000						       /dev/raw/raw5
DG3_0001						       /dev/raw/raw4
DG4_0000						       /dev/raw/raw3
							       /dev/raw/raw1
							       /dev/raw/raw2

7 rows selected.

SQL> ho ssh oracle@node2
Last login: Sun Aug 31 12:56:27 2014 from node1
[oracle@node2 ~]$ export ORACLE_SID=+ASM2
[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Aug 31 13:14:31 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> col name for a31
SQL> col label for a31
SQL> col path for a31
SQL> set linesize 211
SQL> select name,label,path from v$asm_disk order by 1;

NAME				LABEL				PATH
------------------------------- ------------------------------- -------------------------------
DG1_0000							/dev/raw/raw3
DG2_0000							/dev/raw/raw4
DG3_0000							/dev/raw/raw5
DG3_0001							/dev/raw/raw6
DG4_0000							/dev/raw/raw7
								/dev/raw/raw2
								/dev/raw/raw1

7 rows selected.

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options
[oracle@node2 ~]$ export ORACLE_SID=easy2
[oracle@node2 ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Aug 31 13:15:31 2014

Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application Testing options

SQL> select count(*) from t1;

  COUNT(*)
----------
       128

SQL> select min(id),max(id) from t1;

   MIN(ID)    MAX(ID)
---------- ----------
	 1	  128

由此可见,裸设备路径和名称的改变不会影响asm的使用,但是,我们依然建议保持路径名称的稳定性,方便管理。





想在Linux的环境下在ASM上建立Oracle数据库,可是没有ASM磁盘,应该怎做?

正好刚整理了一个这方面的资料,先贴给你吧.
准备ASM环境
ASM使用一个名叫“+ASM”的数据库实例来管理ASM磁盘,因此在配置ASM磁盘之前,需要先启动ASM实例。另外还需要注意,ASM 实例必须要先于数据库实例启动,和数据库实例同步运行,迟于数据库实例关闭。ASM 实例的创建和删除可以用DBCA 工具来操作。在DBCA的第一个界面选择配置自动存储管理就可以进入ASM配置的界面。
根据提示运行脚本就可以配置和启动CSS(Cluster Synchronization Service)了,注意要以root的身份运行这个脚本,运行情况如下:
# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add
/etc/oracle does not exist. Creating it now.
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
Adding to inittab
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
Expecting the CRS daemons to be up within 600 seconds.
CSS is active on these nodes.
s1
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
ASM可以使用裸设备或者ASMLib方式, 因为裸设备的维护更罗嗦一些,本文只讨论ASMLib方式。为了在Linux系统中使用ASMLib方式准备ASM磁盘,需要安装相关的软件,下载链接如下:

www.oracle.com/...x.html
下载时注意选择自己的操作系统和内核的版本,我下载到的是以下三个软件:
oracleasm-2.6.18-164.el5-2.0.5-1.el5.i686.rpm
oracleasmlib-2.0.4-1.el5.i386.rpm
oracleasm-support-2.1.4-1.el5.i386.rpm
这里特别需要注意第一个软件要和你的Linux内核的版本一致。(其实我的内核版本是2.6.18-155.el5,但是在官方网站找不到完全对应的版本,只好使用这个2.6.18-164.el5的版本了,后面会讲怎么解决这个问题。)接下来进行软件的安装,只需要使用rpm命令即可。

# rpm -ivh oracleasm*
现在安装oracleasm模块可能会报错,......余下全文>>
 

oracle rac 一般要是在生产上安装的话是用ASM还是裸设备

11g已经不再支持裸设备,oracle正在逐步强制使用asm,当然文件系统始终支持
 

www.htsjk.Com true http://www.htsjk.com/shujukunews/2973.html NewsArticle ASM下裸设备的路径更改是否会影响数据库的运行,asm会影响 通过asm来存储数据库文件,在linux下可以通过asmlib的方式来管理块设备,也可以直接使用裸设备来建立asm磁盘。在asmlib方式下...
评论暂时关闭