配置GG監控庫:192.168.9.144

Michael_DD發表於2014-10-31
接GG配置:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
配置監控庫:192.168.9.144
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

1  源庫與目標庫均建立監控表
  ggsync.gg_sync_testdb
(如存在,則不需要建立)
CREATE TABLE GGSYNC.GG_SYNC_TESTDB
(
SOURCE_DB VARCHAR2 (20 BYTE),
TARGET_DB VARCHAR2 (20 BYTE),
EXT_NAME VARCHAR2 (20 BYTE),
DPE_NAME VARCHAR2 (20 BYTE),
REP_NAME VARCHAR2 (20 BYTE),
CHECK_FLAG VARCHAR2 (20 BYTE),
CHECK_TIME VARCHAR2 (30 BYTE) DEFAULT SYSDATE
)
TABLESPACE DBADATATBS;
CREATE UNIQUE INDEX GGSYNC.PK_GG_SYNC_TESTDB
ON GGSYNC.GG_SYNC_TESTDB (SOURCE_DB, TARGET_DB);
ALTER TABLE GGSYNC.GG_SYNC_TESTDB ADD (
CONSTRAINT PK_GG_SYNC_TESTDB
PRIMARY KEY
(SOURCE_DB,TARGET_DB)
USING INDEX GGSYNC.PK_GG_SYNC_TESTDB);
GRANT SELECT,
INSERT,
UPDATE,
DELETE
ON GGSYNC.GG_SYNC_TESTDB
TO DBMON;
 建立心跳錶更新儲存過程
CREATE OR REPLACE PROCEDURE GGSYNC.PROC_GG_SYNC_UPDATE
AS
v_time VARCHAR2 (30 BYTE);
v_count NUMBER;
v_table VARCHAR2 (50 BYTE);
v_sql VARCHAR2 (1000 BYTE);
v_eor VARCHAR2 (200 BYTE);
v_dbname VARCHAR2 (30 BYTE);
BEGIN
SELECT TO_CHAR (SYSDATE, 'YYYY-MM-DD HH24:MI:SS') INTO v_time FROM
DUAL;
SELECT NAME
INTO V_DBNAME
FROM V$DATABASE
WHERE ROWNUM = 1;
v_table := 'ggsync.gg_sync_' || v_dbname;
v_sql :=
'select count(*) from '
|| v_table
|| ' where source_db=''ALL'' and target_db=''ALL''';
EXECUTE IMMEDIATE v_sql INTO v_count;
IF v_count = 0
THEN
BEGIN
v_sql :=
'insert into '
|| v_table
|| ' values(''ALL'',''ALL'',''E_ALL'',''T_ALL'',''R_ALL'',''Y'','''
|| v_time
|| ''')';
EXECUTE IMMEDIATE v_sql;
COMMIT;
END;
ELSE
BEGIN
v_sql :=
'update '
|| v_table
|| ' set check_time='''
|| v_time
|| ''' where source_db=''ALL'' and target_db=''ALL''';
EXECUTE IMMEDIATE v_sql;
COMMIT;
END;
END IF;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
NULL;
END;
/
 建立心跳錶自動更新JOB(GGSYNC 下建立)
DECLARE
X NUMBER;
BEGIN
SYS.DBMS_JOB.SUBMIT (job => X,
what => 'begin ggsync.proc_gg_sync_update; end;',
next_date => SYSDATE,
interval => 'sysdate+1/1440',
no_parse => FALSE);
SYS.DBMS_OUTPUT.PUT_LINE ('Job Number is: ' || TO_CHAR (x));
COMMIT;
END;
/
(已完成)

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
2 配置監控表的GG 同步
新增ggsync.gg_sync_testdb 的附加日誌;
抽取程式,傳輸程式,恢復程式中預設新增表ggsync.gg_sync_testdb 的同步;
(已完成)

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
3 監控資料庫中新增源庫DBLINK
[oracle@test1 ~]:testdb> sqlplus sxmon/123456@192.168.9.144:1521/dbadb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 09:51:56 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

create database link testdb_link
connect to dbmon identified by "123456"
 using '(DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.142)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = testdb)
    )
  )';

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
4 監控資料庫中新增源庫配置(大寫)
[oracle@test1 ~]:testdb> sqlplus sxmon/123456@192.168.9.144:1521/dbadb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 09:51:56 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> create table db_name_list (db_name varchar2(15) not null, link_name varchar2(15) not null, comments varchar2(15) not null);
SQL> INSERT INTO db_name_list (db_name, link_name, comments) VALUES (UPPER('TESTDB'), UPPER('TESTDB_LINK'), '測試庫1');
SQL> commit;

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
5 監控資料庫中新增目標庫DBLINK
[oracle@test1 ~]:testdb> sqlplus sxmon/123456@192.168.9.144:1521/dbadb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 09:51:56 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>

CREATE PUBLIC DATABASE LINK O01FDR_link
CONNECT TO DBMON
IDENTIFIED BY "123456"
USING '(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.143)(PORT = 1521))
)
(CONNECT_DATA =
(SERVER = DEDICATED)
(sid = O01FDR)
)
)';

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
6 監控資料庫中新增目標庫配置(大寫)
[oracle@test1 ~]:testdb> sqlplus sxmon/123456@192.168.9.144:1521/dbadb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 09:51:56 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
SQL> INSERT INTO db_name_list (db_name, link_name, comments) VALUES (UPPER('O01FDR'), UPPER('O01FDR_LINK'), '測試庫1');
SQL> commit;

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

7 監控資料庫中新增GG 同步配置
[oracle@test1 ~]:testdb> sqlplus sxmon/123456@192.168.9.144:1521/dbadb

SQL*Plus: Release 11.2.0.4.0 Production on Fri Oct 31 09:51:56 2014

Copyright (c) 1982, 2013, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL>
create table gg_sync_list (
source_db varchar2(20) not null,
target_db varchar2(20) not null,
ext_name varchar2(20) not null,
dpe_name varchar2(20) not null,
rep_name varchar2(20) not null,
check_flag varchar2(20) not null);

SQL>
INSERT INTO gg_sync_list (SOURCE_DB,
TARGET_DB,
EXT_NAME,
DPE_NAME,
REP_NAME,
CHECK_FLAG)
VALUES (UPPER ('TESTDB'),
UPPER ('O01FDR'),
UPPER ('E_TESTDB'),
UPPER ('T_O01FDR'),
UPPER ('R_TESTDB'),
'Y');

SQL>
COMMIT;

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

相關文章