1.创建目录
mkdir -p $ORACLE_BASE/admin/+ASM/adump
mkdir -p $ORACLE_BASE/admin/+ASM/bdump
mkdir -p $ORACLE_BASE/admin/+ASM/cdump
mkdir -p $ORACLE_BASE/admin/+ASM/udump
2.创建口令文件
orapwd file=/u01/app/oracle/product/10.2.0/db_1/dbs/orapw+ASM password=oracle entries=10
3.创建参数文件
vi /u01/app/oracle/product/10.2.0/db_1/dbs/init+ASM.ora
输入
*.asm_diskstring=''
*.background_dump_dest='/u01/app/oracle/admin/+ASM/bdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/u01/app/oracle/admin/+ASM/udump'
4.追加磁盘四块并分区
增加4块硬盘,每块硬盘1G,命名为physical1.vmk,physical2.vmk,physical3.vmk,physical4.vmk
fdisk sdb
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-130, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-130, default 130):
Using default value 130
Command (m for help): w
如上分区sdc,sdd,sde
5.安装asm程序
rpm -Uvh oracleasm-2.6.9-89.EL-2.0.5-1.el4.i686.rpm
oracleasmlib-2.0.4-1.el4.i386.rpm
oracleasm-support-2.1.7-1.el4.i386.rpm
oracleasm-2.6.9-89.ELsmp-2.0.5-1.el4.i686.rpm
6.配置磁盘
/etc/init.d/oracleasm configure
[root@localhost oracleasm]# /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) [y]:
Scan for Oracle ASM disks on boot (y/n) [y]:
Writing Oracle ASM library driver configuration: done
Initializing the Oracle ASMLib driver: [ OK ]
Scanning the system for Oracle ASMLib disks: [ OK ]
[root@localhost oracleasm]# /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.
localhost
CSS is active on all nodes.
Oracle CSS service is installed and running under init(1M)
7.编辑磁盘
vi /etc/sysconfig/rawdevices
加入:
/dev/raw/raw1 /dev/sdb
/dev/raw/raw2 /dev/sdc
/dev/raw/raw3 /dev/sdd
8.修改raw权限
vi /etc/udev/permissions.d/50-udev.permissions
修改raw/*:root:disk:0660 为raw/*:oracle:dba:0660
9.重新启动服务
[root@localhost oracleasm]# service rawdevices restart
Assigning devices:
/dev/raw/raw1 --> /dev/sdb
/dev/raw/raw1: bound to major 8, minor 16
/dev/raw/raw2 --> /dev/sdc
/dev/raw/raw2: bound to major 8, minor 32
/dev/raw/raw3 --> /dev/sdd
/dev/raw/raw3: bound to major 8, minor 48
done
10.启动ASM
[oracle@localhost ~]$ export ORACLE_SID=+ASM
[oracle@localhost ~]$ sqlplus /nolog
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
11.创建磁盘组
SQL> create diskgroup dg1 external redundancy disk '/dev/raw/raw1';
SQL> select * from v$asm_diskgroup;
SQL> create diskgroup dg2 normal redundancy failgroup fg1 disk '/dev/raw/raw2' failgroup fg2 disk '/dev/raw/raw3';
12.备份数据库
RMAN> backup database format '/u01/rmanbak/databasebak_%d_%U';
13.修改pfile文件
[oracle@localhost dbs]$ vi initrac2.ora
*.control_files='+DG1/rac2/controlfile/control.ctl','/u01/app/oracle/oradata/rac1/control02.ctl','/urac2.__db_cache_size=192937984
rac2.__java_pool_size=4194304
rac2.__large_pool_size=4194304
rac2.__shared_pool_size=79691776
rac2.__streams_pool_size=0
*.audit_file_dest='/u01/app/oracle/admin/rac2/adump'
*.background_dump_dest='/u01/app/oracle/admin/rac2/bdump'
*.compatible='10.2.0.1.0'
*.control_files='+DG1/rac2/controlfile/control.ctl'
*.core_dump_dest='/u01/app/oracle/admin/rac2/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='rac2'
*.db_recovery_file_dest_size=2147483648
*.db_recovery_file_dest='/u01/app/oracle/oradata/rac2/archivelog/'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rac2XDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=+DG1/rac2/'
*.open_cursors=300
*.pga_aggregate_target=94371840
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=285212672
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/app/oracle/admin/rac2/udump'
*.db_create_file_dest='+DG1'
*.db_file_name_convert=("rac1","rac2") ----同一台机子中使用
*.log_file_name_convert=("rac1","rac2")----同一台机子中使用
14.创建密码文件及目录
[oracle@localhost dbs]$ orapwd file=$ORACLE_HOME/dbs/orapwdrac2 password=oracle entries=10
[oracle@localhost dbs]$ mkdir -p $ORACLE_HOME/admin/rac2/adump
[oracle@localhost dbs]$ mkdir -p $ORACLE_HOME/admin/rac2/bdump
[oracle@localhost dbs]$ mkdir -p $ORACLE_HOME/admin/rac2/cdump
[oracle@localhost dbs]$ mkdir -p $ORACLE_HOME/admin/rac2/udump
15.查看RMAN信息
RMAN> list backupset of archivelog all;
RMAN> report schema;
RMAN> list copy;
RMAN> crosscheck backupset;
16.创建复制脚本
RMAN> replace global script g_duplicate comment "duplicate database" {
2> allocate auxiliary channel d1 device type disk;
3> set until logseq 3 thread 1;
4> set newname for datafile 1 to '+DG1';
5> set newname for datafile 2 to '+DG1';
6> set newname for datafile 3 to '+DG1';
7> set newname for datafile 4 to '+DG1';
8> set newname for tempfile 1 to '+DG1';
9> duplicate target database to rac2 logfile
10> group 1('+DG1') size 50m reuse,
11> group 2('+DG2') size 50m reuse,
12> group 3('+DG3') size 50m reuse;
13> }
17.启动数据库rac2到nomount状态
SQL> startup nomount
ORACLE instance started.
Total System Global Area 285212672 bytes
Fixed Size 1218992 bytes
Variable Size 88082000 bytes
Database Buffers 192937984 bytes
Redo Buffers 2973696 bytes
18.用catalog连接rman,并运行脚本
RMAN> connect auxiliary / ;
RMAN> run {
2> execute global script g_duplicate;
3> }
问题点:当rac2还未建立时,应该是不可以建立脚本?