Oracle 11.2.4.0 ADG 單例項安裝(COPY建立備庫)

shawnloong發表於2015-06-14

Oracle 11.2.4.0 ADG 單例項安裝(COPY建立備庫)
規劃:
主:

OS: Linux Centos 6.5 X64
hostname:ORA11G-DG1
ipaddress:192.168.213.199
db_unique_name=netdata_pd
db_name=netdata
備:

OS: Linux Centos 6.5 X64
hostname:ORA11G-DG2
ipaddress:192.168.213.200
db_unique_name=netdata_sd
db_name=netdata

注OS平臺一致

1.主庫安裝oracle軟體(參照文件)

2.建立監聽,可以用netca,也可以直接用檔案建立
listener.ora如下
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ORA11G-DG1)(PORT = 51518))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC51518))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
    (GLOBAL_DBNAME = netdata)
    (SID_NAME = netdata)
    )
   )
ADR_BASE_LISTENER = /u01/app/oracle

2.主庫dbca建庫,注意生產環境的一些引數SGA,PGA,PROCESS,歸檔位置,open_cursor,flash_recovery位置等等,如果要使用EM開始的時候需要建埠1521監聽
3.主庫tnames.ora配置
NETDATA_SD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.200)(PORT = 51518))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = netdata)
    )
  )

NETDATA_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.199)(PORT = 51518))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = netdata)
    )
  )
 
4.備庫安裝oracle軟體僅安裝軟體(請參照之前安裝軟體)

5.備庫配置listener.ora,tnames.ora
listener.ora如下:
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ORA11G-DG2)(PORT = 51518))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC51518))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (PROGRAM = extproc)
    )
    (SID_DESC =
      (GLOBAL_DBNAME = netdata)
      (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1)
      (SID_NAME = netdata)
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

tnames.ora如下:
NETDATA_SD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.200)(PORT = 51518))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = netdata)
    )
  )

NETDATA_PD =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.213.199)(PORT = 51518))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = netdata)
    )
  )
 
6.主庫引數檔案配置
主庫強制forceloing
SQL> ALTER DATABASE FROCE LOGGING;
SQL> select  FORCE_LOGGING  from  v$database;
YES
引數檔案配置
alter system set DB_UNIQUE_NAME=netdata_pd scope=spfile;
alter system set LOG_ARCHIVE_CONFIG='DG_CONFIG=(netdata_pd,netdata_sd)' scope=both;
alter system set LOG_ARCHIVE_DEST_1='LOCATION=/oradata/archive VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=netdata_pd' scope=both;
alter system set LOG_ARCHIVE_DEST_2='SERVICE=netdata_sd LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=netdata_sd';
alter system set standby_file_management='AUTO' sid='*' scope=both;
alter system set fal_client='netdata_pd';
alter system set fal_server='netdata_sd';
alter system set db_file_name_convert='/oradata/netdata','/oradata/netdata' SCOPE=SPFILE;
alter SYSTEM SET log_file_name_convert='/oradata/netdata','/oradata/netdata' SCOPE=SPFILE;

7.為備庫建立引數檔案
create pfile='/oradata/standby.ora' from spfile
編輯standby.ora
修改
*.db_unique_name='NETDATA_PD'
*.log_archive_config='DG_CONFIG=(netdata_pd,netdata_sd)'
*.log_archive_dest_1='LOCATION=/oradata/archive
  VALID_FOR=(ALL_LOGFILES,ALL_ROLES)
  DB_UNIQUE_NAME=netdata_pd'
*.log_archive_dest_2='SERVICE=netdata_sd ASYNC
  VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
  DB_UNIQUE_NAME=netdata_sd'
*.fal_client='NETDATA_PD'
*.fal_server='NETDATA_SD'
*.log_file_name_convert='/oradata/netdata','/oradata/netdata'
*.standby_file_management='AUTO'
*.db_file_name_convert='/oradata/netdata','/oradata/netdata'

8.為備庫建立控制檔案
alter  database  create  standby  controlfile  as  '/oradata/control01.ctl';

9.關閉主庫將資料檔案,引數檔案,密碼檔案($ORACLE_HOME/dbs/orapwnetdata linux為orapw$ORACLE_SID),admin檔案
注:備庫建立所需要目錄 用oracle使用者建立
--資料檔案目錄
mkdir -p /oradata/netdata
--recovery目錄
mkdir -p /oradata/recovery_area
--歸檔目錄
mkdir -p /oradata/archive
--admin目錄
mkdir -p /u01/app/oracle/admin/
複製資料檔案及redo檔案
scp -r /oradata/netdata/*.log oracle@192.168.213.200:/oradata/netdata/
scp -r /oradata/netdata/*.dbf oracle@192.168.213.200:c
複製admin目錄
scp -r /u01/app/oracle/admin/* oracle@192.168.213.200:/u01/app/oracle/admin/
複製引數檔案
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/control01.ctl
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/control02.ctl
scp -r /oradata/control01.ctl oracle@192.168.213.200:/oradata/recovery_area/control03.ctl
注意一定要copy全不然啟動備庫會報錯的
複製密碼檔案
scp -r $ORACLE_HOME/dbs/orapwnetdata oracle@192.168.213.200:/u01/app/oracle/product/11.2.0/dbhome_1/dbs/orapwnetdata

10.為主備庫建立standbylog
主:
startup
ALTER DATABASE ADD STANDBY LOGFILE group 4('/oradata/netdata/stredo01.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 5('/oradata/netdata/stredo02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 6('/oradata/netdata/stredo03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 7('/oradata/netdata/stredo04.log') SIZE 50M;
注意這裡大小要跟redolog一致,比redolog多一組
備:
sqlplus /nolog
create spfile from pfile='/oradata/netdata/standby.ora';
startup mount;
ALTER DATABASE ADD STANDBY LOGFILE group 4('/oradata/netdata/stredo01.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 5('/oradata/netdata/stredo02.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 6('/oradata/netdata/stredo03.log') SIZE 50M;
ALTER DATABASE ADD STANDBY LOGFILE group 7('/oradata/netdata/stredo04.log') SIZE 50M;

11.檢驗主庫是否同步
備操作:
shutdown immediate;
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;

檢驗主備是否一致
archive log list;
col name format A50;
col dest_name format A40
col error format A20
set line 200;
select name,sequence#,applied from v$archived_log a where a.sequence#=(select max(sequence#) from v$archived_log);
col dest_name format A40
select dest_name,status,error from v$archive_dest where rownum<3;


啟動ADG:
alter database recover managed standby database cancel;
alter database open read only;
alter database recover managed standby database using current logfile disconnect from session;

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

相關文章