因项目预研需要,所以想找一个能够满足内外网数据库同步方案,前面先是测试了一下Oracle的高级复制功能,未果;才转而进行Oracle
因项目预研需要,所以想找一个能够满足内外网数据库同步方案,前面先是测试了一下Oracle的高级复制功能,未果;才转而进行Oracle Stream的测试,,大概是我水平太差了,前后测试了3.5遍总算把Oracle Stream运行正常起来了。
错误的原因其实称不上原因,无他,读文档读的不细致,手误、本身对这方面也缺乏理论认识。
关于Oracle流的原理
Oracle 流能够共享信息。Oracle流每个单元的共享信息来自于消息,我们可以在流中共享这些消息。流可以在同一个数据库或不同数据库之间传播信息。”流路由”指定信息到达特定的目的地。流比起传统的在不同数据库之间捕获、管理、共享消息的解决方案,有着更强大的功能和灵活性。流提供的功能可用于分布式企业程序、数据仓库和高可用性解决方案。我们可以在同一时刻使用oracle流的所有功能。我们可以使用流的新功能而不会严重影响数据库的性能。
使用Oracle流,我们可以控制流里的信息,流的流向,流进入目标数据库时,消息怎样运作,中止流。通过配置流,可以满足我们的特殊需求。基于我们的特殊情况,流可以在数据库里自动捕获、传播和管理DML、DDL消息。我们可以把用户定义的消息放入流中,流可以自动把信息传播到其它数据库或应用程序。当消息到达目的数据库时,流可以根据我们的设定应用它们。
本文主要参考文档《Step by step 配置Oracle Stream》杨宝秋(hrb_qiuyb)
《stream_concepts_administration_读书笔记.doc》
试验环境采用虚拟机方式,操作系统Windows2003,Oracle版本10.2.0
数据源机器配置
目标机器配置
计算机名
Source
Dest
IP地址
192.168.23.130
192.168.23.131
SID
Source
Dest
第一步:进行Stream前的参数配置,Source和Dest机器上均运行,运行命令可完全一致
SQL> conn sys/inxite as sysdba;
已连接。
SQL> alter system set aq_tm_processes=2 scope=both;
系统已更改。
SQL> alter system set global_names=true scope=both;
系统已更改。
SQL> alter system set job_queue_processes=20 scope=both;
系统已更改。
SQL> alter system set parallel_max_servers=20 scope=both;
系统已更改。
SQL> alter system set undo_retention=3600 scope=both;
系统已更改。
SQL> alter system set nls_date_format='YYYY-MM-DD HH24:MI:SS' scope=spfile;
系统已更改。
SQL> alter system set streams_pool_size=25M scope=spfile;
系统已更改。
SQL> alter system set utl_file_dir='*' scope=spfile;
系统已更改。
SQL> alter system set open_links=4 scope=spfile;
系统已更改。
SQL> alter system set log_archive_dest='e:/OracleDB/arch' scope=spfile;
系统已更改。
SQL> alter system set log_archive_start=TRUE scope=spfile;
系统已更改。
SQL> alter system set log_archive_format='arch%t_%s_%r.arc' scope=spfile;
系统已更改。
第二步:查看系统归档状态(双机可以同时检查,检查方式完全一致)
SQL> shutdown immediate
数据库已经关闭。
已经卸载数据库。
ORACLE 例程已经关闭。
SQL> startup mount
ORA-32004: obsolete and/or deprecated parameter(s) specified
ORACLE 例程已经启动。
Total System Global Area
167772160 bytes
Fixed Size
1247900 bytes
Variable Size
92276068 bytes
Database Buffers
71303168 bytes
Redo Buffers
2945024 bytes
数据库装载完毕。
SQL> alter database archivelog;
数据库已更改。
SQL> alter database open;
数据库已更改。
SQL> archive log list;
数据库日志模式
存档模式
自动存档
启用
存档终点
USE_DB_RECOVERY_FILE_DEST
最早的联机日志序列
1
下一个存档日志序列
2
当前日志序列
2
SQL>
第三步:创建Stream用户和表空间(双机可以同时设置,设置方式完全一致)
#创建主环境的Stream专用表空间
SQL> create tablespace tbs_stream datafile 'e:/OracleDB/tbs_stream01.dbf'
2
size 100m autoextend on next 100m maxsize 1000m segment space management auto;
表空间已创建。
#将logminer 的数据字典从system表空间转移到新建的表空间,防止撑满system表空间
SQL> execute dbms_logmnr_d.set_tablespace('tbs_stream');
PL/SQL 过程已成功完成。
#创建Stream管理用户
SQL> create user strmadmin identified by strmadmin default tablespace tbs_stream
temporary tablespace temp;
用户已创建。
#授权Stream管理用户
SQL> grant connect,resource,dba,aq_administrator_role to strmadmin;
授权成功。
SQL> begin
2
dbms_streams_auth.grant_admin_privilege(
3
grantee => 'strmadmin',
4
grant_privileges => true);
5
end;
6
/
PL/SQL 过程已成功完成。
第四步:配置各自双方的数据库连接
在source机器上添加dest数据源,名称为dest
在dest机器上添加source数据源,名称为source

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

