温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

怎么在RedHat AS3上安装ASM

发布时间:2021-09-01 11:44:59 来源:亿速云 阅读:155 作者:chen 栏目:云计算

本篇内容主要讲解“怎么在RedHat AS3上安装ASM”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么在RedHat AS3上安装ASM”吧!

==操作系统版本
[root@TCLUX3245 root]# uname -a
Linux TCLUX3245 2.4.21-47.0.1.ELsmp #1 SMP Fri Oct 13 17:56:20 EDT 2006 i686 i686 i386 GNU/Linux

==去oracle网站下载相应的rpm包,其中oracleasm-2.4.21-47.0.1.ELsmp-1.0.5-1.i686.rpm 要跟根据#uname -r结果一致,其余两个包个版本之间通用。地址:http://www.oracle.com/technology/tech/linux/asmlib/index.html
[root@TCLUX3245 root]# uname -r
2.4.21-47.0.1.ELsmp

[root@TCLUX3245 asm_lib]# pwd
/10ginstaller/asm_lib
[root@TCLUX3245 asm_lib]# ls -l
total 136
-rw-r--r--    1 root     root        94176 Mar 28 23:42 oracleasm-2.4.21-47.0.1.ELsmp-1.0.5-1.i686.rpm
-rw-r--r--    1 oracle   dba         13638 Mar 28 00:46 oracleasmlib-2.0.2-1.i386.rpm
-rw-r--r--    1 oracle   dba         22402 Mar 28 00:46 oracleasm-support-2.0.3-1.i386.rpm

==安装包,中间不能有报错,否则在配置系统reboot后自动启动ASM kernel module时会出错(Loading module "oracleasm": Unable to load module "oracleasm"  [FAILED]')。其原因多半是因为oracleasm-2.4.21-47.0.1.ELsmp-1.0.5-1.i686.rpm没有下载对,卸载后重新安装正确的rpm包就可以解决。
[root@TCLUX3245 asm_lib]# rpm -ivh *.rpm
......
......

==配置system reboot后自动启动ASM kernel module
[root@TCLUX3245 asm_lib]# /etc/init.d/oracleasm configure
Default user to own the driver interface []: oracle
Default group to own the driver interface []: oinstall
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": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]

==在unix/linux中,所有设备都是文件,所以我们可以建几个文件来模拟多块硬盘。先用dd建若干个文件,大小为1G
root@TCLUX3245 dev]# mkdir /asmdisks
[root@TCLUX3245 dev]# dd if=/dev/sda2 of=/asmdisks/disk1 bs=1024k count=1000
dd if=/dev/sda2 of=/asmdisks/disk2 bs=1024k count=1000
dd if=/dev/sda2 of=/asmdisks/disk3 bs=1024k count=1000
dd if=/dev/sda2 of=/asmdisks/disk4 bs=1024k count=1000
dd if=/dev/sda2 of=/asmdisks/disk5 bs=1024k count=1000

==用losetup命令,使这些文件在linux看来是某个存储设备
[root@TCLUX3245 dev]# /sbin/losetup /dev/loop1 /asmdisks/disk1
/sbin/losetup /dev/loop2 /asmdisks/disk2
/sbin/losetup /dev/loop3 /asmdisks/disk3
/sbin/losetup /dev/loop4 /asmdisks/disk4
/sbin/losetup /dev/loop5 /asmdisks/disk5

==运行oracleasm命令,使这些存储设备变成asm的备用盘
root@TCLUX3245 asm_lib]# /etc/init.d/oracleasm createdisk ASMD1 /dev/loop1
Marking disk "/dev/loop1" as an ASM disk:                  [  OK  ]
/etc/init.d/oracleasm createdisk ASMD2 /dev/loop2
/etc/init.d/oracleasm createdisk ASMD3 /dev/loop3
/etc/init.d/oracleasm createdisk ASMD4 /dev/loop4
/etc/init.d/oracleasm createdisk ASMD5 /dev/loop5


