DG_安裝三

chenoracle發表於2015-04-13


ORACLE DG 的搭建 ( 方法三 )

 

說明:

備庫生成原理:

1 配置好主庫後將資料庫安裝檔案 /u01 ,備庫控制檔案,歸檔檔案打包傳送到備庫

2 備庫新增 oracle 使用者,組,附加組,解壓來自主庫的壓縮檔案

3 修改引數檔案,網路檔案等相關配置,啟動備庫 mount( 主備庫 sid 相同 )

 

主機

IP:192.168.1.181

主機名 :chen01

OS:Red Hat Enterprise Linux Server release 6.4 (Santiago)

oracle:11.2.0.1.0

SID:orcl

db_unique_name:orcl

service_names:orcl

 

備機

IP 192.168.1.183

主機名 :chen03

OS:Red Hat Enterprise Linux Server release 6.4 (Santiago)

oracle:11.2.0.1.0

SID:orcl

db_unique_name:db01

service_names:db01

 

一:主機 , 備機分別配置 hosts 檔案

 

192.168.1.181

[root@chen01 ~]# vim /etc/hosts

192.168.1.181 chen01

192.168.1.183 chen03

 

[root@chen01 ~]# vim /etc/sysconfig/network

 

192.168.1.183

[root@chen03 ~]# vim /etc/hosts

192.168.1.183 chen03

192.168.1.181 chen01

 

二:主機修改為歸檔模式,強制寫日誌

 

192.168.1.181

 

SQL> startup mount

 

SQL> alter database archivelog;

 

SQL> select force_logging from v$database;

 

FOR

---

NO

 

SQL> alter database force logging;

 

Database altered.

 

SQL> select force_logging from v$database;

 

FOR

---

YES

 

三:主機建立密碼檔案

 

192.168.1.181

 

[oracle@chen01 ~]$ cd $ORACLE_HOME/network/admin

 

[oracle@chen01 admin]$ orapwd file=orapworcl password=oracle

 

 

四:主機配置 standby redolog

最佳效能模式可以忽略,如果將來變成備庫且要轉為其它兩種模式則要建立

 

192.168.1.181

 

standby redolog 的組數參考公式: (online redolog 組數 + 1) * 資料庫執行緒數;單機執行緒數為 1 RAC 一般為 2

standby redolog 的組成員數和大小也儘量和 online redolog 一樣。

 

SQL> select * from v$logfile;

 

    GROUP# STATUS  TYPE    MEMBER                                   IS_

---------- ------- ------- ---------------------------------------- ---

         3         ONLINE  /u01/app/oracle/oradata/orcl/redo03.log  NO

         2         ONLINE  /u01/app/oracle/oradata/orcl/redo02.log  NO

         1         ONLINE  /u01/app/oracle/oradata/orcl/redo01.log  NO

 

SQL> select group#,members,bytes/1024/1024||'M' M from v$log;

 

    GROUP#    MEMBERS M

---------- ---------- -----------------------------------------

         1          1 50M

         2          1 50M

         3          1 50M

 

SQL> alter database add standby logfile

  2  group 4 ('/u01/app/oracle/oradata/orcl/stdby_redo04.log') size 50M,

  3  group 5 ('/u01/app/oracle/oradata/orcl/stdby_redo05.log') size 50M,

  4  group 6 ('/u01/app/oracle/oradata/orcl/stdby_redo06.log') size 50M;

 

Database altered.

 

SQL> select * from v$logfile order by group#;

 

    GROUP# STATUS  TYPE    MEMBER                                        IS_

---------- ------- ------- --------------------------------------------- ---

         1         ONLINE  /u01/app/oracle/oradata/orcl/redo01.log       NO

         2         ONLINE  /u01/app/oracle/oradata/orcl/redo02.log       NO

         3         ONLINE  /u01/app/oracle/oradata/orcl/redo03.log       NO

         4         STANDBY /u01/app/oracle/oradata/orcl/stdby_redo04.log NO

         5         STANDBY /u01/app/oracle/oradata/orcl/stdby_redo05.log NO

         6         STANDBY /u01/app/oracle/oradata/orcl/stdby_redo06.log NO

 

6 rows selected.

 

SQL> select group#,members,bytes/1024/1024||'M' M from v$log;

 

    GROUP#    MEMBERS M

---------- ---------- -----------------------------------------

         1          1 50M

         2          1 50M

         3          1 50M

 

SQL> select group#,bytes/1024/1024||'M' M from v$standby_log;

 

    GROUP# M

---------- -----------------------------------------

      4 50M

      5 50M

      6 50M

 

 

五:設定主庫初始化引數

 

192.168.1.181

 

備份引數檔案

SQL> create pfile='/home/oracle/pfile.ora' from spfile;

 

[oracle@chen01 dbs]$ vim initorcl.ora

*.fal_client='ORCL'

*.fal_server='DB01'

*.log_archive_config='dg_config=(orcl,db01)'

