源端
os:red hat enterprise linux server release 5.5 (tikanga)
oracle:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit production
shareplex目录:/oradata/shareplex
目的端:
os:red hat enterprise linux server release 5.8 (tikanga)
oracle:oracle database 10g enterprise edition release 10.2.0.5.0 - 64bit production
shareplex目录:/data/shareplex
shareplex软件:shareplex-7.6.1-b27-oracle100-rh-40-amd64-m64.tar
解压后:shareplex-7.6.1-b27-oracle100-rh-40-amd64-m64.tpm
1)创建splex用户及设置归档模式
a 、源端与目标端--创建用户及授权(注意系统时间):
create user splex identified by splex default tablespace users;----最好为splex用户单独创建一个表空间
grant dba,connect,resource to splex;---splex必须有dba权限
源端必须处于归档模式
sql> archive log list
database log mode archive mode
automatic archival enabled
archive destination use_db_recovery_file_dest
oldest online log sequence 7
next log sequence to archive 9
current log sequence 9
alter database add supplemental log data (primary key,unique index) columns;
目标端创建需同步进去的数据(注意在目标端创建好源端默认表空间及数据表空间)
create user test identified by test default tablespace tbs_data01;
grant connect,resource,unlimited tablespace to test;
2) 安装shareplex
源端
$ ./shareplex-7.6.1-b27-oracle100-rh-40-amd64-m64.tpm
unpacking ..................................................................
..........................................................................
..........................................................................
..........................................................................
shareplex for oracle installation program:
shareplex version: 7.6.1
supported oracle version: 10gr2
build platform: rh-40-amd64
target platform: rh-40-amd64
please enter the product directory location? /oradata/shareplex/prodir
please enter the variable data directory location? /oradata/shareplex/vardir
please specify the shareplex admin group (select a number):
1. [oinstall]
2. dba
3. oper
?
please wait while the installer obtains oracle information ..
please enter the oracle_sid that corresponds to this installation? [hrdb]
please enter the oracle_home directory that corresponds to this oracle_sid? [/opt/app/oracle/product/10.2.0/db_1]
please enter the tcp/ip port number for shareplex communications? [2100] 2200
preparing to install shareplex for oracle v. 7.6.1:
user: oracle
admin group: oinstall
product directory: /oradata/shareplex/prodir
variable data directory: /oradata/shareplex/vardir
oracle_sid: hrdb
oracle_home: /opt/app/oracle/product/10.2.0/db_1
proceed with installation? [yes]
installing ................................................................
.........................................................................
....................................................................
setting file ownerships ...................................................
.........................................................................
........
setting file permissions ..................................................
.........................................................................
.........
do you have a valid shareplex for oracle v. 7.6.1 license? [yes]
please enter the license key? xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
please enter the customer name associated with this license key? yyyyyyyyyyyyyyyyyyyyyyyyyyy
shareplex for oracle v. 7.6.1 license validation successful:
customer name: yyyyyyyyyyyyyyyyyyyyyyyyyyy
license key: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
product name: shareplex for oracle - rac
license key type: perpetual key
note: you can upgrade this license key or add license keys for additional machines
by executing utility /oradata/shareplex/prodir/install/splex_add_key.
installation log saved to: /home/oracle/.shareplex/install-shareplex-7.6.1-1106130040.log
shareplex for oracle v. 7.6.1 installation successful.
$ ./ora_setup
welcome to the oracle shareplex setup process.
this process creates tables and user accounts needed to run
oracle shareplex replication.
please note the following:
** in response to prompts, a carriage return will choose the default
given in brackets. if there is no default, a reply must be entered.
** to exit the program while the program is waiting for input, use the
ctrl-c key sequence.
this sequences can be entered by holding down the control key and
pressing the c key.
enter the oracle sid for which shareplex should be installed [hrdb] :
in order to create the shareplex tables and user account, we must
connect to the database as a dba user
enter a dba user name : system
enter password for the dba account, which will not echo :
注意:rac环境下,此处输入oracle数据库system帐户的口令,但应当在口令的后面加上@tns_alias,然后回车;
connecting--this may take a few seconds.
validating user name and password. . . this may take a few seconds.
shareplex objects will need to be created under a special
account. you can pick an existing user or create a new one.
would you like to create a new shareplex user ? [y] : n
enter username of an existing user : splexhr
enter user password for splexhr :
注意:rac环境下,此处输入oracleshareplex用户的口令,但应当在口令的后面加上@tns_alias, 然后回车;
validating user name and password. . . this may take a few seconds.
warning: this user is now being granted unlimited tablespace.
this privilege will remain in effect until it is explicitly changed.
splex_role_both already exists; continuing setup . . .
setup will now install shareplex objects.
these are the existing tablespaces.
system undotbs1 sysaux temp users tbs_data01 tbs_data02 tbs_data03
tbs_index01 tbs_index02 tbs_index03 tbs_splex
enter the default tablespace for use by shareplex [tbs_splex] :
enter the temporary tablespace for use by shareplex [temp] :
enter the index tablespace for use by shareplex [tbs_splex] :
creating shareplex objects [installation type: upgrade]. . .
splexhr.shareplex_actid already exists; continuing setup . . .
splexhr.shareplex_marker already exists; continuing setup . . .
splexhr.shareplex_objmap already exists; continuing setup . . .
splexhr.shareplex_objmap_i1 already exists; continuing setup . . .
splexhr.shareplex_trans already exists; continuing setup . . .
splexhr.shareplex_loglist already exists; continuing setup . . .
splexhr.shareplex_lobmap already exists; continuing setup . . .
splexhr.shareplex_routes already exists; continuing setup . . .
splexhr.shareplex_routes_i1 already exists; continuing setup . . .
splexhr.shareplex_routes_i2 already exists; continuing setup . . .
splexhr.shareplex_wildcard already exists; continuing setup . . .
splexhr.shareplex_wildcard_i1 already exists; continuing setup . . .
splexhr.shareplex_wildcard_i2 already exists; continuing setup . . .
splexhr.shareplex_partition_cache already exists; continuing setup . . .
splexhr.shareplex_partition_cache_i1 already exists; continuing setup . . .
splexhr.shareplex_lob_cache already exists; continuing setup . . .
splexhr.shareplex_lob_cache_i1 already exists; continuing setup . . .
splexhr.shareplex_config already exists; continuing setup . . .
splexhr.shareplex_command already exists; continuing setup . . .
splexhr.shareplex_jobid already exists; continuing setup . . .
splexhr.shareplex_jobs already exists; continuing setup . . .
splexhr.shareplex_job_stats already exists; continuing setup . . .
splexhr.shareplex_dataequator already exists; continuing setup . . .
already exists; continuing setup . . .
already exists; continuing setup . . .
already exists; continuing setup . . .
splexhr.demo_src already exists; continuing setup . . .
splexhr.demo_dest already exists; continuing setup . . .
splexhr.shareplex_act_marker already exists; continuing setup . . .
splexhr.shareplex_partition already exists; continuing setup . . .
splexhr.shareplex_oos_master already exists; continuing setup . . .
splexhr.shareplex_oos_keys already exists; continuing setup . . .
splexhr.shareplex_sync_marker already exists; continuing setup . . .
splexhr.shareplex_change_object already exists; continuing setup . . .
splexhr.shareplex_ddl_control already exists; continuing setup . . .
creating shareplex oracle-timezone-region map . . . done.
creating conflict resolution package . . . done.
setup of shareplex objects successful . . .
changing shareplex parameter database . . .
setup completed successfully
3)目标端安装shareplex
安装shareplex过程中./shareplex-7.6.1-b27-oracle100-rh-40-amd64-m64.tpm及./ora_setup类似,不同
之外在于
oracle asm detected. enable shareplex asm support? [y] :
shareplex asm support enabled.
(备注:如在源端或目标端都有安装过shareplex,则记得清除splex用户capture或post信息,则在启动前记得以下操作:
./ora_cleansp splexhr/splexhr
)
3) 源端操作
a 、启动shareplex
[oracle@hrdb bin]$ ./sp_cop -u2200 &
[1] 25839
[oracle@hrdb bin]$
*******************************************************
* shareplex for oracle startup
* 10 quest software, inc.
* all rights reserved.
* protected by u.s. patents: 7,461,103 and 7,065,538
* version: 7.6.1.27-m64-oracle100
* vardir : /oradata/shareplex/vardir
* port : 2200
*******************************************************
b 、进入控制台
[oracle@hrdb bin]$ ./sp_ctrl
*******************************************************
* shareplex for oracle command utility
* 10 quest software, inc.
* all rights reserved.
* protected by u.s. patents: 7,461,103 and 7,065,538
*******************************************************
c 、添加配置文件
sp_ctrl (hrdb:2200)> list config
file name state datasource
-------------------------------------------------- ---------- ---------------
ora_config inactive o.source_sid
last modified at: 13-jun-11 00:43 size: 151
sp_ctrl (hrdb:2200)> copy config ora_config to hr_config
sp_ctrl (hrdb:2200)> view config hr_config
datasource:o.hrdb
#source tables target tables routing map
splex.demo_src splex.demo_dest 10.1.2.18@o.backupdb
expand test.% test.% 10.1.2.18@o.backupdb
4)目标端操作
$./sp_cop -u2200 &
$./sp_ctrl
sp_ctrl (backupdb:2200)> status
brief status for backupdb
process state pid running since
--------------- ------------------------------ -------- --------------------
cop running 26483 31-jul-12 09:31:06
cmd & ctrl running 26485 31-jul-12 09:31:14
there are no active configuration files
sp_ctrl (backupdb:2200)> stop post
5)源端
sp_ctrl (hrdb:2200)> activate config hr_config
not all tables activated successfully
源端-导出数据(这里使用scn来保证 一致性):
sql> set num 50
sql> select current_scn from v$database;
current_scn
--------------------------------------------------
165290627611expdp system/xxxx directory=dump_dir dumpfile=20120730_hr.dmp flashback_scn=165290627611 schemas=test logfile=20120730_hr.log
或用exp方式
6) 目标端
impdp system/oracle directory=dump_dir dumpfile=20120730_hr.dmp schemas=test logfile=impdp_2012730_hr.log
或用imp方式
禁用查找相关job
select job_name from dba_scheduler_jobs where owner='test';
禁用触发器
select 'alter trigger '||owner||'.'||object_name||' disable'
from dba_objects
where object_type='trigger' and owner='test';
查找外键及约束
select 'alter table '||t.owner||'.'||t.table_name||' disable constraint '||t.constraint_name||';'
from dba_constraints t
where owner='test' and constraint_type='r';
sp_ctrl (backupdb:2200)> qstatus
queues statistics for backupdb
name: hrdb (o.hrdb-o.backupdb) (mtpost queue)
number of messages: 207 (age 0 min; size 0 mb)
backlog (messages): 207 (age 0 min)
sp_ctrl (backupdb:2200)>reconcile queue hrdb for o.hrdb-o.backupdb scn 165290627611
sp_ctrl (backupdb:2200)>start post
(
清除源端或目标端下队列记录信息:
$ ./ora_cleansp splexhr/splexhr
在config文件配置错误的情况下已经activate时,需deactivate config后再行编辑激活;否则,有可能激活config后,一直hang住
)***********************************
注意在rac环境下:
1、如果两个节点的实例名字不一样,就必须在oracle10g rac的两个节点的tnsnames.ora文件中都建立一个tns别名,然后在/etc/oratab文件中添加如下入口:
splex:/oracle/product/db/10.2:n
其中splex为新建的tns别名;oracle_home为oracle的home目录的全路径
2、如果rac中各个节点的oracle_home不同,应该在两个节点上oracle用户下创建相同符号连接指向示本地的oracle_home 。然后编辑oratab文件,将文件中的路径改成符号连接。
# ln -s /local_oracle_home /$oracle_home
编辑 oratab file : sid:/pathname_to_symbolic_link:n
