ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 创建ASM 实例 [学习笔记]

创建ASM 实例 [学习笔记]

原创 Linux操作系统 作者:todayboy 时间:2011-08-16 16:26:28 0 删除 编辑

   创建ASM 实例
1创建初始化文件 
2创建密码文件
3创建目录结构
4启动实例
5创建spfile,重新启动
6创建diskgroup


 前提:
  安装Oracle soft :
 ORACLE_BASE=/u01/oracle; export ORACLE_BASE
 ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1; export ORACLE_HOME
 ORACLE_SID=ORCL;    export ORACLE_SID
  stty erase ^h

配制VOL:

[root@rac2 ~]# /etc/init.d/oracleasm  createdisk VOL1   /dev/sda5
[root@rac2 ~]# /etc/init.d/oracleasm  createdisk VOL2   /dev/sda6
[root@rac2 ~]# /etc/init.d/oracleasm  createdisk VOL3   /dev/sda7
[root@rac2 ~]# /etc/init.d/oracleasm  createdisk VOL4   /dev/sda8

 [root@rac2 ~]# /etc/init.d/oracleasm  configure

查询:
[root@rac2 ~]# /etc/init.d/oracleasm  querydisk /dev/sda6
Device "/dev/sda6" is marked an ASM disk with the label "VOL2"

 

 

 

1.创建初始化文件
su - oracle
cd $ORACLE_HOME/dbs
vi init+ASM.ora

*.asm_diskstring='ORCL:VOL*'
*.background_dump_dest='/u01/oracle/admin/+ASM/bdump'
*.core_dump_dest='/u01/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u01/oracle/admin/+ASM/udump'

 

###注:ORACLE_BASE=/u01/oracle


2创建密码文件

su - oracle
cd $ORACLE_HOME/dbs
orapwd file=orapwd+ASM password=hanmiit


3创建目录结构
mkdir -p /u01/oracle/admin/+ASM/bdump

mkdir -p /u01/oracle/admin/+ASM/cdump

mkdir -p  /u01/oracle/admin/+ASM/udump

4启动实例
  export ORACLE_SID=+ASM

Connected to an idle instance.
SQL> startup
ORA-29701: unable to connect to Cluster Manager


#############################################################################################
解决的办法是,以root用户到目录$ORACLE_HOME/bin下,执行:
[root@rac2 bin]# cd /u01/oracle/product/10.2.0/db_1/bin

[root@rac2 bin]# ./localconfig  delete
OCR initialization failed accessing OCR device: PROC-26: Error while accessing the physical storage Operating System error [No such file or directory] [2]
Shutdown has begun. The daemons should exit soon.
[root@rac2 bin]# ./localconfig  add
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.
        rac2
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

######################################################s

