Oracle ASM操作详细步骤

一.检查虚拟机的相关配置: [root@rac1 ~]# ifconfig eth0 eth0 Link encap:Ethernet HWaddr 00:0C:29:E3:7D:59 inet addr:10.1.1.210 Bcast:10.1.1.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee3:7d59/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:7957 errors:0 dropped:0 overruns:0 frame:0 TX packets:1314 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:615293 (600.8 KiB) TX bytes:103970 (101.5 KiB) Interrupt:10 Base address:0x1480 [root@rac1 ~]# ping 10.1.1.1 PING 10.1.1.1 (10.1.1.1) 56(84) bytes of data. 64 bytes from 10.1.1.1: icmp_seq=1 ttl=64 time=58.8 ms --- 10.1.1.1 ping statistics --- 1 packets transmitted, 1 received, 0% packet loss, time 0ms rtt min/avg/max/mdev = 58.860/58.860/58.860/0.000 ms [root@rac1 ~]# rpm -qa |grep oracleasm oracleasmlib-2.0.3-1.el5 oracleasm-2.6.18-128.el5-2.0.5-1.el5 oracleasm-2.6.18-128.el5debug-2.0.5-1.el5 oracleasm-support-2.1.2-1.el5 oracleasm-2.6.18-128.el5PAE-2.0.5-1.el5 oracleasm-2.6.18-128.el5xen-2.0.5-1.el5 [root@rac1 ~]# fdisk -l Disk /dev/sda: 12.8 GB, 12884901888 bytes 255 heads, 63 sectors/track, 1566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sda1 * 1 765 6144831 83 Linux /dev/sda2 766 956 1534207+ 82 Linux swap / Solaris /dev/sda3 957 1566 4899825 83 Linux Disk /dev/sdb: 536 MB, 536870912 bytes 64 heads, 32 sectors/track, 512 cylinders Units = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks Id System /dev/sdb1 1 512 524272 83 Linux Disk /dev/sdc: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdc1 1 391 3140676 83 Linux Disk /dev/sdd: 3221 MB, 3221225472 bytes 255 heads, 63 sectors/track, 391 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sdd1 1 391 3140676 83 Linux Disk /dev/sde: 2147 MB, 2147483648 bytes 255 heads, 63 sectors/track, 261 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/sde1 1 261 2096451 83 Linux [root@rac1 ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda1 5.7G 3.0G 2.5G 55% / /dev/sda3 4.6G 138M 4.2G 4% /u01 tmpfs 349M 0 349M 0% /dev/shm [root@rac1 ~]# 二.上传database安装介质 安装软件不建库 more ~/.bash_profile PATH=$PATH:$HOME/bin export PS1="`/bin/hostname -s`->" export EDITOR=vim export ORACLE_SID=up export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1 export LD_LIBRARY_PATH=$ORACLE_HOME/lib export PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/b in:/usr/X11R6/bin umask 022 rac1->cd admin rac1->mkdir +ASM rac1->cd +ASM rac1->mkdir {a,b,c,u}dump rac1->ll 总计 16 drwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 adump drwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 bdump drwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 cdump drwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 udump rac1->pwd /u01/app/oracle/admin/+ASM $ORACLE_HOME/dbs $ vi init+ASM.ora *.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' *.instance_type='asm' *.large_pool_size=12M *.remote_login_passwordfile='SHARED' rac1->orapwd file=orapw+ASM password=oracle rac1->export ORACLE_SID=+ASM rac1->sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 12 18:39:43 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ORA-29701: unable to connect to Cluster Manager [root@rac1 ~]# cd /u01/app/oracle/product/10.2.0/db_1/bin [root@rac1 bin]# ./localconfig delete /etc/oracle does not exist. Creating it now. ./localconfig: line 715: /etc/init.d/init.cssd: 没有那个文件或目录 [root@rac1 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. rac1->sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 12 18:43:52 2010 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to an idle instance. SQL> startup nomount ASM instance started Total System Global Area 83886080 bytes Fixed Size 1217836 bytes Variable Size 57502420 bytes ASM Cache 25165824 bytes 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 [root@rac1 soft]# /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 ] [root@rac1 soft]# /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1 Marking disk "VOL1" as an ASM disk: [ OK ] [root@rac1 soft]# /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1 Marking disk "VOL2" as an ASM disk: [ OK ] [root@rac1 soft]# /etc/init.d/oracleasm createdisk VOL3 /dev/sde1 Marking disk "VOL3" as an ASM disk: [ OK ] [root@rac1 soft]# /etc/init.d/oracleasm listdisks VOL1 VOL2 VOL3 SQL> create diskgroup dg1 external redundancy disk 'ORCL:VOL1'; SQL> select NAME,TYPE,STATE from v$asm_diskgroup; NAME TYPE STATE ------------------------------ ------ ----------- DG1 EXTERN MOUNTED 如果上述命令返回的 state是 DISMOUNTED,那么我们需要手工将挂载 diskgroup SQL> ALTER DISKGROUP dgroup1 MOUNT; Diskgroup altered. SQL> show parameter asm_diskgroups NAME TYPE VALUE ------------------------------------ ---------- ------------------------------ asm_diskgroups string DGROUP1 三、创建ASM数据库 接下来,创建ASM数据库的工作就非常的简单了。执行dbca实用程序,在第六步“storage options”部分选择“Automatic Storage Management ”,在接下来的“ASM Disk Groups”步骤中,选择之前创建的“DGROUP1”,再按照普通建库的方式完成数据库的创建就OK了。 [root@rac1 soft]# /etc/init.d/oracleasm createdisk VOL4 /dev/sdb1 Marking disk "VOL4" as an ASM disk: [ OK ] SQL> alter diskgroup dg2 add disk 'ORCL:VOL4'; Diskgroup altered. SQL> select NAME,TOTAL_MB,STATE from v$asm_diskgroup; NAME TOTAL_MB STATE ------------------------------ ---------- ----------- DG1 3067 MOUNTED DG2 5625 MOUNTED 监听状态: rac1->lsnrctl stat Service "+ASM" has 1 instance(s). Instance "+ASM", status BLOCKED, has 1 handler(s) for this service... Service "+ASM_XPT" has 1 instance(s). Instance "+ASM", status BLOCKED, has 1 handler(s) for this service... Service "up" has 1 instance(s). Instance "up", status READY, has 1 handler(s) for this service... Service "upXDB" has 1 instance(s). Instance "up", status READY, has 1 handler(s) for this service... Service "up_XPT" has 1 instance(s). Instance "up", status READY, has 1 handler(s) for this service... The command completed successfully 关闭asm实例,数据库也会自动关闭:
需要先停止数据库实例:
export ORACLE_SID=orcl
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
 export ORACLE_SID=+ASM SQL> shutdown normal ASM diskgroups dismounted ASM instance shutdown SQL> ho lsnrctl stat LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-AUG-2010 21:39:06 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 12-AUG-2010 21:27:19 Uptime 0 days 0 hr. 11 min. 47 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.mycorpdomain.com)(PORT=1521))) The listener supports no services The command completed successfully 启动asm实例后,数据库需要再次启动 SQL> STARTUP ASM instance started Total System Global Area 83886080 bytes Fixed Size 1217836 bytes Variable Size 57502420 bytes ASM Cache 25165824 bytes ASM diskgroups mounted SQL> ho lsnrctl stat LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-AUG-2010 21:40:21 Copyright (c) 1991, 2005, Oracle. All rights reserved. Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521)) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production Start Date 12-AUG-2010 21:27:19 Uptime 0 days 0 hr. 13 min. 2 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.log Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.mycorpdomain.com)(PORT=1521))) Services Summary... Service "+ASM" has 1 instance(s). Instance "+ASM", status BLOCKED, has 1 handler(s) for this service... Service "+ASM_XPT" has 1 instance(s).ol4; Instance "+ASM", status BLOCKED, has 1 handler(s) for this service... The command completed successfully 《Dropping Disk Groups》 SQL> alter diskgroup dg2 add disk 'ORCL:VOL4'; SQL> alter diskgroup dg2 drop disk vol4; SQL> create diskgroup dg3 eXternal redundancy disk 'ORCL:VOL4'; SQL> drop diskgroup dg3; 《Create controlfile》 CREATE CONTROLFILE REUSE DATABASE "SAMPLE" NORESETLOGS ARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 2 MAXDATAFILES 30 MAXINSTANCES 1 MAXLOGHISTORY 226 LOGFILE GROUP 1 ( '+DGROUP1/db/onlinelog/group_1.258.541956457', '+DGROUP2/db/onlinelog/group_1.256.541956473' ) SIZE 100M, GROUP 2 ( '+DGROUP1/db/onlinelog/group_2.257.541956477', '+DGROUP2/db/onlinelog/group_2.258.541956487' ) SIZE 100M DATAFILE '+DGROUP1/db/datafile/system.260.541956497', '+DGROUP1/db/datafile/sysaux.259.541956511' CHARACTER SET US7ASCII ; 《Adding New Redo Log Files》 DB_CREATE_ONLINE_LOG_DEST_1 = '+dgroup1' DB_CREATE_ONLINE_LOG_DEST_2 = '+dgroup2' ALTER DATABASE ADD LOGFILE; eg: SQL> alter system set db_create_online_log_dest_1='+DG1'; System altered. SQL> alter system set db_create_online_log_dest_2='+DG2'; System altered. SQL> ALTER database add logfile; Database altered. SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DG2/up/onlinelog/group_3.263.726866059 +DG1/up/onlinelog/group_3.259.726866065 +DG2/up/onlinelog/group_2.262.726866045 +DG1/up/onlinelog/group_2.258.726866055 +DG2/up/onlinelog/group_1.261.726866037 +DG1/up/onlinelog/group_1.257.726866041 +DG1/up/onlinelog/group_4.260.726875773 +DG2/up/onlinelog/group_4.266.726875777 8 rows selected. SQL> ALTER database add logfile; Database altered. SQL> select member from v$logfile; MEMBER -------------------------------------------------------------------------------- +DG2/up/onlinelog/group_3.263.726866059 +DG1/up/onlinelog/group_3.259.726866065 +DG2/up/onlinelog/group_2.262.726866045 +DG1/up/onlinelog/group_2.258.726866055 +DG2/up/onlinelog/group_1.261.726866037 +DG1/up/onlinelog/group_1.257.726866041 +DG1/up/onlinelog/group_4.260.726875773 +DG2/up/onlinelog/group_4.266.726875777 +DG1/up/onlinelog/group_5.261.726875799 +DG2/up/onlinelog/group_5.267.726875803 10 rows selected. 《Creating a Tablespace in ASM》 SQL> ALTER SYSTEM SET DB_CREATE_FILE_DEST = '+dgroup1(my_template)'; SQL> CREATE TABLESPACE tspace3; SQL> create tablespace tb1 datafile size 20m; 《asmcmd》 rac1->asmcmd ASMCMD> ls DG1/ DG2/ ASMCMD> cd +DG1 ASMCMD> ls UP/ ASMCMD> cd UP ASMCMD> ls CONTROLFILE/ ONLINELOG/ ASMCMD> mkdir mydir ASMCMD> ls CONTROLFILE/ ONLINELOG/ mydir/ ASMCMD> cd mydir ASMCMD> ls ASMCMD> pwd +DG1/UP/mydir ASMCMD> cd .. ASMCMD> ls CONTROLFILE/ ONLINELOG/ mydir/ ASMCMD> rm mydir ASMCMD> ls CONTROLFILE/ ONLINELOG/ ASMCMD> du Used_MB Mirror_used_MB 1192 2391 ASMCMD> find +dg2 undo* +dg2/UP/DATAFILE/UNDOTBS1.258.726865825 ASMCMD> find +dg2 spfi ASMCMD> find +dg2 spfil* +dg2/UP/PARAMETERFILE/spfile.265.726866225 +dg2/UP/spfileup.ora 

 

你可能感兴趣的:(oracle,sql,linux,vim,UP)