建立ASM例項和資料庫

oracle_ace發表於2008-01-01

由於ASM例項是工作在Oracle instance上面,因此建立ASM的instance就是我們工作的第一步。
共分六步驟
1.create initial parameter files
2.create orapwd files
3.create the directory structure
4.startup the instance
5.create the spfile and restart the database
6.create the diskgroup

第一步:
建立pfile檔案init_asm.ora
*.asm_diskstring='ORCL:MYVOL*'
*.user_dump_dest='/opt/oracle/admin/ASM/udump'
*.background_dump_dest='/opt/oracle/admin/ASM/bdump'
*.core_dump_dest='/opt/oracle/admin/ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'

第二步:
建立密碼檔案:
[oracle@orahost01 dbs]$ orapwd file=orapwdASM password=passsw0rd entries=15

第三步:
建立目錄
[oracle@orahost01 dbs]$ mkdir -p /opt/oracle/admin/ASM/udump
[oracle@orahost01 dbs]$ mkdir -p /opt/oracle/admin/ASM/bdump
[oracle@orahost01 dbs]$ mkdir -p /opt/oracle/admin/ASM/cdump

第四步:
啟動例項
[oracle@orahost01 10g]$ export ORACLE_SID=ASM
[oracle@orahost01 10g]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 31 18:56:24 2007

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

SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup nomount
ORA-29701: unable to connect to Cluster Manager
******************
如果遇到這樣的問題
******************
編輯vi /etc/inittab檔案
新增或取消註釋這一樣
hi:35:respawn:/etc/init.d/init.cssd run > /dev/null 2>&1 < /dev/null
同時我們要保證有css服務的存在,如果沒有的話,需要自己新增:
[oracle@orahost01 10g]$ cd $ORACLE_HOME
[oracle@orahost01 10g]$ cd bin
[oracle@orahost01 bin]$ ./localconfig add
You must be logged in as root to run ./localconfig.
Log in as root and restart ./localconfig execution.
[oracle@orahost01 bin]$ exit
[root@orahost01 bin]# pwd
/opt/oracle/product/10g/bin
[root@orahost01 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.
        orahost01
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)

然後重新啟動,我們再來:
[oracle@orahost01 ~]$ export ORACLE_SID=ASM
[oracle@orahost01 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 31 19:15:58 2007

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

SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

SQL> select name,state from v$asm_diskgroup;

no rows selected

SQL> quit

第五步:建立spfile
SQL> create spfile from pfile;

File created.

SQL> startup force
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

第六步:建立磁碟組
[oracle@orahost01 ~]$ export ORACLE_SID=ASM
[oracle@orahost01 ~]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 31 19:29:21 2007

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

SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted

SQL> create diskgroup dgroup1 normal redundancy
  2  failgroup fgroup1 disk 'ORCL:MYVOL1','ORCL:MYVOL2'
  3  failgroup fgroup2 disk 'ORCL:MYVOL3','ORCL:MYVOL4';

Diskgroup created.

SQL> select disk_number,total_mb,free_mb from v$asm_disk;

DISK_NUMBER   TOTAL_MB    FREE_MB
----------- ---------- ----------
          0        392        362
          1        392        369
          2        392        364
          3        392        367

SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
DGROUP1                        MOUNTED

當然也可以通過手動方式來mount
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@orahost01 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 31 19:31:46 2007

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

SQL> conn / as sysdba;
Connected.
SQL> shutdown abort
ASM instance shutdown
SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted
SQL> alter diskgroup dgroup1 mount;

Diskgroup altered.

SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
DGROUP1                        MOUNTED

SQL> select instance_name from v$instance; 

INSTANCE_NAME
----------------
ASM

SQL> show parameter instance_name;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      ASM

之後我們就可以建立ASM資料庫了。
那麼建立完畢後如何啟動ASM資料庫,則按照如下步驟進行就可以了:
1.啟動ASM例項
2.啟動ASM資料庫的例項

下面是自己另外做的一個小測試,很簡單,備忘吧
[oracle@orahost01 dbs]$ sqlplus /nolog

SQL*Plus: Release 10.2.0.1.0 - Production on Mon Dec 31 20:10:01 2007

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

SQL> conn / as sysdba;
Connected to an idle instance.
SQL> startup
ASM instance started

Total System Global Area   83886080 bytes
Fixed Size                  1217836 bytes
Variable Size              57502420 bytes
ASM Cache                  25165824 bytes
ORA-15110: no diskgroups mounted


SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /opt/oracle/product/10g/dbs/sp
                                                 fileASM.ora
SQL> show parameter asm_

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string
asm_diskstring                       string      ORCL:MYDISK*
asm_power_limit                      integer     1
SQL> select name,state from v$asm_diskgroup;

NAME                           STATE
------------------------------ -----------
ALANGROUP                      DISMOUNTED

SQL> alter diskgroup alangroup mount;

Diskgroup altered.

SQL> show parameter asm_ 

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
asm_diskgroups                       string      ALANGROUP
asm_diskstring                       string      ORCL:MYDISK*
asm_power_limit                      integer     1
SQL>

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/12361284/viewspace-68258/,如需轉載,請註明出處,否則將追究法律責任。

相關文章