ASM初探-1

原创 2012年03月29日 20:55:50

本次实验的目的是将单实例Oracle数据用文件系统存储迁移到ASM上,sdc1、sdd1、sde1、sdf1使用这四块盘创建ASM DiskGroup.
安装oracleasm的rpm包
[root@Oracle ~]# ls
anaconda-ks.cfg     oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
Desktop             oracleasmlib-2.0.4-1.el5.x86_64.rpm
install.log         oracleasm-support-2.1.7-1.el5.x86_64.rpm

[root@Oracle ~]# rpm -ivh oracleasm-support-2.1.7-1.el5.x86_64.rpm
warning: oracleasm-support-2.1.7-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-support      ########################################### [100%]
[root@Oracle ~]# rpm -ivh oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm
warning: oracleasm-2.6.18-164.el5-2.0.5-1.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 1e5e0159
Preparing...                ########################################### [100%]
   1:oracleasm-2.6.18-164.el########################################### [100%]
[root@Oracle ~]# rpm -ivh 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%]
[root@Oracle ~]#
 
查看磁盘
[root@Oracle ~]# fdisk -l

Disk /dev/sda: 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/sda1   *         132        1044     7333672+  83  Linux
/dev/sda2               1         131     1052226   82  Linux swap / Solaris

Partition table entries are not in disk order

Disk /dev/sdb: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1          56      449788+  83  Linux
/dev/sdb2              57        2489    19543072+  83  Linux

Disk /dev/sdc: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1         130     1044193+  83  Linux

Disk /dev/sdd: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1         130     1044193+  83  Linux

Disk /dev/sde: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1         130     1044193+  83  Linux

Disk /dev/sdf: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1         130     1044193+  83  Linux

设置asm
[root@Oracle ~]# /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  ]/o

