Oracle ASM操作详细步骤
一.检查虚拟机的相关配置:# ifconfig eth0eth0 Link encap:EthernetHWaddr 00:0C:29:E3:7D:59 inet addr:10.1.1.210Bcast:10.1.1.255Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fee3:7d59/64 Scope:Link UP BROADCAST RUNNING MULTICASTMTU:1500Metric: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 # ping 10.1.1.1PING 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 0msrtt min/avg/max/mdev = 58.860/58.860/58.860/0.000 ms# rpm -qa |grep oracleasmoracleasmlib-2.0.3-1.el5oracleasm-2.6.18-128.el5-2.0.5-1.el5oracleasm-2.6.18-128.el5debug-2.0.5-1.el5oracleasm-support-2.1.2-1.el5oracleasm-2.6.18-128.el5PAE-2.0.5-1.el5oracleasm-2.6.18-128.el5xen-2.0.5-1.el5# fdisk -lDisk /dev/sda: 12.8 GB, 12884901888 bytes255 heads, 63 sectors/track, 1566 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks IdSystem/dev/sda1 * 1 765 6144831 83Linux/dev/sda2 766 956 1534207+82Linux swap / Solaris/dev/sda3 957 1566 4899825 83LinuxDisk /dev/sdb: 536 MB, 536870912 bytes64 heads, 32 sectors/track, 512 cylindersUnits = cylinders of 2048 * 512 = 1048576 bytes Device Boot Start End Blocks IdSystem/dev/sdb1 1 512 524272 83LinuxDisk /dev/sdc: 3221 MB, 3221225472 bytes255 heads, 63 sectors/track, 391 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks IdSystem/dev/sdc1 1 391 3140676 83LinuxDisk /dev/sdd: 3221 MB, 3221225472 bytes255 heads, 63 sectors/track, 391 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks IdSystem/dev/sdd1 1 391 3140676 83LinuxDisk /dev/sde: 2147 MB, 2147483648 bytes255 heads, 63 sectors/track, 261 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks IdSystem/dev/sde1 1 261 2096451 83Linux# df -h文件系统 容量已用 可用 已用% 挂载点/dev/sda1 5.7G3.0G2.5G55% //dev/sda3 4.6G138M4.2G 4% /u01tmpfs 349M 0349M 0% /dev/shm# 二.上传database安装介质安装软件不建库more ~/.bash_profile PATH=$PATH:$HOME/binexport PS1="`/bin/hostname -s`->"export EDITOR=vimexport ORACLE_SID=upexport ORACLE_BASE=/u01/app/oracleexport ORACLE_HOME=$ORACLE_BASE/product/10.2.0/db_1export LD_LIBRARY_PATH=$ORACLE_HOME/libexport PATH=$ORACLE_HOME/bin:$ORA_CRS_HOME/bin:/bin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/X11R6/binumask 022rac1->cd adminrac1->mkdir +ASM rac1->cd +ASMrac1->mkdir {a,b,c,u}dumprac1->ll总计 16drwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 adumpdrwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 bdumpdrwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 cdumpdrwxr-xr-x 2 oracle oinstall 4096 08-12 18:33 udumprac1->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+ASMpassword=oraclerac1->export ORACLE_SID=+ASMrac1->sqlplus/ as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 12 18:39:43 2010Copyright (c) 1982, 2005, Oracle.All rights reserved.Connected to an idle instance.SQL> startup nomountORA-29701: unable to connect to Cluster Manager# cd /u01/app/oracle/product/10.2.0/db_1/bin# ./localconfig delete/etc/oracle does not exist. Creating it now../localconfig: line 715: /etc/init.d/init.cssd: 没有那个文件或目录# ./localconfig add Successfully accumulated necessary OCR keys.Creating OCR keys for user 'root', privgrp 'root'..Operation successful.Configuration for local CSS has been initializedAdding 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 sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 12 18:43:52 2010Copyright (c) 1982, 2005, Oracle.All rights reserved.Connected to an idle instance.SQL> startup nomountASM instance startedTotal System Global Area 83886080 bytesFixed Size 1217836 bytesVariable Size 57502420 bytesASM Cache 25165824 bytesSQL> create spfile from pfile;File created.SQL> startup force ASM instance startedTotal System Global Area 83886080 bytesFixed Size 1217836 bytesVariable Size 57502420 bytesASM Cache 25165824 bytesORA-15110: no diskgroups mounted# /etc/init.d/oracleasm configureConfiguring the Oracle ASM library driver.This will configure the on-boot properties of the Oracle ASM librarydriver.The following questions will determine whether the driver isloaded on boot and what permissions it will have.The current valueswill be shown in brackets ('[]').Hitting <ENTER> without typing ananswer will keep that current value.Ctrl-C will abort.Default user to own the driver interface []: oracleDefault group to own the driver interface []: dbaStart Oracle ASM library driver on boot (y/n) : yScan for Oracle ASM disks on boot (y/n) : yWriting Oracle ASM library driver configuration: doneInitializing the Oracle ASMLib driver: Scanning the system for Oracle ASMLib disks: # /etc/init.d/oracleasm createdisk VOL1 /dev/sdc1Marking disk "VOL1" as an ASM disk: # /etc/init.d/oracleasm createdisk VOL2 /dev/sdd1Marking disk "VOL2" as an ASM disk: # /etc/init.d/oracleasm createdisk VOL3 /dev/sde1Marking disk "VOL3" as an ASM disk: # /etc/init.d/oracleasm listdisksVOL1VOL2VOL3SQL> create diskgroup dg1external redundancy disk 'ORCL:VOL1';SQL> select NAME,TYPE,STATE from v$asm_diskgroup;NAME TYPE STATE------------------------------ ------ -----------DG1 EXTERN MOUNTED如果上述命令返回的 state是 DISMOUNTED,那么我们需要手工将挂载 diskgroupSQL> ALTER DISKGROUP dgroup1 MOUNT;Diskgroup altered.SQL> show parameter asm_diskgroupsNAME TYPE VALUE ------------------------------------ ---------- ------------------------------ asm_diskgroups string DGROUP1三、创建ASM数据库接下来,创建ASM数据库的工作就非常的简单了。执行dbca实用程序,在第六步“storage options”部分选择“Automatic Storage Management ”,在接下来的“ASM Disk Groups”步骤中,选择之前创建的“DGROUP1”,再按照普通建库的方式完成数据库的创建就OK了。# /etc/init.d/oracleasm createdisk VOL4 /dev/sdb1Marking disk "VOL4" as an ASM disk: 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 MOUNTEDDG2 5625 MOUNTED监听状态:rac1->lsnrctl statService "+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=orclSQL>shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.export ORACLE_SID=+ASMSQL> shutdown normalASM diskgroups dismountedASM instance shutdownSQL> ho lsnrctl statLSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-AUG-2010 21:39:06Copyright (c) 1991, 2005, Oracle.All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 10.2.0.1.0 - ProductionStart Date 12-AUG-2010 21:27:19Uptime 0 days 0 hr. 11 min. 47 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.logListening Endpoints Summary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.mycorpdomain.com)(PORT=1521)))The listener supports no servicesThe command completed successfully启动asm实例后,数据库需要再次启动SQL> STARTUPASM instance startedTotal System Global Area 83886080 bytesFixed Size 1217836 bytesVariable Size 57502420 bytesASM Cache 25165824 bytesASM diskgroups mountedSQL> ho lsnrctl statLSNRCTL for Linux: Version 10.2.0.1.0 - Production on 12-AUG-2010 21:40:21Copyright (c) 1991, 2005, Oracle.All rights reserved.Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))STATUS of the LISTENER------------------------Alias LISTENERVersion TNSLSNR for Linux: Version 10.2.0.1.0 - ProductionStart Date 12-AUG-2010 21:27:19Uptime 0 days 0 hr. 13 min. 2 secTrace Level offSecurity ON: Local OS AuthenticationSNMP OFFListener Log File /u01/app/oracle/product/10.2.0/db_1/network/log/listener.logListening 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 eXternalredundancy 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 226LOGFILEGROUP 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 100MDATAFILE'+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.7268757778 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.72687580310 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->asmcmdASMCMD> lsDG1/DG2/ASMCMD> cd +DG1ASMCMD> lsUP/ASMCMD> cd UPASMCMD> lsCONTROLFILE/ONLINELOG/ASMCMD> mkdir mydirASMCMD> lsCONTROLFILE/ONLINELOG/mydir/ASMCMD> cd mydirASMCMD> lsASMCMD> pwd+DG1/UP/mydirASMCMD> cd ..ASMCMD> lsCONTROLFILE/ONLINELOG/mydir/ASMCMD> rm mydirASMCMD> lsCONTROLFILE/ONLINELOG/ASMCMD> duUsed_MB Mirror_used_MB 1192 2391ASMCMD> find +dg2 undo*+dg2/UP/DATAFILE/UNDOTBS1.258.726865825ASMCMD> find +dg2 spfiASMCMD> find+dg2 spfil*+dg2/UP/PARAMETERFILE/spfile.265.726866225+dg2/UP/spfileup.ora
页:
[1]