OGG安装配置文档

OGG安装配置文档
1、【BOTH】unzip ogg11210_fbo_ggs_linux_x64_ora11g_64bit.zip
2、【BOTH】创建OGG用户,可以与oracle用户兼用
3、【BOTH】配置环境变量
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export GGS_HOME=/u01/app
export PATH=$GGS_HOME:$PATH
4、【BOTH】安装ogg
./ggsci
GGSCI>create subdirs
5、【BOTH】检查数据库是否为归档模式
SQL>archive log list
6、【BOTH】打开数据库附加日志功能
SQL>select supplemental_log_data_min from v$database;
SQL>alter database add supplemental log data;
7、【BOTH】创建ogg用户
SQL>create tablespace ogg datafile '/u01/app/oracle/oradata/orcl/ogg_01.dbf' size 200M autoextend off;
SQL>crate user ogg identified by ogg default tablespace ogg;
SQL>grant dba to ogg;
8、【源】 源端确定复制用户schema(实验情况下创建)
SQL>create tablespace oradev datafile '/u01/app/oracle/oradata/orcl/oradev_01.dbf' size 500M autoextend off;
SQL>crate user oradev identified by oracle default tablespace oradev;
SQL>grant connect,resource to oradev;
9、【目】 目标端确定复制用户schema(生产环境下为保持环境一致,建议命名位置以及用户密码一致)
SQL>create tablespace oradev datafile '/u01/app/oracle/oradata/orcl/oradev_01.dbf' size 500M autoextend off;
SQL>crate user oradev identified by oracle default tablespace oradev;
SQL>grant connect,resource to oradev;
10、【BOTH】manager进程(ggsci需要到ogg目录下输入)
--端口号可以自己定义,如果是内网与外网做ogg需要网络做NAT端口映射
ggsci>edit params mgr
PORT 7801
DYNAMICPORTLIST 7802-7802
autorestart extract *, retries 24, waitminutes 5

11、【源】extract复制进程
ggsci>add extract exta,tranlog,begin now
#exttrail /u01/app/ogg/dirdatlocal/ds 为抓取后保存在本地的trail文件
ggsci>add exttrail /u01/app/ogg/dirdatlocal/ds,extract exta
ggsci>edit params exta
extract exta
setenv (NLS_LANG = "simplified chinese_china.zhs16gbk")
setenv (ORACLE_SID = "orcl")
userid ogg,password ogg
exttrail /u01/app/ogg/dirdatlocal/ds
discardfile ./dirrpt/exta.dsc,append, megabytes 50
TRANLOGOPTIONS EXCLUDEUSER ogg
GETAPPLOPS
IGNOREREPLICATES
gettruncates
sequence oradev.*;
table oradev.*
#extract配置完以后可以start exta,查看dirdatlocal文件下是否产生了trail文件
12、【源】pump泵进程配置

ggsci>add extract pumpa,exttrailsource /u01/app/ogg/dirdatlocal/ds
#/u01/app/ogg/dirdatremote/ds为远端目标服务器的路径,推送trail文件的目标位置
ggsci>add rmttrail /u01/app/ogg/dirdatremote/ds,extract pumpa
#注意table 表.*的结尾必须有;
ggsci>edit params pumpa
extract pumpa
SETENV (ORACLE_SID = "orcl")
SETENV (NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK")
userid ogg, password ogg
rmthost 192.168.100.100, mgrport 6101,compress,compressthreshold 0
rmttrail /u01/app/ogg/dirdatremote/ds 
passthru
table oradev.*;
sequence oradev.*;
#pump配置完以后可以start pumpa,查看远端dirdatremote文件下是否产生了trail文件
13、【目】目标端添加checkpoint表
ggsci>edit params globals
ggschema ogg
checkpointtable ogg.checkpoint
14、【目】复制端创建checkpoint表
ggsci>dblogin userid ogg,password ogg
ggsci>add checkpointtable ogg.checkpoint
SQL>select * from tab;
#检查是否创建成功
15、【目】初始化目标数据库
15.1、源数据导出
--创建expdir目录,目录根据源OS设置
create directory expdir as '/database/oracle/expdir2';
--给用户授权
grant read,write on directory expdir2 to system,oradev;
--导出语句;
--从高版本到低版本需要指定 version=11.2.0.3.0 
--指定SCN号导出 flashback_scn=154059194  来源:select dbms_flashback.get_system_change_number from dual;
expdp system/password@orcl schemas=oradev directory=expdir  dumpfile=oradev0827.dmp logfile=oradev0827.log CONTENT=ALL version=11.2.0.3.0 flashback_scn=154059194
15.3、dmp文件拷贝,如果SSH端口不是22需要-P指定
scp -P 22 cwx_ks_0821.dmp  [email protected]:/backup/oracle/impdir/
15.2、目标数据库导入
--创建expdir目录,目录根据目标OS设置
create directory impdir as '/database/oracle/impdir';
--给用户授权
grant read,write on directory impdir to system,oradev;
--创建表空间
#已经在步骤9中创建,如果是重新初始化此处删除用户对象(保留tablespace)
#SQL>drop user test cascade
--如果目标数据库结构不一致,用remap参数remap_schema=cwx_ks:cwx_ks remap_tablespace=KS_DATA01:KS_DATA,TEMP:TEMP
impdp system/password@orcl directory=impdir dumpfile=oradev0827.dmp logfile=oradev0827.log  schemas=test
16、【目】目标端replicat配置
ggsci>add replicat repa,exttrail /u01/app/ogg/dirdatremote/ds,checkpointtable ogg.checkpoint
#TABLEEXCLUDE为排除表
ggsci>edit params repa
replicat repa
SETENV (NLS_LANG = "AMERICAN_AMERICA.ZHS16GBK")
SETENV (ORACLE_SID = "orcl")
userid ogg,password ogg
assumetargetdefs
reperror default,discard
discardfile ./dirdat/discard_file,append,megabytes 500
ALLOWNOOPUPDATES
TABLEEXCLUDE cwx_ks.SYS_EXPORT_SCHEMA_*;
TABLEEXCLUDE cwx_ks.SYS_EXPORT_TABLE_*;
map cwx_ks.*, target cwx_ks.*;


17、【目】启动复制
如果OGG为初始创建
ggsci>start replicat repa
如果OGG为重新初始化
--000687为extract的序号,可根据数据导出时间在trail文件夹查看相应的文件序列号
alter repa extseqno  000687 extrba 0
--2719112586为SCN号,为导出数据时数据库的SCN号,需要注意的是改SCN号必须包含在extract文件中,否者会报错
start repa atcsn 2719112586


18、双向复制参考单向复制,只是不需要初始化数据库。

你可能感兴趣的:(OGG安装配置文档)