OGG搭建(rac到-->單例項)

quanshengaa發表於2016-06-17
開啟歸檔。
在兩個節點分別建立本地目錄/arch1

點選(此處)摺疊或開啟

  1. SQL> alter system set log_archive_dest_1 ='location=/arch1' scope=both sid='*';

  2. System altered.

  3. SQL> archive log lsit
  4. SP2-0718: illegal ARCHIVE LOG option
  5. SQL> archive log list
  6. Database log mode     No Archive Mode
  7. Automatic archival     Disabled
  8. Archive destination     /arch1
  9. Oldest online log sequence 32
  10. Current log sequence     34
兩個節點都啟動到mount狀態然後,alter database archivelog; 執行完之後兩個節點再open,你懂得否則報錯:

點選(此處)摺疊或開啟

  1. SQL> alter database archivelog;
  2. alter database archivelog
  3. *
  4. ERROR at line 1:
  5. ORA-01126: database must be mounted in this instance and not open in any
  6. instance
因為我們在節點1配置ogg所以得配置NFS,讓節點1看到節點2的歸檔。
在節點2上 /etc/exports新增如下內容:

點選(此處)摺疊或開啟

  1. /arch1 *(ro)
然後啟動NFS

點選(此處)摺疊或開啟

  1. [root@rac2 ~]# service nfs start
  2. Starting NFS services:           [ OK ]
  3. Starting NFS quotas:             [ OK ]
  4. Starting NFS daemon:             [ OK ]
  5. Starting NFS mountd:             [ OK ]
在節點1上

點選(此處)摺疊或開啟

  1. [root@rac1 ~]# mkdir /arch2
  2. [root@rac1 ~]# chown -R oracle:oinstall /arch2
  3. [root@rac1 ~]# mount -t nfs 10.10.10.2:/arch1 /arch2 -o nolock
  4. [root@rac1 ~]# cd /arch2
  5. [root@rac1 arch2]# ls
  6. 1_34_876782166.dbf
新增NFS自啟


配置ASM動態註冊
Oracle 11g RAC的監聽是用grid使用者來管理的,所以用grid使用者來操作。

點選(此處)摺疊或開啟

  1. [root@rac1 ~]# su - grid
  2. [grid@rac1 ~]$ srvctl status listener
  3. Listener LISTENER is enabled
  4. Listener LISTENER is running on node(s): rac2,rac1
  5. [grid@rac1 ~]$ lsnrctl status

  6. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-SEP-2015 17:07:10

  7. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  8. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
  9. STATUS of the LISTENER
  10. ------------------------
  11. Alias LISTENER
  12. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  13. Start Date 28-SEP-2015 16:30:33
  14. Uptime 0 days 0 hr. 36 min. 36 sec
  15. Trace Level off
  16. Security ON: Local OS Authentication
  17. SNMP OFF
  18. Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
  19. Listener Log File /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
  20. Listening Endpoints Summary...
  21.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  22.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.101)(PORT=1521)))
  23.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.103)(PORT=1521)))
  24. Services Summary...
  25. Service "+ASM" has 1 instance(s).
  26.   Instance "+ASM1", status READY, has 1 handler(s) for this service...
  27. Service "prod" has 2 instance(s).
  28.   Instance "prod1", status READY, has 2 handler(s) for this service...
  29.   Instance "prod2", status READY, has 1 handler(s) for this service...
  30. Service "prodXDB" has 2 instance(s).
  31.   Instance "prod1", status READY, has 1 handler(s) for this service...
  32.   Instance "prod2", status READY, has 1 handler(s) for this service...
  33. The command completed successfully


點選(此處)摺疊或開啟

  1. SID_LIST_LISTENER =
  2.   (SID_LIST =
  3.     (SID_DESC =
  4.       (GLOBAL_DBNAME = ASM)
  5.       (ORACLE_HOME = /u01/11.2.0/grid)
  6.       (SID_NAME = +ASM1)
  7.     )
  8.   )

