goldengate部署實施

petrel_peng發表於2013-12-09

一、安裝redhat4,安裝步驟略

二、安裝oracle10g 安裝步驟略

三、安裝goldengate,注意要選對版本

    1、源端安裝配置

       1.1安裝goldengate
        
         linux: mkdir /u01/oracle/ggate
                cd /u01/oracle/ggate

         通過ftp,將goldengate的zip軟體上傳到/u01/oracle/ggate

                unzip 解壓,將生成一個tar檔案

                tar -xvf *.tar

       1.2配置.bash_profile
         
               vi .bash_profile
               新增:
               export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/oracle/ggate
               export GGATE_HOME=/u01/oracle/ggate

               注意LD_LIBRARY_PATH,那一行,可以在原來安裝oracle的基礎上新增在後面便可

               配置完,執行 source ~./bash_profile

       1.3建立goldengate目錄

               cd /u01/oracle/ggate

               ./ggsci  (進入goldengate命令列介面)

              Oracle GoldenGate Command Interpreter for Oracle
              Version 11.1.1.0.0 Build 078
              Linux, x86, 32bit (optimized), Oracle 10 on Jul 28 2010 13:24:18
              Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved


               現在在goldengate命令列工作
              
               create subdirs

       1.4配置資料庫歸檔模式,進入sql命令列(如果關閉,建議開啟)

               sqlplus "/as sysdba"

               alter system set log_archive_format='%s_%t_%r.log' scope=spfile;
      
               alter system set log_archive_dest_1='location=/u02/oracle/arc';

               shutdown immediate;

               startup mount;

               alter database archivelog;

               alter database open;

               alter database force logging;

               ----取消用  alter database no force logging;

               這下可以看一下歸檔是否已經起來,archive log list

        1.5開啟minimal supplemental logging

               alter database add supplemental log data(primary key,unique) columns;

              
        1.6關閉回收站

               alter system set recyclebin=off scope=spfile;
           

        1.7配置複製的DDL支援

                建立使用者授權:

                create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;

                grant connect,resource,dba to ggate;

                grant execute on utl_file to ggate;

                grant restricted session to ggate;
              
                               
               @$GGATE_HOME/marker_setup.sql;

               SCHEMA:GGATE

               @$GGATE_HOME/ddl_setup.sql;

               這裡要看清楚,選擇輸入,否則會有問題!

               @$GGATE_HOME/role_setup.sql;

               授予角色權力:
               grant GGS_GGSUSER_ROLE to ggate;

               @$GGATE_HOME/ddl_enable.sql;

         1.8建立源端使用者(用於同步的使用者)

                create user sender identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;

                grant dba,connect,resource to ggate;

                grant select on v_$session to ggate;

    2、源端複製佇列配置

         2.1配置manager

            cd /u01/oracle/ggate           

            ./ggsci   (進入goldengate命令列)


            edit params mgr

            輸入:PORT 7809

            與vi操作基本相同

          2.2配置源端複製佇列
            
             同樣是在goldengate命令列裡做

             add extract ext1, tranlog, begin now

             add exttrail /u01/oracle/ggate/dirdat/lt, extract ext1

             edit params ext1
             輸入如下內容:
             extract ext1
             userid ggate, password ggate     
             rmthost 目標機, mgrport 7809
             rmttrail /u01/oracle/ggate/dirdat/lt
             ddl include mapped objname sender.*;
             table sender.*;

             到這裡,可以用info all檢視一下,

             關閉程式:
             stop mgr
             stop ext1

    到這裡源端基本上配置完畢


    3、目標端安裝配置

       3.1安裝goldengate
        
         linux: mkdir /u01/oracle/ggate
                cd /u01/oracle/ggate

         通過ftp,將goldengate的zip軟體上傳到/u01/oracle/ggate

                unzip 解壓,將生成一個tar檔案

                tar -xvf *.tar

       3.2配置.bash_profile
         
               vi .bash_profile
               新增:
               export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/u01/oracle/ggate
               export GGATE_HOME=/u01/oracle/ggate

               注意LD_LIBRARY_PATH,那一行,可以在原來安裝oracle的基礎上新增在後面便可

               配置完,執行 source ~./bash_profile

       3.3建立goldengate目錄

               cd /u01/oracle/ggate

               ./ggsci  (進入goldengate命令列介面)

              Oracle GoldenGate Command Interpreter for Oracle
              Version 11.1.1.0.0 Build 078
              Linux, x86, 32bit (optimized), Oracle 10 on Jul 28 2010 13:24:18
              Copyright (C) 1995, 2010, Oracle and/or its affiliates. All rights reserved


               現在在goldengate命令列工作
              
               create subdirs

        3.4建立目標端使用者

               create user ggate identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;

               create user receiver identified by ggate default tablespace users temporary tablespace temp quota unlimited on users;(接收同步的使用者)

                grant connect,resource,dba to ggate;

                grant execute on utl_file to ggate;

                grant restricted session to ggate;

                grant connect,resource,dba to receiver;

                grant select on v_$session to receiver;

        3.5配置replicat

               ./ggsci

               edit params ./GLOBALS

               輸入:
               GGSCHEMA ggate
               CHECKPOINTTABLE ggate.checkpoint
              
               edit params mgr

               輸入:PORT 7809
              
               在goldengate命令列登入資料庫

                dblogin userid ggate,password ggate

                add checkpointtable ggate.checkpoint (增加檢測點)

                add replicat rep1, exttrail /u01/oracle/ggate/dirdat/lt, checkpointtable ggate.checkpoint(增加同不佇列)

                edit params rep1

                新增如下內容:
                replicat rep1
                ASSUMETARGETDEFS
                userid ggate, password ggate
                discardfile /u01/oracle/ggate/dirdat/rep1_discard.txt, append, megabytes 10
                DDL include all
                map sender.*, target receiver.*;


     到這裡上標端配置基本結束


四、額外增加的一個步驟,我是這樣做

      分別在源端、目標端增加
     
      mkdir -p /u01/oracle/ggate/dirdat/lt

五、在goldengate命令列開啟

        源端:start manager
              start ext1


        目標:start manager
              start rep1

六、測試:

    源端:create table sender.test(empid number(4),names varchar2(10),oldage number(3));
   
    目標:select * from receiver.test;

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/21752515/viewspace-1062726/,如需轉載,請註明出處,否則將追究法律責任。

相關文章