1:配置ASM环境 [root@primary ~]# /u01/app/oracle/product/10.2.0/db_1/bin/localconfig add [root@primary ~]# ps -ef |grep css root 4180 1 0 13:07 ? 00:00:00 /bin/su -l oracle -c sh -c 'cd /u01/app/oracle/product/10.2.0/db_1/log/primary/cssd;ulimit -c unlimited; exec /u01/app/oracle/product/10.2.0/db_1/bin/ocssd ' oracle 4332 4180 0 13:08 ? 00:00:00 /u01/app/oracle/product/10.2.0/db_1/bin/ocssd.bin root 4682 4265 0 13:17 pts/1 00:00:00 grep css [root@primary ~]# cd /u01/app/oracle/product/10.2.0/db_1/bin/ [root@primary bin]# ./crsctl check crs CSS appears healthy Cannot communicate with CRS Cannot communicate with EVM [oracle@primary ~]# ps -ef |grep -i asm oracle 4459 1 0 13:10 ? 00:00:00 asm_pmon_+ASM oracle 4461 1 0 13:10 ? 00:00:00 asm_psp0_+ASM oracle 4463 1 0 13:10 ? 00:00:00 asm_mman_+ASM oracle 4465 1 0 13:10 ? 00:00:00 asm_dbw0_+ASM oracle 4467 1 0 13:10 ? 00:00:00 asm_lgwr_+ASM oracle 4469 1 0 13:10 ? 00:00:00 asm_ckpt_+ASM oracle 4471 1 0 13:10 ? 00:00:00 asm_smon_+ASM oracle 4473 1 0 13:10 ? 00:00:00 asm_rbal_+ASM oracle 4475 1 0 13:10 ? 00:00:00 asm_gmon_+ASM oracle 4665 5702 0 13:16 pts/2 00:00:00 grep -i asm [oracle@primary ~]$ export ORACLE_SID=+ASM [oracle@primary ~]$ sqlplus /nolog SQL> conn /as sysdba SQL> select instance_name,status from v$instance; INSTANCE_N STATUS ---------- ------------------------------------ +ASM STARTED SQL> create diskgroup data normal redundancy 2 failgroup fg1 disk 3 '/dev/raw/raw1' name asmdisk1, 4 '/dev/raw/raw2' name asmdisk2 5 failgroup fg2 disk 6 '/dev/raw/raw3' name asmdisk3, 7 '/dev/raw/raw4' name asmdisk4; Diskgroup created. SQL> create diskgroup fraexternal redundancy 2 disk '/dev/raw/raw5' name asmdisk5; Diskgroup created. SQL> select name,path,failgroup from v$asm_disk; NAMEPATH FAILGROUP ---------- ---------------------------------------- -------------------- ASMDISK5 /dev/raw/raw5 ASMDISK5 ASMDISK4 /dev/raw/raw4 FG2 ASMDISK3 /dev/raw/raw3 FG2 ASMDISK2 /dev/raw/raw2 FG1 ASMDISK1 /dev/raw/raw1 FG1 SQL> select name,total_mb,free_mb,usable_file_mb from v$asm_diskgroup; NAMETOTAL_MB FREE_MB USABLE_FILE_MB ---------- ---------- ---------- -------------- DATA 81920 8181430667 FRA 58368 5831858318 2:建库 [oracle@primary ~]$ env |grep ORA ORACLE_SID=orcl ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 SQL> select file_name from dba_data_files; FILE_NAME ------------------------------------------ +DATA/orcl/datafile/users.259.765985893 +DATA/orcl/datafile/sysaux.257.765985893 +DATA/orcl/datafile/undotbs1.258.765985893 +DATA/orcl/datafile/system.256.765985891 +DATA/orcl/datafile/example.265.765986057 SQL> select member from v$logfile; MEMBER -------------------------------------------- +DATA/orcl/onlinelog/group_3.263.765986013 +FRA/orcl/onlinelog/group_3.259.765986017 +DATA/orcl/onlinelog/group_2.262.765986005 +FRA/orcl/onlinelog/group_2.258.765986009 +DATA/orcl/onlinelog/group_1.261.765985997 +FRA/orcl/onlinelog/group_1.257.765986003 SQL> show parameter spfile; NAMETYPEVALUE ------------------------------------ ----------- ------------------------------ spfile string+DATA/orcl/spfileorcl.ora SQL> show parameter control; NAMETYPEVALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 control_files string+DATA/orcl/controlfile/current .260.765985991, +FRA/orcl/cont rolfile/current.256.765985991 SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination +FRA/orcl Oldest online log sequence 3 Next log sequence to archive 5 Current log sequence 5 SQL> show parameter db_recovery_file_dest; NAMETYPEVALUE ------------------------------------ ----------- --------- db_recovery_file_dest string+FRA db_recovery_file_dest_size big integer 50000M 3:添加standby日志组 SQL> alter database add standby logfile group 4 size 50M; SQL> alter database add standby logfile group 5 size 50M; SQL> alter database add standby logfile group 6 size 50M; SQL> alter database add standby logfile group 7 size 50M; SQL> select member,type from v$logfile; MEMBERTYPE -------------------------------------------------- ------- +DATA/orcl/onlinelog/group_3.263.765986013 ONLINE +FRA/orcl/onlinelog/group_3.259.765986017 ONLINE +DATA/orcl/onlinelog/group_2.262.765986005 ONLINE +FRA/orcl/onlinelog/group_2.258.765986009 ONLINE +DATA/orcl/onlinelog/group_1.261.765985997 ONLINE +FRA/orcl/onlinelog/group_1.257.765986003 ONLINE +DATA/primary/onlinelog/group_4.268.765996737 STANDBY +FRA/primary/onlinelog/group_4.264.765996743 STANDBY +DATA/primary/onlinelog/group_5.269.765996751 STANDBY +FRA/primary/onlinelog/group_5.265.765996757 STANDBY +DATA/primary/onlinelog/group_6.270.765996763 STANDBY MEMBERTYPE -------------------------------------------------- ------- +FRA/primary/onlinelog/group_6.266.765996767 STANDBY +DATA/primary/onlinelog/group_7.271.765996775 STANDBY +FRA/primary/onlinelog/group_7.267.765996779 STANDBY 4:配置Data guard相关参数 SQL> alter system set db_unique_name='primary' scope=spfile; System altered. SQL> alter system set log_archive_config='DG_CONFIG=(primary,physical)'; System altered. SQL> show parameter remote_login; NAMETYPEVALUE ------------------------------------ ----------- ------------------------------ remote_login_passwordfile stringEXCLUSIVE SQL> alter system set log_archive_dest_1='LOCATION=+FRA/orcl valid_for=(all_logfiles,all_roles) db_unique_name=primary' scope=spfile; System altered. SQL> alter system set log_archive_dest_2='service=physical lgwr async valid_for=(online_logfile,primary_role) db_unique_name=physical' scope=spfile; System altered. SQL> alter system set log_archive_dest_state_1=enable; System altered. SQL> alter system set log_archive_dest_state_2=enable; System altered. SQL>alter system set log_archive_format='%t_%s_%r.arc' scope=spfile; System altered. SQL> alter system set fal_server='physical'; System altered. SQL> alter system set fal_client='primary'; System altered. SQL> alter database force logging; Database altered 5:配置listener.ora和tnsnames.ora文件(备库上需要做同样的配置),重启监听器和数据库,确保数据库连接正常 [oracle@primary ~]$ cat $ORACLE_HOME/network/admin/listener.ora SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (SID_NAME = PLSExtProc) (GLOBAL_DBNAME = primary_DGMGRL.yang.com) (ORACLE_HOME = /u01/app/oracle/product/10.2.0/db_1) (PROGRAM = extproc) ) )
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.227.20)(PORT = 1521)) (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0)) ) [oracle@primary ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora primary = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.227.20)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = primary.yang.com) ) ) physical = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.227.30)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = physical.yang.com) ) ) [oracle@primary ~]$ sqlplus /nolog SQL> conn /as sysdba Connected. SQL> shutdown immediate; [oracle@primary ~]$ lsnrctl stop [oracle@primary ~]$ lsnrctl start [oracle@primary ~]$ sqlplus /nolog SQL> conn /as sysdba Connected to an idle instance. SQL> startup SQL> connsys/123456@primaryas sysdba Connected. SQL> show parameter name; NAMETYPEVALUE ------------------------------------ ----------- ---------------------- db_file_name_convert string db_name stringorcl db_unique_name stringprimary global_names booleanFALSE instance_name stringorcl lock_name_space string log_file_name_convert string service_names stringprimary.yang.com 6:备份主库相关文件 SQL> !mkdir -p /home/oracle/dg_backup SQL> create pfile='/home/oracle/dg_backup/initorcl.ora' from spfile; File created. [oracle@primary ~]$ rman target / RMAN> backup incremental level 0 format '/home/oracle/dg_backup/dg_%U' 2> tag 'dg_asm' database plus archivelog; RMAN> backup format '/home/oracle/dg_backup/ctl_asm_%U' current controlfile for standby; [oracle@primary ~]$ ll -h /home/oracle/dg_backup/ total 670M -rw-r----- 1 oracle oinstall 6.8M Oct 31 15:32 ctl_asm_05mqg6vt_1_1 -rw-r----- 1 oracle oinstall 64M Oct 31 15:28 dg_01mqg6o9_1_1 -rw-r----- 1 oracle oinstall 592M Oct 31 15:29 dg_02mqg6oj_1_1 -rw-r----- 1 oracle oinstall 6.9M Oct 31 15:29 dg_03mqg6qa_1_1 -rw-r----- 1 oracle oinstall 25K Oct 31 15:29 dg_04mqg6qh_1_1 -rw-r--r-- 1 oracle oinstall 1.5K Oct 31 15:24 initorcl.ora |