一、安装配置先决条件
1,安装oracleasm支持包
http://www.oracle.com/technology/software/tech/linux/asmlib/rhel5.html
http://www.oracle.com/technology/tech/linux/asmlib/index.html
驱动下载地址:http://www.oracle.com/technology/software/tech/linux/asmlib /rhel5.html
创建asm数据库,首先需要ASMLib驱动程序包,可以从相关的网站下载到和操作系统对应的rpm文件,分别为oracleasm-support- 2.0.3-1、oracleasm-2.6.18-8.el5- 2.0.4-1.el5、oracleasmlib-2.0.3-1.el5。
# rpm -Uvh oracleasm*.rpm
# rpm -qa|grep oracleasm
oracleasm-support-2.0.3-1
oracleasm-2.6.18-8.el5-2.0.4-1.el5
oracleasmlib-2.0.3-1.el5
[root@RHEL5 Desktop]# rpm -Uhv oracleasmlib-2.0.4-1.el5.i386.rpm
error: Failed dependencies:
oracleasm >= 1.0.4 is needed by oracleasmlib-2.0.4-1.el5.i386
[root@RHEL5 Desktop]#
My kernel version is:
[root@RHEL5 Desktop]# uname -rn
RHEL5.3 2.6.18-164.el5
1. 先安装 oracleasm-support-2.1.3-1.el5.i386.rpm
2. 再直接运行 [root@RHEL5 ~]# oracleasm update-driver
系统自动查找驱动程序,运行过程显示如下:
[root@Rm-DevDB ~]# oracleasm update-driver
Kernel: 2.6.18-194.3.1.el5 x86_64
Driver name: oracleasm-2.6.18-194.3.1.el5
Latest version: oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5.x86_64.rpm
Installing driver...
warning: /tmp/oracleasm.M21786/oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:oracleasm-2.6.18-194.3.########################################### [100%]
Driver installed successfully
[root@Rm-DevDB dhj]# rpm -qa|grep oracleasm
oracleasm-support-2.1.3-1.el5
oracleasm-2.6.18-194.3.1.el5-2.0.5-1.el5
[root@Rm-DevDB dhj]#
[root@Rm-DevDB dhj]# rpm -Uvh oracleasmlib-2.0.4-1.el5.x86_64.rpm
warning: oracleasmlib-2.0.4-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
添加一块磁盘并格式化。如果sdb比较大,分区的时候可以留一些空间,分一部分空间给sdb1。
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 1044.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1044, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1044, default 1044):
Using default value 1044
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
# fdisk -l
Disk /dev/sda: 17.1 GB, 17179869184 bytes
255 heads, 63 sectors/track, 2088 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 2088 16667437+ 8e Linux LVM
Disk /dev/sdb: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 1044 8385898+ 83 Linux
4.配置rawdevices
因为rh5中取消了rawdevices服务,要使用裸设备创建asm,需要做以下配置。
# vi /etc/udev/rules.d/60-raw.rules
添加以下部分的内容
ACTION=="add", KERNEL=="sdb1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", ENV{MAJOR}=="8", ENV{MINOR}=="1", RUN+="/bin/raw /dev/raw/raw2 %M %m"
# start_udev
Starting udev: [ OK ]
5,.配置oracleasm
以root用户登陆,执行
# /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) [y]:
Fix permissions of Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks:
[ OK ]
以上操作将加载oracleasm.o驱动,并且mount上ASM文件系统,同时我们可以通过以下命令来手工的卸载和加载ASMLib
#/etc/init.d/oracleasm disable //出错检查/var/log/messages文件,确认需要更新的内核版本
#/etc/init.d/oracleasm enable
6,添加init文件使系统启动时自动加载ASMLib
$su -
#cd /etc/rc3.d
#ln -s ../init.d/oracleasm S99oracleasm
#ln -s ../init.d/oracleasm K01oracleasm
注意:如果系统启动是自动进入图形界面,也就是系统的init level是5,那么上面生成链接的命令应该在/etc/rc5.d目录中操作
重新启动系统,确认ASMLib已经可以自动加载
#lsmod |grep oracleasm
#dmesg |grep oracleasm
7,创建ASM磁盘(说明:createdisk 是针对分区,不是针对磁盘,即:先应将磁盘分区)
#/etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
#/etc/init.d/oracleasm createdisk VOL2 /dev/sdc1
...
...
#/etc/init.d/oracleasm listdisks //列出ASM磁盘
VOL1
VOL2
VOL3
VOL4
如果要删除ASM磁盘通过以下命令
#/etc/init.d/oracleasm deletedisk VOL4
注意:
如果是在RAC环境中的某一个节点中添加了ASM磁盘,那么需要在其他的节点上运行scandisk来获取这种变化
#/etc/init.d/oracleasm scandisks
OK,现在已经完成了创建ASM实例的物理基础,下面开始安装数据库
# /etc/init.d/oracleasm createdisk VOL1 /dev/sdb1
Marking disk "/dev/sdb1" as an ASM disk: [ OK ]
#
# /etc/init.d/oracleasm listdisks
VOL1
# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:
[ OK ]
如果ASM已经被配置了
View the contents of the oratab file to determine whether an ASM instance i
configured on the system:
# more /etc/oratab
If an ASM instance is configured on the system, then the oratab file should
contain a line similar to the following:
+ASM:oracle_home_path:N
In this example, +ASM is the system identifier (SID) of the ASM instance and
oracle_home_path is the Oracle home directory where it is installed. By
convention, the SID for an ASM instance begins with a plus sign.
二、使用DBCA创建ASM数据库过程
1,利用dbca建库时,需要运行脚本,注意是root用户,但环境变量是oracle
[root@dbsvr 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.
dbsvr
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
建库时报ora-12547错误,需要安装如下包:
[root@dbsvr tmp]# rpm -qa|grep libaio
libaio-0.3.105-2
libaio-0.3.105-2
libaio-devel-0.3.105-2
2,安装Oracle
接下来,创建ASM数据库的工作就非常的简单了。执行dbca实用程序,在第六步“storage options”部分选择“Automatic Storage Management ”,在接下来的“ASM Disk Groups”步骤中,选择之前创建的“DGROUP1”,再按照普通建库的方式完成数据库的创建就OK了。
在DBCA创建磁盘组过程中,找不到ASM硬盘解决方法:
磁盘组名称
输入磁盘组名称,如 DATA1。
冗余
- High 镜像数据两次。
- Normal 镜像数据一次。
- External 不镜像 ASM 中的数据。如果外部 RAID 阵列提供冗余,则通常使用此选项。
选择成员磁盘
必须手动指示 ASM 到什么地方查找 ASMLib 磁盘,因此,单击 Change Disk Discovery Path
- 弹出一个窗口,提示输入磁盘发现路径。如下所示将磁盘发现路径更改为“ORCL:*”。如果还找不到使用绝对路径 '/dev/oracleasm/disks/*'
- 单击 OK 继续。
- 您将返回到 Select Member Disks 窗口。您的所有 ASMLib 磁盘现在应显示在此窗口中。
单击该行开头的框,选择加入磁盘组的磁盘。完成后单击 OK。
您将返回到 Select Member Disks 窗口。您的所有 ASMLib 磁盘现在应显示在此窗口中。
单击该行开头的框,选择加入磁盘组的磁盘。完成后单击 OK。
这个时候如果还发现不了 硬盘,可以使用RAW
Add Disks: Enter /dev/raw as the disk recovery path. You can also clisk
Disk Recovery Path and enter the required disk recovery path in the dialog
box and clisk OK.
3,,ora-15031 DBCA找不到ASM磁盘组解决方法:
使用DBCA创建数据库,使用ASM存储。ASM实例已经创建,但是在创建磁盘组窗口,无法找到已经创建的ASM磁盘组。ORACLEASM显示正常。
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm status
Checking if ASM is loaded: [ OK ]
Checking if /dev/oracleasm is mounted: [ OK ]
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
VOL5
[yangwenchao@yangwenchao ~]$ /etc/init.d/oracleasm scandisks
Scanning system for ASM disks:
请问怎样才能添加上ASM磁盘组?
#/etc/init.d/oracleasm createdisk VOL1 /dev/sdb
#/etc/init.d/oracleasm createdisk VOL2 /dev/sdc
#/etc/init.d/oracleasm createdisk VOL3 /dev/sdd
#/etc/init.d/oracleasm createdisk VOL4 /dev/sde
#/etc/init.d/oracleasm createdisk VOL5 /dev/sdf
解决方法一
[root@racdb1 ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@racdb1 disks]# /etc/init.d/oracleasm status
Checking if ASM is loaded: [ OK ]
Checking if /dev/oracleasm is mounted: [ OK ]
注意mount在 /dev/oracleasm
创建的时候路径要用全部路径(绝对路径)同时要要看
*.asm_diskgroups='ORACLE','dgtest' -----这个地方要经常更改
*.asm_diskstring='/dev/oracleasm/disks/VOL*' -----特别要注意这个地方
*.background_dump_dest='/u01/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/u01/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u01/app/oracle/admin/+ASM/udump'
SQL> create diskgroup dgtest1 normal redundancy
2 failgroup dgtest_0001 disk '/dev/oracleasm/disks/VOL4' name dgtest_0003
3 failgroup dgtest_0002 disk '/dev/oracleasm/disks/VOL5' name dgtest_0004;
Diskgroup created.
解决方法二
修改$ORACLE_HOME/dbs/init+ASM.ora文件
添加一行:asm_diskstring='ORCL:VOL*'
启动实例
报错,ORA-29701: unable to connect to Cluster Manager
查google,查不到
再查metalink,原来是因为安装完10g以后,就直接把/etc/inittab中的
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 这句注释了
原来这就是10g内置的cluster manager
取消注释
重新启动系统
再次启动实例,OK
三、手工创建ASM实例
1.创建初始化文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ vi init+ASM.ora
*.asm_diskstring='ORCL:VOL*'
*.background_dump_dest='/oracle/admin/+ASM/bdump'
*.core_dump_dest='/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/oracle/admin/+ASM/udump'
如果找不到磁盘还 改成绝对路径
#+ASM.asm_diskgroups='ASMDISK'#Manual Mount
#*.asm_diskstring='ORCL:VOL*'
#*.asm_diskgroups='ASMDISK'
*. asm_diskstring='/dev/oracleasm/disks/*'
*.background_dump_dest='/opt/app/oracle/admin/+ASM/bdump'
*.core_dump_dest='/opt/app/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
2.创建密码文件
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ orapwd file=orapw+ASM password=dba
3. 创建目录结构
$ su – oracle
$ cd $ORACLE_HOME/dbs
$ mkdir –p $ORALCE_BASE/admin/+ASM/udump
$ mkdir –p $ORALCE_BASE/admin/+ASM/bdump
$ mkdir –p $ORALCE_BASE/admin/+ASM/cdump
4. 启动实例
$ export ORACLE_SID=+ASM
$ sqlplus / as sysdba
SQL> startup
ASM instance started
Total System Global Area 100663296 bytes
Fixed Size 777616 bytes
Variable Size 99885680 bytes
Database Buffers 0 bytes
Redo Buffers 0 bytes
ORA-15110: no diskgroups mounted
因为我们是首次启动asm实例,还没有创建diskgroup,所以显示15110错误是正常的。
如果启动实例的时候碰到如下报错:
ORA-29701: unable to connect to Cluster Manager
那么请检查/etc/inittab 文件,看看是否有下面这行
h1:35:respawn:/etc/init.d/init.cssd run >/dev/null 2>&1 </dev/null
如果没有请添加,如果被注释了请取消注释。
5. 创建 spfile,重新启动
SQL> create spfile from pfile;
SQL> shutdown immediate;
SQL> startup;
6. 创建 diskgroup
SQL> create diskgroup dgroup1 external redundancy
2 failgroup fgroup1 disk 'ORCL:VOL1';
Diskgroup created.
SQL> col name for a10
SQL> select name,state from v$asm_diskgroup;
NAME STATE
---------- ----------------------
DGROUP1 MOUNTED
如果上述命令返回的 state是 DISMOUNTED,那么我们需要手工将挂载 diskgroup
SQL> ALTER DISKGROUP dgroup1 MOUNT;
Diskgroup altered.
SQL> show parameter asm_diskgroups
NAME TYPE VALUE
------------------------------------ ---------- ------------------------------
asm_diskgroups string DGROUP1
四、ASM database简单管理
开机启动:
[oracle@asm dbs]$ lsnrctl start
[oracle@asm dbs]$ export ORACLE_SID=+ASM
[oracle@asm dbs]$ echo $ORACLE_SID
+ASM
[oracle@asm dbs]$ sqlplus / as sysdba
SQL>startup
[oracle@asm dbs]$ export ORACLE_SID=eagle
[oracle@asm dbs]$ echo $ORACLE_SID
eagle
SQL>startup
关机停止:
[oracle@asm dbs]$ export ORACLE_SID=+ASM
[oracle@asm dbs]$ echo $ORACLE_SID
+ASM
[oracle@asm dbs]$ sqlplus / as sysdba
SQL>shutdown immediate
[oracle@asm dbs]$ export ORACLE_SID=eagle
[oracle@asm dbs]$ echo $ORACLE_SID
eagle
SQL>shutdown immediate
附录:
1,安装好ASM后,启动ASM数据的过程
启动ASM 数据库的步骤
由于启动ASM 数据库必须要先启动ASM 实例,所以基本上启动步骤如下。
1. 以oracle 用户进入操作系统
2. $ export ORACLE_SID=+ASM //ORACLE_SID一定要大写。
3. SQL> sqlplus / as sysdba
4. SQL> startup
5. SQL> exit
6. $ export ORACLE_SID=<your_real_db_sid>
7. SQL> sqlplus / as sysdba
8. SQL> startup
需要重新启动2遍
2,远程连接ASM数据配置listener.ora的情况
listener.ora 这个文件的配置
服务器端的配置
[oracle@rs2600-2 admin]$ vi listener.ora
# listener.ora Network Configuration File: /opt/app/oracle/product/10.2.0/server/network/admin/listener.ora
# Generated by Oracle configuration tools.
LSNRASM =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs2600-2)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = +ASM)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(SID_NAME = +ASM)
)
(SID_DESC =
(GLOBAL_DBNAME = danghj)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(SID_NAME = danghj)
)
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = rs2600-2)(PORT = 1521))
)
)
客户端的配置
ASM_172.22.11.124 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 172.22.11.124)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = danghj)
)
)
3,Oracle 中删除 ASM 实例
删除自动存储管理实例+ASM实例+ASM的删除是在数据库被卸载之后完成的,并删除/ORACLE_HOME/dbs目录下的所有文件(除了 与ASM相关的)。因此必须完成下列步骤:
4.1在命令提示符中,设置oracle_sid环境变量为+ASM实例:
# export oracle_sid=+ASM
4.2启动SQL*Plus并以sys用户连接到自动存储管理+ASM实例:
# sqlplus / as sysdba
4.3使用下列命令来确定是否有数据库实例正在使用自动存储管理实例+ASM:
SQL>select instance_name from v$asm_client;
该命令结果列出所有正在运行并使用+ASM实例的数据库实例。只要+ASM包含正在支持的数据库实例,就不能删除该+ASM实例。(其实可以先 shutdown对应的数据库实例,然后从asmcmd进入磁盘组所在目录,删掉对应的数据库目录和文件就可以了)。
4.4 如果没有与+ASM相关联的数据库实例,则删除与该实例相关联的磁盘组。
首先,识别与+ASM相关联的磁盘组:
SQL>select name from v$asm_diskgroup;
其次,用下列命令删除每个要删除的磁盘组:
SQL>drop diskgroup<disk_group_name>including contents;
4.5 关闭+ASM实例并退出SQL*Plus:
SQL>shutdown
SQL>exit
4.6 在命令提示符中输入下列命令,删除+ASM服务(我没找到这个命令,所以没有运行):
oradim -delete -asmsid +ASM
4,到ASM磁盘输入sys密码连接不上,显示网络问题
需要启动istener就可以了