[oracle@rac2 dbs]$ export ORACLE_SID=+ASM
[oracle@rac2 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Aug 16 16:54:42 2011

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

SQL> conn /as sysdba;
Connected to an idle instance.
SQL> start  
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

 

 

5创建spfile,重新启动

SQL>create spfiel from pfile;

SQL> shutdown immedaite;
SQL> STARTUP;


6创建diskgroup

SQL> create diskgroup dgroup1    normal redundancy
  2  failgroup fgroup1 disk 'ORCL:VOL1','ORCL:VOL2'
  3  failgroup fgroup2 disk 'ORCL:VOL3','ORCL:VOL4';

Diskgroup created.

 

SQL> set linesize 500;
SQL> col name for a40;
SQL> select name,state from v$asm_diskgroup;
NAME                                     STATE
---------------------------------------- ---------------------------------
DGROUP1                                  MOUNTED            --------------------------mount 成功!

SQL> select group_number ,name ,state from v$asm_diskgroup;

GROUP_NUMBER NAME                                     STATE
------------ ---------------------------------------- ---------------------------------
           1 DGROUP1                                  MOUNTED     ------------------------------如不成功,就手动MOUNT

 

SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ ---------------------------------
DGROUP1                        DISMOUNTED              -----------------------------------  DISMOUNTED, 表示不成功 (需要手工mount)

SQL> alter diskgroup dgroup1 mount;

Diskgroup altered.


SQL> alter diskgroup dgroup1 dismount;

Diskgroup altered.

 

 

 

SQL>  show parameter asm_diskgroups;

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
asm_diskgroups                       string                            DGROUP1

 

再用DBCA 创建数据库(略)

测试:

 

 

重点:
 1 添加磁盘
 2   删除磁盘

三个发相关的视图:
  v$asm_operation
        v$asm_diskgroup
        v$asm_disk
 

1 添加磁盘:
  /etc/init.d/oracleasm createdisk  VOL5 /dev/sda9
 /etc/init.d/oracleasm createdisk  VOL6 /dev/sda10
    检查:
  /etc/init.d/oracleasm  querydisk /dev/sda9
 /etc/init.d/oracleasm  querydisk /dev/sda10


   启动ASM 实例:(略)
   启动数据库:(略)


[oracle@rac2 ~]$ export ORACLE_SID=+ASM
[oracle@rac2 ~]$ sqlplus / as sysdba;

SQL> set linesize 500;
SQL> col name for a10;  
SQL> col path for a10; 
SQL>col mount_status for a20;
SQL> col failgroup for a20;

SQL> select disk_number,mount_status,name,path,total_mb,free_mb,failgroup from v$asm_disk;

DISK_NUMBER MOUNT_STATUS         NAME       PATH                   TOTAL_MB    FREE_MB FAILGROUP
----------- -------------------- ---------- -------------------- ---------- ---------- --------------------
          0 CLOSED                          ORCL:VOL5                  5726          0
          1 CLOSED                          ORCL:VOL6                  5726          0
          0 CACHED               VOL1       ORCL:VOL1                  5726       5074 FGROUP1
          1 CACHED               VOL2       ORCL:VOL2                  5726       5086 FGROUP1
          2 CACHED               VOL3       ORCL:VOL3                  5726       5078 FGROUP2
          3 CACHED               VOL4       ORCL:VOL4                  5726       5082 FGROUP2

6 rows selected.


SQL> alter diskgroup dgroup1 add failgroup fgroup1 disk 'ORCL:VOL5' failgroup fgroup2 disk 'ORCL:VOL6';

Diskgroup altered.


SQL> select group_number,operation,state,est_work,sofar,est_rate,est_minutes from v$asm_operation;

GROUP_NUMBER OPERATION       STATE          EST_WORK      SOFAR   EST_RATE EST_MINUTES
------------ --------------- ------------ ---------- ---------- ---------- -----------
           1 REBAL           RUN                 978        813        765           0

SQL> r
  1* select group_number,operation,state,est_work,sofar,est_rate,est_minutes from v$asm_operation

GROUP_NUMBER OPERATION       STATE          EST_WORK      SOFAR   EST_RATE EST_MINUTES
------------ --------------- ------------ ---------- ---------- ---------- -----------
           1 REBAL           RUN                 978        813        765           0

 


查看ASM空间大小(34G):
SQL> select name ,allocation_unit_size ,total_mb from v$asm_diskgroup;

NAME       ALLOCATION_UNIT_SIZE   TOTAL_MB
---------- -------------------- ----------
DGROUP1                 1048576      34356

 

登陆oracle 实例:
[oracle@rac2 ~]$ export ORACLE_SID=orcl
[oracle@rac2 ~]$ sqlplus / as sysdba;
 SQL>set linesize 500;
SQL> col  name for a60;
SQL> select * from v$dbfile;

 FILE# NAME
------ ------------------------------------------------------------
     4 +DGROUP1/orcl/datafile/users.259.759505733
     3 +DGROUP1/orcl/datafile/sysaux.257.759505733
     2 +DGROUP1/orcl/datafile/undotbs1.258.759505733
     1 +DGROUP1/orcl/datafile/system.256.759505733
     5 +DGROUP1/orcl/datafile/example.269.759505873
5 rows selected.


SQL> create tablespace ts_test datafile '+DGROUP1' size 200m;
Tablespace created.

SQL> select * from v$dbfile;

 FILE# NAME
------ ------------------------------------------------------------
     4 +DGROUP1/orcl/datafile/users.259.759505733
     3 +DGROUP1/orcl/datafile/sysaux.257.759505733
     2 +DGROUP1/orcl/datafile/undotbs1.258.759505733
     1 +DGROUP1/orcl/datafile/system.256.759505733
     5 +DGROUP1/orcl/datafile/example.269.759505873
     6 +DGROUP1/orcl/datafile/ts_test.271.759512763

6 rows selected.


SQL> create user asmuser identified by  pass default tablespace ts_test;

User created.

SQL> grant dba to asmuser;

Grant succeeded.

SQL> conn asmuser/pass;
Connected.


SQL> create table t_test as select * from dba_objects;

Table created.

SQL> select count(*) from t_test;

  COUNT(*)
----------
     50315
SQL>exit;

 

登陆ASM 实例(进行删除disk 测试):
[oracle@rac2 ~]$ export ORACLE_SID=+ASM
[oracle@rac2 ~]$ sqlplus / as sysdba;

SQL> alter diskgroup dgroup1 drop disk VOL4;

Diskgroup altered.


查看ORACLE 如何重新分配数据:

SQL> select group_number,operation,state,est_work,sofar,est_rate,est_minutes from v$asm_operation;
GROUP_NUMBER OPERATION       STATE          EST_WORK      SOFAR   EST_RATE EST_MINUTES
------------ --------------- ------------ ---------- ---------- ---------- -----------
           1 REBAL           RUN                 978        813        765           0

SQL> r
  1* select group_number,operation,state,est_work,sofar,est_rate,est_minutes from v$asm_operation

GROUP_NUMBER OPERATION       STATE          EST_WORK      SOFAR   EST_RATE EST_MINUTES
------------ --------------- ------------ ---------- ---------- ---------- -----------
           1 REBAL           RUN                 978        813        765           0

SQL> r
  1* select group_number,operation,state,est_work,sofar,est_rate,est_minutes from v$asm_operation

GROUP_NUMBER OPERATION       STATE          EST_WORK      SOFAR   EST_RATE EST_MINUTES
------------ --------------- ------------ ---------- ---------- ---------- -----------
           1 REBAL           RUN                 978        813        765           0

查看ASM空间大小(34G没有变化):
SQL> select name ,allocation_unit_size ,total_mb from v$asm_diskgroup;
NAME                           ALLOCATION_UNIT_SIZE   TOTAL_MB
------------------------------ -------------------- ----------
DGROUP1                                     1048576      34356


SQL> alter diskgroup dgroup1 rebalance;

Diskgroup altered.

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7583803/viewspace-704998/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-24

  • 博文量
    75
  • 访问量
    245782