听说ASM很长时间了,却一直没有条件来配置学习一下,今天看到一篇文档( [url]https://metalink.oracle.com/metalink/plsql/f?p=130:14:4520376557271601272::::p14_database_id[/url],p14_docid,p14_show_header,p14_show_help,p14_black_frame,p14_font:NOT,266028.1,1,1,1,helvetica),说可以用文件来模拟分区,很感兴趣,下面记录了在文件分区上安装ASM的过程:
1、ASM相关软件下载
从网址 [url]http://www.oracle.com/technology/software/tech/linux/asmlib/rhel4.html[/url]下载相关软件,主要包括三个文件,我的环境是32位的Linux AS4 2.6.9-22.ELsmp,下载的文件为:
oracleasm-support-2.0.3-1.i386.rpm
oracleasm-2.6.9-22.ELsmp-2.0.3-1.i686.rpm
oracleasmlib-2.0.2-1.i386.rpm
2、安装
rpm包的安装很简单:
[root@localhost ~]# rpm -Uvh oracleasm-support-2.0.3-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [100%]
[[root@localhost ~]# rpm -Uvh oracleasm-2.6.9-22.ELsmp-2.0.3-1.i686.rpm
Preparing... ########################################### [100%]
1:oracleasm-2.6.9-22.ELsm########################################### [100%]
[root@localhost ~]# rpm -Uvh oracleasmlib-2.0.2-1.i386.rpm
Preparing... ########################################### [100%]
1:oracleasmlib ########################################### [100%]
3、配置
[root@localhost ~]# /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
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": Unable to load module "oracleasm"
[FAILED]
此时出现了一个错误,安装失败,网上说要么是文件下载错误,要么是没有关闭SElinux。首先查看
/lib/modules/2.6.9-22.ELsmp/kernel/drivers/addon/oracleasm目录下是否有
oracleasm.ko文件,如果有,证明安装没有问题,我的环境下测试没有问题:
[root@localhost ~]# ls /lib/modules/2.6.9-22.ELsmp/kernel/drivers/addon/oracleasm
oracleasm.ko
然后查看/etc/SElinux/config中的
SELINUX=enforcing -----> SELINUX=disabled
需要将配置改为disabled,然后重启服务器,如果不想重启,可以执行如下命令:
[root@localhost selinux]# setenforce 0
[root@localhost selinux]#
再次配置asm:
[root@localhost selinux]# setenforce 0
[root@localhost selinux]#
[root@localhost selinux]#
[root@localhost selinux]# /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 ]
[root@localhost selinux]# /etc/init.d/oracleams disable
bash: /etc/init.d/oracleams: No such file or directory
[root@localhost selinux]# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: [ OK ]
Unmounting ASMlib driver filesystem: [ OK ]
Unloading module "oracleasm": [ OK ]
4、disable和enable ORACLE ASM
如果要卸载ASM,用以下命令
[root@localhost selinux]# /etc/init.d/oracleams disable
bash: /etc/init.d/oracleams: No such file or directory
[root@localhost selinux]# /etc/init.d/oracleasm disable
Writing Oracle ASM library driver configuration: [ OK ]
Unmounting ASMlib driver filesystem: [ OK ]
Unloading module "oracleasm": [ OK ]
重新装载则相反:
[root@localhost selinux]# /etc/init.d/oracleasm enable
Writing Oracle ASM library driver configuration: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
[root@localhost selinux]# cd
5、用dd创建空文件:
A52>dd if=/dev/zero of=_file_disk1 bs=1k count=100000
100000+0 records in
100000+0 records out
A52>dd if=/dev/zero of=_file_disk2 bs=1k count=100000
100000+0 records in
100000+0 records out
A52>ls -ltr
total 1291560
drwxr-xr-x 3 oracle oracle 4096 Aug 15 2003 product
-rw-r--r-- 1 oracle oracle 1058810367 Feb 3 2006 product1
drwxrwxr-x 3 oracle oracle 4096 Feb 5 2006 oradata1
drwxrwxr-x 7 oracle oracle 4096 Feb 8 2006 bak
drwxrwxr-x 2 oracle oracle 4096 Feb 8 2006 restore
-rw-rw-r-- 1 oracle oracle 87912 Mar 4 2006 report_2_3.lst
-rw-rw-r-- 1 oracle oracle 101981 Mar 4 2006 report_1_2.lst
-rw-rw-r-- 1 oracle oracle 90339 Mar 4 2006 report_3_4.lst
-rw-rw-r-- 1 oracle oracle 97867 Mar 4 2006 report_4_5.lst
-rw-r--r-- 1 oracle oracle 20765492 Mar 20 2006 deluser.sql.bak
-rw-r--r-- 1 oracle oracle 15457072 Mar 20 2006 deluser.sql
-rwxrwxr-x 1 oracle oracle 65 Mar 20 2006 deluser.sh
-rw------- 1 oracle oracle 20872970 Mar 20 2006 nohup.out
drwxrwxr-x 4 oracle oracle 4096 May 9 2006 admin
-rw-rw-r-- 1 oracle oracle 28 Feb 10 11:59 1.sql
-rw-rw-r-- 1 oracle oracle 144 Feb 10 12:04 2.sql
-rw-rw-r-- 1 oracle oracle 104 Feb 10 15:11 3.sql
drwxrwxr-x 5 oracle oracle 4096 Feb 10 16:52 oradata
-rw-rw-r-- 1 oracle oracle 102400000 Mar 24 18:45 _file_disk1
-rw-rw-r-- 1 oracle oracle 102400000 Mar 24 18:45 _file_disk2
6、创建loop分区:
[root@localhost ~]# losetup /dev/loop1 /home/oracle/_file_disk1
[root@localhost ~]# losetup /dev/loop2 /home/oracle/_file_disk2
7、创建、查看磁盘
[root@localhost ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/loop1
Marking disk "/dev/loop1" as an ASM disk: [ OK ]
[root@localhost ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/loop2
Marking disk "/dev/loop2" as an ASM disk: [ OK ]
[root@localhost ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@localhost ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
[root@localhost ~]# /etc/init.d/oracleasm querydisk /dev/loop1
Disk "/dev/loop1" is marked an ASM disk with the label "VOL1"
[root@localhost ~]# /etc/init.d/oracleasm querydisk /dev/loop2
Disk "/dev/loop2" is marked an ASM disk with the label "VOL2"
7、配置asm实例参数
[zzx@localhost dbs]$ more initasm.ora
*.instance_type='asm'
*.background_dump_dest='/home/zzx/admin/db1/asm/bdump'
*.core_dump_dest='/home/zzx/admin/db1/asm/cdump'
*.user_dump_dest='/home/zzx/admin/db1/asm/udump'
*.asm_diskstring='ORCL:VOL*'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
8、启动asm实例
set ORACLE_SID=asm
[zzx@localhost dbs]$ sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Mon Mar 31 12:11:42 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORA-29701: unable to connect to Cluster Manager
此时,出现了未能连接到集群管理器的提示
网上查,需要启动css服务,启动方法为:
$ORACLE_HOME/bin/localconfig add
但是执行的时候,出现如下错误:
[root@localhost lib]# /home/zzx/product/10.2.0/db_1/bin/localconfig add
/home/zzx/product/10.2.0/db_1/bin/crsctl.bin: error while loading shared libraries: libclntsh.so.10.1: cannot open shared object file: No such file or directory
/home/zzx/product/10.2.0/db_1/bin/clscfg.bin: error while loading shared libraries: libuini10.so: cannot open shared object file: No such file or directory
查询系统下$ORACLE_HOME/lib下,发现libclntsh.so.10.1和libuini10.so都存在,而且localconfig 中的配置也正确:
。。。
SILENT=%s_silent%
CSS_ORACLE_HOME=/home/zzx/product/10.2.0/db_1
CSS_ORACLE_OWNER=zzx
CSS_DBA_GROUP=oinstall
CSS_LANGUAGE_ID=AMERICAN_AMERICA.WE8ISO8859P1
经过反复检查,终于发现是localconfig 中调用的几个文件里面的ORACLE_HOME参数设置不对(oracle安装是tar过来的,看来tar的弊病还是很多的),调试修改后,重新执行localconfig add命令,结果如下:
[root@localhost dbs]# localconfig add
$CRSCTL /home/zzx/product/10.2.0/db_1/bin/crsctl
$CSS_ORACLE_OWNER zzx
LD_LIBRARY_PATH is: /home/zzx/product/10.2.0/db_1/lib
/home/zzx/product/10.2.0/db_1/bin/crsctl.bin: /home/zzx/product/10.2.0/db_1/lib/libstdc++.so.5: version `CXXABI_1.2' not found (required by /home/zzx/product/10.2.0/db_1/bin/crsctl.bin)
/home/zzx/product/10.2.0/db_1/bin/crsctl.bin: /home/zzx/product/10.2.0/db_1/lib/libstdc++.so.5: version `GLIBCPP_3.2' not found (required by /home/zzx/product/10.2.0/db_1/bin/crsctl.bin)
613
620
Successfully accumulated necessary OCR keys.
Creating OCR keys for user 'root', privgrp 'root'..
Operation successful.
Configuration for local CSS has been initialized
630
Adding to inittab
/etc/init.d/init.cssd: line 509: /etc/oracle/scls_scr/localhost/root/cssrun: No such file or directory
Startup will be queued to init within 90 seconds.
Checking the status of new Oracle init process...
LD_LIBRARY_PATH is: /home/zzx/product/10.2.0/db_1/lib
/home/zzx/product/10.2.0/db_1/bin/crsctl.bin: /home/zzx/product/10.2.0/db_1/lib/libstdc++.so.5: version `CXXABI_1.2' not found (required by /home/zzx/product/10.2.0/db_1/bin/crsctl.bin)
/home/zzx/product/10.2.0/db_1/bin/crsctl.bin: /home/zzx/product/10.2.0/db_1/lib/libstdc++.so.5: version `GLIBCPP_3.2' not found (required by /home/zzx/product/10.2.0/db_1/bin/crsctl.bin)
Giving up: Oracle CSS stack appears NOT to be running.
Oracle CSS service would not start as installed
Automatic Storage Management(ASM) cannot be used until Oracle CSS service is started
看来,oracle的库文件还是有问题
搜索了n长时间,终于从以下网站下载了需要的包compat-libstdc++-33-3.2.3-56.fc5.i386.rpm:
[url]http://download.fedora.redhat.com/pub/fedora/linux/core/updates/5/i386/[/url]
[root@localhost ~]# rpm -ivh compat-libstdc++-33-3.2.3-56.fc5.i386.rpm
warning: compat-libstdc++-33-3.2.3-56.fc5.i386.rpm: V3 DSA signature: NOKEY, key ID 4f2a6fd2
Preparing... ########################################### [100%]
compat-libstdc++-33 ########################################### [100%]