ToaddusersinMySQLeffectivelyandsecurely,followthesesteps:1)UsetheCREATEUSERstatementtoaddanewuser,specifyingthehostandastrongpassword.2)GrantnecessaryprivilegesusingtheGRANTstatement,adheringtotheprincipleofleastprivilege.3)Implementsecuritymeasuresl

ToaddanewuserwithcomplexpermissionsinMySQL,followthesesteps:1)CreatetheuserwithCREATEUSER'newuser'@'localhost'IDENTIFIEDBY'password';.2)Grantreadaccesstoalltablesin'mydatabase'withGRANTSELECTONmydatabase.TO'newuser'@'localhost';.3)Grantwriteaccessto'

The string data types in MySQL include CHAR, VARCHAR, BINARY, VARBINARY, BLOB, and TEXT. The collations determine the comparison and sorting of strings. 1.CHAR is suitable for fixed-length strings, VARCHAR is suitable for variable-length strings. 2.BINARY and VARBINARY are used for binary data, and BLOB and TEXT are used for large object data. 3. Sorting rules such as utf8mb4_unicode_ci ignores upper and lower case and is suitable for user names; utf8mb4_bin is case sensitive and is suitable for fields that require precise comparison.

The best MySQLVARCHAR column length selection should be based on data analysis, consider future growth, evaluate performance impacts, and character set requirements. 1) Analyze the data to determine typical lengths; 2) Reserve future expansion space; 3) Pay attention to the impact of large lengths on performance; 4) Consider the impact of character sets on storage. Through these steps, the efficiency and scalability of the database can be optimized.

MySQLBLOBshavelimits:TINYBLOB(255bytes),BLOB(65,535bytes),MEDIUMBLOB(16,777,215bytes),andLONGBLOB(4,294,967,295bytes).TouseBLOBseffectively:1)ConsiderperformanceimpactsandstorelargeBLOBsexternally;2)Managebackupsandreplicationcarefully;3)Usepathsinst

The best tools and technologies for automating the creation of users in MySQL include: 1. MySQLWorkbench, suitable for small to medium-sized environments, easy to use but high resource consumption; 2. Ansible, suitable for multi-server environments, simple but steep learning curve; 3. Custom Python scripts, flexible but need to ensure script security; 4. Puppet and Chef, suitable for large-scale environments, complex but scalable. Scale, learning curve and integration needs should be considered when choosing.

Yes,youcansearchinsideaBLOBinMySQLusingspecifictechniques.1)ConverttheBLOBtoaUTF-8stringwithCONVERTfunctionandsearchusingLIKE.2)ForcompressedBLOBs,useUNCOMPRESSbeforeconversion.3)Considerperformanceimpactsanddataencoding.4)Forcomplexdata,externalproc


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver Mac version
Visual web development tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.