*.log_archive_dest_1='location=/home/oracle/arch_orcl valid_for=(all_logfiles,all_roles) db_unique_name=orcl'

*.log_archive_dest_2='service=db01 LGWR ASYNC valid_for=(online_logfiles,primary_roles) db_unique_name=db01'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.standby_archive_dest='location=/home/oracle/arch_orcl'

*.standby_file_management='AUTO'

*.db_unique_name='orcl'

 

 

 

備份主庫資料檔案

 

192.168.1.181

 

SQL> alter database create standby controlfile as '/home/oracle/stdby_control01.ctl';

SQL> shutdown immediate

[root@chen01 ~]# tar -zcvf arch.tar arch_orcl/

[root@chen01 ~]# tar -zcvf uu.tar /u01

[root@chen01 ~]# scp arch.tar 192.168.1.183:/root

[root@chen01 ~]# scp uu.tar 192.168.1.183:/root

[root@chen01 ~]# scp stdby_control01.ctl 192.168.1.183:/root

 

 

配置備庫

 

[root@chen03 ~]# tar -zxvf arch.tar

[root@chen03 ~]# tar -zxvf uu.tar

[root@chen03 ~]# mkdir /u01

[root@chen03 ~]# mv u01/* /u01

[root@chen03 ~]# cp stdby_control01.ctl /u01/app/oracle/oradata/orcl/control01.ctl

[root@chen03 ~]# cp stdby_control01.ctl stdby_control02.ctl

[oracle@chen03 dbs]$ cp stdby_control02.ctl /u01/app/oracle/flash_recovery_area/orcl/control02.ctl

[root@chen03 ~]# chown -R oracle.oinstall /u01

 

 

配置備庫引數

[oracle@chen03 ~]$ cd $ORACLE_HOME/dbs

 

[oracle@chen03 dbs]$ vim initorcl.ora

*.control_files='/u01/app/oracle/oradata/orcl/control01.ctl','/u01/app/oracle/flash_recovery_area/orcl/control02.ctl'

*.db_name='orcl'

*.fal_client='DB01'

*.fal_server='ORCL'

*.log_archive_config='dg_config=(orcl,db01)'

*.log_archive_dest_1='location=/home/oracle/arch_orcl valid_for=(all_logfiles,all_roles) db_unique_name=db01'

*.log_archive_dest_2='service=orcl ARCH ASYNC valid_for=(online_logfiles,primary_roles) db_unique_name=orcl'

*.log_archive_dest_state_1='ENABLE'

*.log_archive_dest_state_2='ENABLE'

*.standby_archive_dest='location=/home/oracle/arch_orcl'

*.standby_file_management='AUTO'

*.db_unique_name='db01'

 

                                    

  配置網路

 

xhost +

netmgr

 

或者

 

192.168.1.183

 

192.168.1.181 (同 183

 

[oracle@chen03 admin]$ pwd

/u01/app/oracle/product/11.2.0/network/admin

 

[oracle@chen03 admin]$ ls

listener.ora  orapworcl  samples  shrept.lst  sqlnet.ora  tnsnames.ora

 

[oracle@chen03 admin]$ vim listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/listener.ora

# Generated by Oracle configuration tools.

 

SID_LIST_LISTENER =

  (SID_LIST =

    (SID_DESC =

      (GLOBAL_DBNAME = orcl)

      (ORACLE_HOME = /u01/app/oracle/product/11.2.0)

      (SID_NAME = ORCL)

    )

  )

 

LISTENER =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = chen03)(PORT = 1521))

  )

 

ADR_BASE_LISTENER = /u01/app/oracle

 

 

[oracle@chen03 admin]$ vim tnsnames.ora

# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/network/admin/tnsnames.ora

# Generated by Oracle configuration tools.

 

LISTENER_ORCL =

  (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

 

 

DB01 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.183)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = db01)

    )

  )

 

ORCL =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.181)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = orcl)

 

 

[oracle@chen03 admin]$ tnsping db_orcl

 

[oracle@chen03 admin]$ tnsping db_db01

 

 

啟動 DG

 

1

啟用備用資料庫

SQL > STARTUP MOUNMT;

 

2

啟動主庫

SQL> startup

 

 

192.168.1.183

 

SQL> col dest_name for a25

 

SQL> select dest_name,status from v$archive_dest_status;

 

DEST_NAME         STATUS

------------------------- ---------

LOG_ARCHIVE_DEST_1        VALID

LOG_ARCHIVE_DEST_2        VALID

STANDBY_ARCHIVE_DEST      VALID

 

SQL> select database_role,protection_mode,protection_level from v$database;

 

DATABASE_ROLE    PROTECTION_MODE      PROTECTION_LEVEL

---------------- -------------------- --------------------

PHYSICAL STANDBY MAXIMUM PERFORMANCE  MAXIMUM PERFORMANCE

  歡迎關注我的微信公眾號"IT小Chen",共同學習,共同成長!!!

DG_安裝三

DG_安裝三



 

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

相關文章