******[root@TCLUX3245 bin]# pwd
******/ddms01/dms/oracle/10.2.0/bin
******[root@TCLUX3245 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.
******        tclux3245
******CSS is active on all nodes.
******Oracle CSS service is installed and running under init(1M)


==编辑asm init文件
[oracle@TCLUX3245 dbs]$ cat init+ASM.ora
INSTANCE_TYPE=ASM
DB_UNIQUE_NAME=+ASM
LARGE_POOL_SIZE=8M
ASM_DISKSTRING='ORCL:*'

==启动ASM Instance,并创建disk group
[oracle@TCLUX3245 dbs]$ export ORACLE_SID=+ASM
[oracle@TCLUX3245 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 16:07:05 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL>
SQL> startup nomount
ASM instance started

Total System Global Area   79691776 bytes
Fixed Size                  1217812 bytes
Variable Size              53308140 bytes
ASM Cache                  25165824 bytes
SQL> create diskgroup DGROUP1 normal redundancy disk 'ORCL:ASMD1','ORCL:ASMD2','ORCL:ASMD3','ORCL:ASMD4','ORCL:ASMD5';
Diskgroup created.


SQL> col path format a20
SQL> select path,mount_status from v$asm_disk

PATH                 MOUNT_S
-------------------- -------
ORCL:ASMD1           CACHED
ORCL:ASMD2           CACHED
ORCL:ASMD3           CACHED
ORCL:ASMD4           CACHED
ORCL:ASMD5           CACHED

SQL> shutdown
ASM diskgroups dismounted

==在init+ASM.ora中加入一行ASM_DISKGROUPS='DGROUP1',这样asm instance就可以直接启动了
INSTANCE_TYPE=ASM
DB_UNIQUE_NAME=+ASM
LARGE_POOL_SIZE=8M
ASM_DISKSTRING='ORCL:*'
ASM_DISKGROUPS='DGROUP1'


SQL> shutdown
ASM diskgroups dismounted
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area   79691776 bytes
Fixed Size                  1217812 bytes
Variable Size              53308140 bytes
ASM Cache                  25165824 bytes
ASM diskgroups mounted


==把创建asm备用磁盘的那些命令加到/etc/rc.local文件里,这样每次系统reboot后,那些/asmdisks/diski文件就自动变成asm备用磁盘了。
[root@TCLUX3245 etc]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

/sbin/losetup /dev/loop1 /asmdisks/disk1
/sbin/losetup /dev/loop2 /asmdisks/disk2
/sbin/losetup /dev/loop3 /asmdisks/disk3
/sbin/losetup /dev/loop4 /asmdisks/disk4
/sbin/losetup /dev/loop5 /asmdisks/disk5

/etc/init.d/oracleasm createdisk ASMD1 /dev/loop1
/etc/init.d/oracleasm createdisk ASMD2 /dev/loop2
/etc/init.d/oracleasm createdisk ASMD3 /dev/loop3
/etc/init.d/oracleasm createdisk ASMD4 /dev/loop4
/etc/init.d/oracleasm createdisk ASMD5 /dev/loop5


======================================================
自此,完成了ASM instance和ASM diskgroup的创建,并且每次系统重启后ASM diskgroup都会自动创建。下面创建数据库。
======================================================

==创建initSID.ora文件
[oracle@TCLUX3245 dbs]$ pwd
/ddms01/dms/oracle/10.2.0/dbs

[oracle@TCLUX3245 dbs]$ cat initO01DMS0.ora
db_name=O01DMS0
sga_target=256M
db_create_file_dest=+DGROUP1

==创建spfile和数据库
[oracle@TCLUX3245 dbs]$ echo $ORACLE_SID
O01DMS0
[oracle@TCLUX3245 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 18:05:00 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area  268435456 bytes
Fixed Size                  1218868 bytes
Variable Size              88082124 bytes
Database Buffers          171966464 bytes
Redo Buffers                7168000 bytes

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /ddms01/dms/oracle/10.2.0/dbs/
                                                 spfileO01DMS0.ora
SQL> create database;

Database created.

SQL> create temporary tablespace TEMP;

Tablespace created.

SQL> create undo tablespace UNDOTBS1;

Tablespace created.

SQL> @?/rdbms/admin/catalog.sql
.......
SQL> @?/rdbms/admin/catproc.sql
......

SQL> alter database default temporary tablespace TEMP;

Database altered.

SQL> alter system set undo_tablespace=UNDOTBS1 scope=spfile;

System altered.

SQL> alter system set undo_management=AUTO scope=spfile;

System altered.

SQL> startup force
ORACLE instance started.

Total System Global Area  268435456 bytes
Fixed Size                  1218868 bytes
Variable Size              96470732 bytes
Database Buffers          163577856 bytes
Redo Buffers                7168000 bytes
Database mounted.
Database opened.

SQL> select file_name,bytes/1024/1024 MB from dba_data_files;

FILE_NAME                                                  MB
-------------------------------------------------- ----------
+DGROUP1/o01dms0/datafile/system.259.618516577            200
+DGROUP1/o01dms0/datafile/sysaux.260.618516593            100
+DGROUP1/o01dms0/datafile/undotbs1.262.618516647          100

SQL>  select file_name,bytes/1024/1024 MB from dba_temp_files;

FILE_NAME                                                  MB
-------------------------------------------------- ----------
+DGROUP1/o01dms0/tempfile/temp.261.618516635              100

SQL> select a.group#,MEMBER,bytes/1024/1024 MB from v$logfile a,v$log b
  2  where a.group#=b.group#;

    GROUP# MEMBER                                                     MB
---------- -------------------------------------------------- ----------
         1 +DGROUP1/o01dms0/onlinelog/group_1.257.618516495          100
         2 +DGROUP1/o01dms0/onlinelog/group_2.258.618516537          100

SQL> select BLOCK_SIZE*FILE_SIZE_BLKS from v$controlfile;

BLOCK_SIZE*FILE_SIZE_BLKS
-------------------------
                  6062080
                 
==datafile, redo log file, control file一共所占空间为 705.78125MB                
SQL> select 200+100+100+100+100+100+6062080/1024/1024 MB  from dual;

        MB
----------
 705.78125

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@TCLUX3245 oracle]$ export ORACLE_SID=+ASM
[oracle@TCLUX3245 oracle]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Mar 30 11:24:22 2007

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options


SQL>  select PATH,MOUNT_STATUS,NAME,TOTAL_MB,FREE_MB from v$asm_disk;

PATH                 MOUNT_S NAME           TOTAL_MB    FREE_MB
-------------------- ------- ------------ ---------- ----------
ORCL:ASMD1           CACHED  ASMD1              1000        673
ORCL:ASMD2           CACHED  ASMD2              1000        675
ORCL:ASMD3           CACHED  ASMD3              1000        675
ORCL:ASMD4           CACHED  ASMD4              1000        676
ORCL:ASMD5           CACHED  ASMD5              1000        675


==DiskGroup中一共使用掉的空间为 1626MB
SQL> select 5*1000-673-675-675-676-675 MB from dual;

MB
--------
   1626


1626MB>2*705.78125MB
注意前面创建diskgroup的脚本
SQL> create diskgroup DGROUP1 normal redundancy disk ...;
其中NORMAL REDUNDANCY: requires the existence of at least two failure groups。每个diskgroup里面的文件都有一份冗余,再加上创建asm备用盘时需要的一些额外空间,就造成了七百多兆文件占用了1.6G的空间。

到此,相信大家对“怎么在RedHat AS3上安装ASM”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI