ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 高级复制-3、主体定义站点上的操作

高级复制-3、主体定义站点上的操作

原创 Linux操作系统 作者:lirenquan 时间:2011-01-13 18:51:17 0 删除 编辑

1、创建repadmin用户,用于管理高级复制
create user repadmin identified by repadmin default tablespace users temporary tablespace temp;
execute dbms_defer_sys.register_propagator('repadmin');
grant execute any procedure to repadmin;
execute dbms_repcat_admin.grant_admin_any_repgroup('repadmin');
execute dbms_repcat_admin.grant_admin_any_schema(username => '"REPADMIN"');
grant comment any table to repadmin;
grant lock any table to repadmin;
grant select any dictionary to repadmin;

SQL> desc dba_tablespaces;      
 Name                                      Null?    Type
 ----------------------------------------- -------- ----------------------------
 TABLESPACE_NAME                           NOT NULL VARCHAR2(30)
 BLOCK_SIZE                                NOT NULL NUMBER
 INITIAL_EXTENT                                     NUMBER
 NEXT_EXTENT                                        NUMBER
 MIN_EXTENTS                               NOT NULL NUMBER
 MAX_EXTENTS                                        NUMBER
 PCT_INCREASE                                       NUMBER
 MIN_EXTLEN                                         NUMBER
 STATUS                                             VARCHAR2(9)
 CONTENTS                                           VARCHAR2(9)
 LOGGING                                            VARCHAR2(9)
 FORCE_LOGGING                                      VARCHAR2(3)
 EXTENT_MANAGEMENT                                  VARCHAR2(10)
 ALLOCATION_TYPE                                    VARCHAR2(9)
 PLUGGED_IN                                         VARCHAR2(3)
 SEGMENT_SPACE_MANAGEMENT                           VARCHAR2(6)
 DEF_TAB_COMPRESSION                                VARCHAR2(8)
 RETENTION                                          VARCHAR2(11)
 BIGFILE                                            VARCHAR2(3)

SQL> select tablespace_name,contents from dba_tablespaces;

TABLESPACE_NAME                                              CONTENTS
------------------------------------------------------------ ------------------
SYSTEM                                                       PERMANENT
UNDOTBS1                                                     UNDO
SYSAUX                                                       PERMANENT
TEMP                                                         TEMPORARY
USERS                                                        PERMANENT
EXAMPLE                                                      PERMANENT
TEST                                                         PERMANENT

7 rows selected.

SQL> create user repadmin identified by repadmin default tablespace users temporary tablespace temp;

User created.

SQL> execute dbms_defer_sys.register_propagator('repadmin');                                                                     
grant execute any procedure to repadmin;
execute dbms_repcat_admin.grant_admin_any_repgroup('repadmin');
execute dbms_repcat_admin.grant_admin_any_schema(username => '"REPADMIN"');
grant comment any table to repadmin;
grant lock any table to repadmin;
grant select any dictionary to repadmin;

PL/SQL procedure successfully completed.

SQL>
Grant succeeded.

SQL>
PL/SQL procedure successfully completed.

SQL>
PL/SQL procedure successfully completed.

SQL>
Grant succeeded.

SQL>
Grant succeeded.

SQL>
Grant succeeded.

2、登录snap 数据库,重复上面的操作,创建public dblink 以及repadmin 用户(这个在非主体定义站点实现)

3、创建公共的dblink连接到复制站点
CREATE PUBLIC DATABASE LINK SNAP_PUBLIC_COM connect to repadmin identified by repadmin  USING 'REPLICATION_SITE';

SQL> CREATE PUBLIC DATABASE LINK SNAP_PUBLIC_COM connect to repadmin identified by repadmin  USING 'REPLICATION_SITE';

Database link created.

SQL> select * from global_name;

GLOBAL_NAME
--------------------------------------------------------------------------------
ORCL.COM

SQL> select * from global_name@snap_public_com;
select * from global_name@snap_public_com
                          *
ERROR at line 1:
ORA-02085: database link SNAP_PUBLIC_COM.COM connects to CHRIST.COM


SQL> select * from user_tables@snap_public_com;
select * from user_tables@snap_public_com
                          *
ERROR at line 1:
ORA-02085: database link SNAP_PUBLIC_COM.COM connects to CHRIST.COM

错误原因为:
当global名设置为TRUE时,DB LINK的名称必须与GLOBAL NAME保持一致

CREATE PUBLIC DATABASE LINK SNAP.COM connect to repadmin identified by repadmin  USING 'REPLICATION_SITE';


4、创建主体复制组,创建主体复制组,添加复制对象,操作的数据库将称为主体定义站点
添加复制组
execute dbms_repcat.create_master_repgroup('REP_MYTEST');

SQL> set linesize 200;
SQL> select gname,master,status from dba_repgroup where gname='REP_MYTEST';

GNAME                                                        MA STATUS
------------------------------------------------------------ -- ------------------
REP_MYTEST                                                   Y  QUIESCED

5、添加主体复制站点支持:
execute dbms_repcat.add_master_database  (gname=>'REP_MYTEST',master=>'SNAP.COM',  use_existing_objects=>true,copy_rows=>false, propagation_mode => 'synchronous');

SQL> execute dbms_repcat.add_master_database  (gname=>'REP_MYTEST',master=>'SNAP.COM',  use_existing_objects=>true,copy_rows=>false, propagation_mode => 'synchronous');

PL/SQL procedure successfully completed.

SQL> col gname for a20;
SQL> select gname,master,status from dba_repgroup where gname='REP_MYTEST';

GNAME                MA STATUS
-------------------- -- ------------------
REP_MYTEST           Y  QUIESCED

SQL> col dblink for a10;
SQL> col gname for a20;
SQL> select gname,dblink,masterdef,master from dba_repsites where gname='REP_MYTEST';

GNAME                DBLINK     MA MA
-------------------- ---------- -- --
REP_MYTEST           MASTER.COM Y  Y
REP_MYTEST           SNAP.COM   N  Y

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12350275/viewspace-683776/,如需转载,请注明出处,否则将追究法律责任。

全部评论

注册时间:2010-12-24

  • 博文量
    24
  • 访问量
    109531