搜索
首页数据库mysql教程Oracle 单表流复制 stream

把Oracle单表流复制搞定,由于oracle stream 操作步骤多,之前遇到许多问题,没有理清思路或者说自己对此的理解不够,所以失败。

把Oracle单表流复制搞定,由于oracle stream 操作步骤多,之前遇到许多问题,

没有理清思路或者说自己对此的理解不够,所以失败。对于重要表,流复制类似dataguard应用日志,主服务器

捕获,然后传递,从服务器接受,如此而以。简单记录一下主要步骤。

1 主服务器 os: windows  sid:rman  数据库版本10.2.0.1

  从服务器 os:   windows   sid  format  数据库版本10.2.0.1

2 主、从数据库分别执行如下的语句:
Sqlplus ‘/ as sysdba’
alter system set aq_tm_processes=2 scope=both;
alter system set global_names=true scope=both;
alter system set job_queue_processes=10 scope=both;
alter system set parallel_max_servers=20 scope=both;
alter system set undo_retention=3600 scope=both;
alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
alter system set streams_pool_size=25M scope=spfile;--这个我没执行,理由是oracle自动分配了
alter system set utl_file_dir='*' scope=spfile;
alter system set open_links=4 scope=spfile;

3 主从机设置归档 mout状态下alter database archivelog 另开启alter system set  log_archive_start=true;

  查看归档是否成功select recid, name, first_time from v$archived_log;

4 主从机表空间和用户

  create tablespace stream_tbs datafile 'g:\oracle\oradata\rman\stream01.dbf' size 200m

  autoextend on extent management local uniform size 1m segment space management auto;

表空间已创建。

-- 创建streams管理用户,并授予dba权限

JSSWEB> create user test identified by test default tablespace stream_tbs;

用户已创建。

--将logminer的数据字典从system表空间转移到新建的表空间,防止撑满system表空间
execute dbms_logmnr_d.set_tablespace('tbs_stream');

-- 由于streams用户操作需要较多权限,此处仅用于演示,简便期间直接授予dba权限

 授权test管理用户

JSSWEB> grant dba to test;

begin
dbms_streams_auth.grant_admin_privilege(
grantee => 'test',
grant_privileges => true);
end;


5 主从机表空间和用户

  create tablespace stream_tbs datafile 'd:\oracle\oradata\rman\stream01.dbf' size 200m

  autoextend on extent management local uniform size 1m segment space management auto;

表空间已创建。

-- 创建streams管理用户,并授予dba权限

JSSWEB> create user strmadmin identified by strmadmin default tablespace stream_tbs;

用户已创建。

--将logminer的数据字典从system表空间转移到新建的表空间,防止撑满system表空间
execute dbms_logmnr_d.set_tablespace('tbs_stream');

-- 由于streams用户操作需要较多权限,此处仅用于演示,简便期间直接授予dba权限

 授权test管理用户

JSSWEB> grant dba to strmadmin ;

begin
dbms_streams_auth.grant_admin_privilege(
grantee => 'strmadmin',
grant_privileges => true);
end;


6 配置网络连接

 主数据库(tnsnames.ora)中添加从数据库的配置。
 RMAN =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.103)(PORT = 1521))
)
(CONNECT_DATA =
(SID = rman)
(SERVER = DEDICATED)
)
)
配置从环境tnsnames.ora
从数据库(tnsnames.ora)中添加主数据库的配置。
FORMAT =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.104)(PORT = 1521))
)
(CONNECT_DATA =
(SID = format)
(SERVER = DEDICATED)
)
)


7 创建database link

  主:create database link format connect to strmadmin identified by strmadmin using 'format';

  从:create database link rman  connect to strmadmin identified by strmadmin using 'rman '; 

 然后相互tnsping 或 select sysdate from dual@format/rman;

8  主库 exec dbms_streams_adm.set_up_queue();

    从库  exec dbms_streams_adm.set_up_queue();

 

9 创建捕获规则 

  begin

   dbms_streams_adm.add_table_rules(

   table_name => 'scott.emp',

   streams_type => 'capture',

   streams_name =>'capture_stream',

   queue_name => 'test.streams_queue',

   include_dml => true,

   include_ddl => true,

   inclusion_rule => true);

   end;
--创建传播规则

begin

   dbms_streams_adm.add_table_propagation_rules(

   table_name =>'scott.emp',

   streams_name => 'sour_to_targ',

   source_queue_name =>'test.streams_queue',

   destination_queue_name => 'strmadmin.streams_queue@format',

   include_dml => true,

   include_ddl => true,

   source_database =>'rman',

   inclusion_rule => true,

   queue_to_queue => true);

 end;

select capture_name,status from dba_capture;

CAPTURE_NAME                   STATUS

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

CAPTURE_STREAM                 DISABLED

linux

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
MySQL字符串类型:存储,性能和最佳实践MySQL字符串类型:存储,性能和最佳实践May 10, 2025 am 12:02 AM

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)长度,始终使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

了解MySQL字符串类型:VARCHAR,文本,char等了解MySQL字符串类型:VARCHAR,文本,char等May 10, 2025 am 12:02 AM

mySqlStringTypesIncludeVarChar,文本,char,enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptOptoPeptoPepecifientlimit.2)textisidealforlargetStortStorStoverStorextorewiteWithoutAdefinedLengthl.3)charlisfixed-Length

MySQL中的字符串数据类型是什么?MySQL中的字符串数据类型是什么?May 10, 2025 am 12:01 AM

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

如何向新的MySQL用户授予权限如何向新的MySQL用户授予权限May 09, 2025 am 12:16 AM

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

如何在MySQL中添加用户:逐步指南如何在MySQL中添加用户:逐步指南May 09, 2025 am 12:14 AM

toadduserInmysqleffectection andsecrely,theTheSepsps:1)USEtheCreateuserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNectalRevileSaryPrivilegesSustate,usiveleanttatement,AdheringTotheTeprinciplelastPrevilegege.3)

mysql:添加具有复杂权限的新用户mysql:添加具有复杂权限的新用户May 09, 2025 am 12:09 AM

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)创建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。3)GrantWriteAccessto'

mysql:字符串数据类型和coltrationsmysql:字符串数据类型和coltrationsMay 09, 2025 am 12:08 AM

MySQL中的字符串数据类型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序规则(Collations)决定了字符串的比较和排序方式。1.CHAR适合固定长度字符串,VARCHAR适合可变长度字符串。2.BINARY和VARBINARY用于二进制数据,BLOB和TEXT用于大对象数据。3.排序规则如utf8mb4_unicode_ci忽略大小写,适合用户名;utf8mb4_bin区分大小写,适合需要精确比较的字段。

MySQL:我应该在Varchars上使用什么长度?MySQL:我应该在Varchars上使用什么长度?May 09, 2025 am 12:06 AM

最佳的MySQLVARCHAR列长度选择应基于数据分析、考虑未来增长、评估性能影响及字符集需求。1)分析数据以确定典型长度;2)预留未来扩展空间;3)注意大长度对性能的影响;4)考虑字符集对存储的影响。通过这些步骤,可以优化数据库的效率和扩展性。

See all articles

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

Video Face Swap

Video Face Swap

使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热工具

VSCode Windows 64位 下载

VSCode Windows 64位 下载

微软推出的免费、功能强大的一款IDE编辑器

Dreamweaver Mac版

Dreamweaver Mac版

视觉化网页开发工具

mPDF

mPDF

mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

禅工作室 13.0.1

禅工作室 13.0.1

功能强大的PHP集成开发环境

Dreamweaver CS6

Dreamweaver CS6

视觉化网页开发工具