點選(此處)摺疊或開啟

  1. [grid@rac1 ~]$ lsnrctl status

  2. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-SEP-2015 17:07:10

  3. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  4. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
  5. STATUS of the LISTENER
  6. ------------------------
  7. Alias LISTENER
  8. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  9. Start Date 28-SEP-2015 16:30:33
  10. Uptime 0 days 0 hr. 36 min. 36 sec
  11. Trace Level off
  12. Security ON: Local OS Authentication
  13. SNMP OFF
  14. Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
  15. Listener Log File /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
  16. Listening Endpoints Summary...
  17.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  18.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.101)(PORT=1521)))
  19.   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.6.103)(PORT=1521)))
  20. Services Summary...
  21. Service "+ASM" has 1 instance(s).
  22.   Instance "+ASM1", status READY, has 1 handler(s) for this service...
  23. Service "prod" has 2 instance(s).
  24.   Instance "prod1", status READY, has 2 handler(s) for this service...
  25.   Instance "prod2", status READY, has 1 handler(s) for this service...
  26. Service "prodXDB" has 2 instance(s).
  27.   Instance "prod1", status READY, has 1 handler(s) for this service...
  28.   Instance "prod2", status READY, has 1 handler(s) for this service...
  29. The command completed successfully
  30. [grid@rac1 ~]$ echo $ORACLE_HOME
  31. /u01/11.2.0/grid
  32. [grid@rac1 home]$ cd $ORACLE_HOME
  33. [grid@rac1 grid]$ ls
  34. assistants crf dbs evm install jlib mdns ologgerd osysmond racg slax wwg
  35. auth crs dc_ocm gipc instantclient JRE mesg OPatch oui rdbms sqlplus xdk
  36. bin csmig deinstall gns inventory ldap network opmn owm relnotes srvm
  37. cdata css demo gpnp javavm lib nls oracore perl root.sh sysman
  38. cfgtoollogs ctss diagnostics has jdbc log oc4j oraInst.loc plsql rootupgrade.sh usm
  39. clone cv eons hs jdk md ohasd ord precomp scheduler utl
  40. [grid@rac1 grid]$ pwd
  41. /u01/11.2.0/grid
  42. [grid@rac1 grid]$ cd network/admin
  43. [grid@rac1 admin]$ ll
  44. total 72
  45. -rw-r--r-- 1 grid oinstall 182 Apr 8 19:34 endpoints_listener.ora
  46. -rw-r--r-- 1 grid oinstall 184 Apr 8 19:34 listener1504087PM3409.bak
  47. -rw-r--r-- 1 grid oinstall 350 May 20 12:04 listener15052012PM0404.bak
  48. -rw-r--r-- 1 grid oinstall 350 Apr 8 19:34 listener.ora
  49. -rw-r--r-- 1 grid oinstall 184 Apr 8 19:20 listener.ora.bak.rac1
  50. drwxr-xr-x 2 grid oinstall 4096 Apr 8 18:44 samples
  51. -rw-r--r-- 1 grid oinstall 205 May 11 2011 shrept.lst
  52. -rw-r--r-- 1 grid oinstall 210 May 20 12:04 sqlnet15052012PM0404.bak
  53. -rw-r--r-- 1 grid oinstall 210 Apr 8 19:34 sqlnet.ora
  54. [grid@rac1 admin]$ cat listener.ora
  55. LISTENER=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER))))        # line added by Agent
  56. LISTENER_SCAN1=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER_SCAN1))))        # line added by Agent
  57. ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER_SCAN1=ON        # line added by Agent
  58. ENABLE_GLOBAL_DYNAMIC_ENDPOINT_LISTENER=ON        # line added by Agent
  59. [grid@rac1 admin]$ vim listener.ora
  60. [grid@rac1 admin]$
  61. [grid@rac1 admin]$ lsnrctl reload

  62. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-SEP-2015 17:25:09

  63. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  64. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
  65. The command completed successfully
  66. [grid@rac1 admin]$ lsnrctl status

  67. LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 28-SEP-2015 17:25:12

  68. Copyright (c) 1991, 2011, Oracle. All rights reserved.

  69. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
  70. STATUS of the LISTENER
  71. ------------------------
  72. Alias LISTENER
  73. Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
  74. Start Date 28-SEP-2015 16:30:33
  75. Uptime 0 days 0 hr. 54 min. 39 sec
  76. Trace Level off
  77. Security ON: Local OS Authentication
  78. SNMP OFF
  79. Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
  80. Listener Log File /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
  81. Listening Endpoints Summary...
  82.   (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  83. Services Summary...
  84. Service "ASM" has 1 instance(s).
  85.   Instance "+ASM1", status UNKNOWN, has 1 handler(s) for this service...
  86. The command completed successfully
節點而一樣

點選(此處)摺疊或開啟

  1. SID_LIST_LISTENER =
  2.   (SID_LIST =
  3.     (SID_DESC =
  4.       (GLOBAL_DBNAME = ASM)
  5.       (ORACLE_HOME = /u01/11.2.0/grid)
  6.       (SID_NAME = +ASM2)
  7.     )
  8.   )




配置TNS檔案

點選(此處)摺疊或開啟

  1. RAC_11G =
  2.    (DESCRIPTION =
  3.      (ADDRESS_LIST =
  4.        (LOAD_BALANCE = yes)
  5.        (FAILOVER = ON)
  6.        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.103)(PORT = 1521))
  7.        (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.104)(PORT = 1521))
  8.      )
  9.      (CONNECT_DATA =
  10.       (SERVICE_NAME = prod)
  11.       (failover_mode=(type=select)(mothod=basic))
  12.      )
  13.    )

  14. ASM =
  15.    (DESCRIPTION =
  16.      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.6.103)(PORT = 1521))
  17.      (CONNECT_DATA =
  18.       (SERVCE = DEDICATED)
  19.       (SERVICE_NAME = ASM)
  20.       (INSTANCE_NAME = +ASM1)
  21.       (UR = A)
  22.      )
  23.    )
注意這裡連線ASM的配置中必須新增(UR = A),該參數列示允許遠端呼叫,這個必須有,否則ASM例項不能連線。





安裝ogg軟體




繼續... ...

安裝完成後將資料庫配置成歸檔,強制日誌,附加日誌。

點選(此處)摺疊或開啟

  1. SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;

  2. LOG_MODE SUPPLEME FOR
  3. ------------ -------- ---
  4. ARCHIVELOG NO NO

  5. SQL> alter database force logging;

  6. Database altered.

  7. SQL> alter database add supplemental log data;

  8. Database altered.

  9. SQL> select log_mode,supplemental_log_data_min,force_logging from v$database;

  10. LOG_MODE SUPPLEME FOR
  11. ------------ -------- ---
  12. ARCHIVELOG YES YES
建立ogg單獨的表空間及使用者這是12c必須做的。

點選(此處)摺疊或開啟

  1. SQL> create tablespace ggs datafile '+DATA_MORMAL' size 100M autoextend on;

  2. Tablespace created.

  3. SQL> create user ggs identified by ggs default tablespace ggs temporary tablespace temp;

  4. User created.

  5. SQL> grant connect ,resource to ggs;

  6. Grant succeeded.

  7. SQL> grant execute on utl_file to ggs;

  8. Grant succeeded.



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

相關文章