当前位置:Gxlcms > mysql > 在Oracle11gStreams测试Streams数据传输

在Oracle11gStreams测试Streams数据传输

时间:2021-07-01 10:21:17 帮助过:23人阅读

源数据库为两台集群64位HP-UNIX的Oracle11gR2数据库,目标数据库为1台64位Linux的Oracle11gR2的数据库,把源数据库的某个用户的数

描述:
源数据库为两台集群64位HP-UNIX的Oracle11gR2数据库,
目标数据库为1台64位Linux的Oracle11gR2的数据库,
把源数据库的某个用户的数据传输到目标数据库中

1、源数据库、目标数据库均为归档模式

源:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination +ARCHDG
Oldest online log sequence 60
Next log sequence to archive 61
Current log sequence 61

目标:
SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 54
Current log sequence 56

SQL> startup mount
ORACLE instance started.

Total System Global Area 6747725824 bytes
Fixed Size 2213976 bytes
Variable Size 4697622440 bytes
Database Buffers 2013265920 bytes
Redo Buffers 34623488 bytes
Database mounted.
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

2、设置源、目标数据库的相关参数
源:
SQL> show parameter global_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
global_names boolean FALSE
SQL>
SQL> alter system set global_names=true scope=both;

System altered.

SQL> show parameter aq_tm_processes

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0

SQL> alter system set aq_tm_processes=2 scope=both;

System altered.

目标:
SQL> show parameter global_names

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
global_names boolean FALSE
SQL>
SQL> alter system set global_names=true scope=both;

System altered.

SQL> show parameter aq_tm_processes

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
aq_tm_processes integer 0

SQL> alter system set aq_tm_processes=2 scope=both;

System altered.

3、在源数据库启用追加日志
启用辅助日志
SQL> alter database add supplemental log data;

Database altered.


4、在源、目标数据库创建表空间、用户、授权
源:
查看数据文件位置:
select file_name from dba_data_files
创建表空间:
create tablespace streams_space
datafile '+DATADG/cboms/datafile/streams_space.dbf'
size 5M autoextend on
创建用户:
create user strmadmin
identified by strmadmin
default tablespace streams_space
授予dba角色:
grant dba to strmadmin
授予流管理权限:
exec dbms_streams_auth.grant_admin_privilege('strmadmin') ----使用sys 或 system在命令行执行

目标:
查看数据文件位置:
select file_name from dba_data_files
创建表空间:
create tablespace streams_space
datafile '/u01/app/oracle/oradata/bhoms/streams_space.dbf'
size 5M autoextend on
创建用户:
create user strmadmin
identified by strmadmin
default tablespace streams_space
授予dba角色:
grant dba to strmadmin
授予流管理权限:
exec dbms_streams_auth.grant_admin_privilege('strmadmin') ----使用sys 或 system在命令行执行

5、配置源、目标数据库的tnsnames.ora
源数据库节点1:
CBDBS01-> cd $ORACLE_HOME
CBDBS01-> pwd
/oracle/db/product/11.2.0/db_1
CBDBS01-> cd network/admin
CBDBS01-> vi tnsnames.ora
在文件中末尾增加:

BHOMS_192.168.2.2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bhoms)
)
)

测试连接到目标数据库
CBDBS01-> sqlplus testUser/testPassword@BHOMS_192.168.2.2

源数据库节点2:
源数据库节点1:
CBDBS02-> cd $ORACLE_HOME
CBDBS02-> pwd
/oracle/db/product/11.2.0/db_1
CBDBS02-> cd network/admin
CBDBS02-> vi tnsnames.ora
在文件中末尾增加:

BHOMS_192.168.2.2 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.2)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = bhoms)
)
)

测试连接到目标数据库
CBDBS02-> sqlplustestUser/testPassword@BHOMS_192.168.2.2


目标数据库:
[@linuxidc ~]$ cd $ORACLE_HOME
[@linuxidc dbhome_1]$ cd network
[@linuxidc network]$ cd admin
[@linuxidc admin]$ pwd
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin

在这目录下没有tnsnames.ora文件,新建一个tnsnames.ora文件,,然后增加下面的内容:
[@linuxidc admin]$ vi tnsnames.ora

CBOMS =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.1)(PORT = 1568))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.2)(PORT = 1568))
(LOAD_BALANCE = yes)
(FAILOVER = ON)
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = cboms)
(FAILOVER_MODE =
(TYPE = Select)
(METHOD = BASIC)
)
)
)


测试是否连接到源数据库。
[@linuxidc admin]$ sqlplus testUser/testPassword@CBOMS

6、在源、目标数据库创建到目标数据库的db_link
源:
SQL> conn strmadmin/strmadmin

SQL>create database link BHOMS connect to strmadmin identified by strmadmin using 'BHOMS_192.168.2.2';

测试:
select * fromglobal_name@BHOMS

目标:
SQL> conn strmadmin/strmadmin

SQL>create database link CBOMS connect to strmadmin identified by strmadmin using 'CBOMS';

测试:
select * fromglobal_name@CBOMS

linux

人气教程排行