创建asm disk
[root@Oracle ~]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1
Marking disk "VOL1" as an ASM disk: [  OK  ]
[root@Oracle ~]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1
Marking disk "VOL2" as an ASM disk: [  OK  ]
[root@Oracle ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1
Marking disk "VOL3" as an ASM disk: [  OK  ]
[root@Oracle ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sdf1
Marking disk "VOL4" as an ASM disk: [  OK  ]

启动css
[root@Oracle ~]# /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.
        oracle
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

创建asm参数文件
[root@Oracle ~]# cat init+ASM.ora
instance_type=asm
large_pool_size=12m
remote_login_passwordfile=exclusive
asm_diskstring='ORCL:VOL*'
background_dump_dest=/u01/app/oracle/admin/+ASM/bdump
core_dump_dest=/u01/app/oracle/admin/+ASM/cdump
user_dump_dest=/u01/app/oracle/admin/+ASM/udump

[root@Oracle ~]# mv init+ASM.ora /u01/app/oracle/product/10.2.0/db_1/dbs/

创建密码文件
[oracle@Oracle ~]$ orapwd file=orapw+ASM entries=5 password=111
[oracle@Oracle ~]$ export ORACLE_SID=+ASM

[oracle@Oracle ~]$ cd /u01/app/oracle/admin/

[oracle@Oracle ~]$ mkdir +ASM

[oracle@Oracle admin]$ cd +ASM

[oracle@Oracle admin]$ mkdir bdump cdump udump

[oracle@Oracle +ASM]$ ls
bdump  cdump  udump

启动asm instance
[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 19:27:18 2012

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

Connected to an idle instance.

SQL> startup
ASM instance started

Total System Global Area  130023424 bytes
Fixed Size                  2019032 bytes
Variable Size             102838568 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

创建diskgroup
SQL> create diskgroup dg1 external redundancy Disk 'ORCL:VOL1','ORCL:VOL2','ORCL:VOL3';

Diskgroup created.

SQL> create diskgroup RECOVERY EXTERNAL redundancy Disk 'ORCL:VOL4';

Diskgroup created.

对db做backup
[oracle@Oracle ~]$ cat backup.rman
run {
        backup as copy database format '+DG1';
}

[oracle@Oracle ~]$ rman target / cmdfile=/home/oracle/backup.rman log=/home/oracle/backup.log
RMAN> 2> 3> 4>

[oracle@Oracle ~]$ cat backup.log

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Mar 29 19:44:01 2012

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

connected to target database: ORCL (DBID=1306991326)

RMAN> run {
2>      backup as copy database format '+DG1';
3> }
4>
Starting backup at 29-MAR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=145 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf
output filename=+DG1/orcl/datafile/system.258.779226255 tag=TAG20120329T194405 recid=3 stamp=779226277
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf
output filename=+DG1/orcl/datafile/sysaux.259.779226283 tag=TAG20120329T194405 recid=4 stamp=779226292
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf
output filename=+DG1/orcl/datafile/example.260.779226297 tag=TAG20120329T194405 recid=5 stamp=779226302
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf
output filename=+DG1/orcl/datafile/undotbs1.261.779226303 tag=TAG20120329T194405 recid=6 stamp=779226305
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf
output filename=+DG1/orcl/datafile/users.262.779226311 tag=TAG20120329T194405 recid=7 stamp=779226310
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DG1/orcl/controlfile/backup.263.779226315 tag=TAG20120329T194405 recid=8 stamp=779226314
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 29-MAR-12
channel ORA_DISK_1: finished piece 1 at 29-MAR-12
piece handle=+DG1/orcl/backupset/2012_03_29/nnsnf0_tag20120329t194405_0.264.779226317 tag=TAG20120329T194405 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-MAR-12

Recovery Manager complete.

修改db_recovery参数并把日志和数据文件位置指定磁盘组
[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 19:46:31 2012

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


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

SQL> alter system set db_recovery_file_dest_size=10G scope=both;

System altered.

SQL> alter system set db_recovery_file_dest='+RECOVERY' scope=both;

System altered.

SQL> alter system set db_create_file_dest='+DG1' scope=both;

System altered.

SQL> alter system set db_create_online_log_dest_1='+DG1' scope=both;

System altered.

SQL> alter system set db_create_online_log_dest_2='+DG1' scope=both;

System altered.

 把日志迁移到asm磁盘
SQL> select group#,member from v$logfile;

    GROUP#
----------
MEMBER
--------------------------------------------------------------------------------
         3
/u01/app/oracle/oradata/orcl/redo03.log

         2
/u01/app/oracle/oradata/orcl/redo02.log

         1
/u01/app/oracle/oradata/orcl/redo01.log

SQL> alter database add logfile member '+DG1' to group 1;

Database altered.

SQL> alter database add logfile member '+DG1' to group 2;

Database altered.

SQL> alter database add logfile member '+DG1' to group 3;

Database altered.

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> alter database drop logfile member '/u01/app/oracle/oradata/orcl/redo02.log';

Database altered.

SQL> alter database drop logfile member '/u01/app/oracle/oradata/orcl/redo01.log';

Database altered.

SQL> alter database drop logfile member '/u01/app/oracle/oradata/orcl/redo03.log';

Database altered.

检查日志是否迁移到asm中
SQL> select * from v$logfile;

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---
         1         ONLINE
+DG1/orcl/onlinelog/group_1.265.779226735
NO

         2         ONLINE
+DG1/orcl/onlinelog/group_2.266.779226751
NO

    GROUP# STATUS  TYPE
---------- ------- -------
MEMBER
--------------------------------------------------------------------------------
IS_
---

         3         ONLINE
+DG1/orcl/onlinelog/group_3.267.779226759
NO

临时表空间迁移asm
SQL> select ts#,bytes/1024/1024,name from v$tempfile;

       TS# BYTES/1024/1024
---------- ---------------
NAME
--------------------------------------------------------------------------------
         3              22
/u01/app/oracle/oradata/orcl/temp01.dbf

SQL> select ts#,name from v$tablespace;

       TS# NAME
---------- ------------------------------
         0 SYSTEM
         1 UNDOTBS1
         2 SYSAUX
         4 USERS
         3 TEMP
         6 EXAMPLE

6 rows selected.

SQL>

SQL> alter tablespace temp add tempfile size 22m;

Tablespace altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DG1/orcl/tempfile/temp.268.779227399
/u01/app/oracle/oradata/orcl/temp01.dbf

SQL> alter database tempfile '/u01/app/oracle/oradata/orcl/temp01.dbf' drop;

Database altered.

确认临时表空间迁移成功
SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DG1/orcl/tempfile/temp.268.779227399

SQL>

迁移控制文件到asm
SQL> show parameter control

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/app/oracle/oradata/orcl/c
                                                 ontrol01.ctl, /u01/app/oracle/
                                                 oradata/orcl/control02.ctl, /u
                                                 01/app/oracle/oradata/orcl/con
                                                 trol03.ctl

SQL> alter system set control_files='+DG1/ORCL/CONTROLFILE/control01','+DG1/ORCL/CONTROLFILE/control02','+DG1/ORCL/CONTROLFILE/control03' scope=spfile;

System altered.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  2019288 bytes
Variable Size             117440552 bytes
Database Buffers           41943040 bytes
Redo Buffers                6369280 bytes
SQL>

恢复新控制文件
[oracle@Oracle ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Mar 29 20:09:36 2012

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

connected to target database: orcl (not mounted)

RMAN> restore controlfile from '/u01/app/oracle/oradata/orcl/control01.ctl';

Starting restore at 29-MAR-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DG1/orcl/controlfile/control01
output filename=+DG1/orcl/controlfile/control02
output filename=+DG1/orcl/controlfile/control03
Finished restore at 29-MAR-12

RMAN>
挂载db
RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

切换数据文件
RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DG1/orcl/datafile/system.258.779226255"
datafile 2 switched to datafile copy "+DG1/orcl/datafile/undotbs1.261.779226303"
datafile 3 switched to datafile copy "+DG1/orcl/datafile/sysaux.259.779226283"
datafile 4 switched to datafile copy "+DG1/orcl/datafile/users.262.779226311"
datafile 5 switched to datafile copy "+DG1/orcl/datafile/example.260.779226297"

恢复数据库
RMAN> recover database;

Starting recover at 29-MAR-12
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

starting media recovery

archive log thread 1 sequence 3 is already on disk as file /arch/1_3_779210592.dbf
archive log thread 1 sequence 4 is already on disk as file /arch/1_4_779210592.dbf
archive log thread 1 sequence 5 is already on disk as file /arch/1_5_779210592.dbf
archive log thread 1 sequence 6 is already on disk as file /arch/1_6_779210592.dbf
archive log thread 1 sequence 7 is already on disk as file /arch/1_7_779210592.dbf
archive log filename=/arch/1_3_779210592.dbf thread=1 sequence=3
archive log filename=/arch/1_4_779210592.dbf thread=1 sequence=4
archive log filename=/arch/1_5_779210592.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:05
Finished recover at 29-MAR-12

打开数据库
RMAN> alter database open;

database opened

确认控制、数据、日志、临时这些文件已经迁移到asm中
[oracle@Oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Thu Mar 29 20:13:17 2012

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


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

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
+DG1/orcl/controlfile/control01
+DG1/orcl/controlfile/control02
+DG1/orcl/controlfile/control03

SQL> select name,status from v$datafile;

NAME
--------------------------------------------------------------------------------
STATUS
-------
+DG1/orcl/datafile/system.258.779226255
SYSTEM

+DG1/orcl/datafile/undotbs1.261.779226303
ONLINE

+DG1/orcl/datafile/sysaux.259.779226283
ONLINE


NAME
--------------------------------------------------------------------------------
STATUS
-------
+DG1/orcl/datafile/users.262.779226311
ONLINE

+DG1/orcl/datafile/example.260.779226297
ONLINE

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DG1/orcl/onlinelog/group_1.265.779226735
+DG1/orcl/onlinelog/group_2.266.779226751
+DG1/orcl/onlinelog/group_3.267.779226759

SQL> select name,status from v$tempfile;

NAME
--------------------------------------------------------------------------------
STATUS
-------
+DG1/orcl/tempfile/temp.268.779227399
ONLINE

 

至此本次实验完毕可以把不必要的文件删除了.

 

相关文章推荐

日本游戏制作理念初探_部分1

  • 2016年08月15日 11:08
  • 41.02MB
  • 下载

Asp[1][1]Net的管理信息系统初探+

  • 2012年04月10日 01:54
  • 1.07MB
  • 下载

Win32ASM-进程学习【1】

关于一些进程的概念就不说了。。。   一创建进程GreateProcess (1).当一个进程被创建时: ①.系统为进程创建一个内核对象,并将这个对象的计数设置为1,进程对象只是一个比较小的数...

Oracle11gR2 RAC实时应用集群(1)在Redhat Enterprise Linux5 x86_64下的集群(ASM篇)

Oracle11gR2 RAC实时应用集群(1)在Redhat Enterprise Linux5 x86_64下的集群(ASM篇) (Oracle11gR2 + Grid + RHEL5 + AS...
  • gyming
  • gyming
  • 2012年08月30日 22:22
  • 7029

全面剖析《自己动手写操作系统》的pmtest1.asm (转)

段机制轻松体验 内存寻址: 实模式下的内存寻址: 让我们首先来回顾实模式下的寻址方式 段首地址×16+偏移量 = 物理地址 为什么要×16?因为在8086CPU中,地址线是20位,...

1.asm-80386汇编

1. leave: mov esp,ebp pop ebp 其实我们应该要注意到pop ebp时,esp也加了4.   2  MOVZX 指令  格式: MOVZX OPD,OPS  ----  功能...
  • hgy413
  • hgy413
  • 2012年04月21日 20:40
  • 823

Win32ASm学习[1]:RadASm下测试Debug

okay  正文开始下面的代码如果不能编译  请把你的RadAsm下的Masm32这个文件夹复制到任意一个磁盘的根目录下,在进行编译就可以了 或者安装Masm32 SDK到任意磁盘根目录下  ...

Oracle 11g R2+RAC+ASM+redhat安装详解1

Oracle RAC是Oracle Real Application Cluster的简写,官方中文文档一般翻译为“真正应用集群”,它一般有两台或者两台以上同构计算机及共享存储设备构成,可提供强大的...
  • knuuy
  • knuuy
  • 2015年08月04日 20:39
  • 2517

自己动手写操作系统第二章 pmtest1.asm分析

[SECTION .gdt] ; GDT ;                                         段基址,      段界限     , 属性 LABEL_GDT: ...

杨继文10.4节实方式与保护方式切换实例10-1.asm,用bochs虚拟机调试

1.      切换到保护方式的准备工作 最起码的准备工作是建立合适的全局描述符表,并且使得GDTR指向GDT。在切换到保护方式的时候,至少要把代码段的选择子装载到CS,所以GDT中至少要含有代码段...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:ASM初探-1
举报原因:
原因补充:

(最多只允许输入30个字)