在前面的几篇里讲了GG的系统需求及支持的对象类型， 在这里看下GG的安装与卸载的理论知识，这里只介绍Linux 平台的说明，其他平台的自己参看官方文档。
To install Oracle GoldenGate , the following steps arerequired:
(1) Downloading Oracle GoldenGate
(2) Setting ORACLE_HOME andORACLE_SID
(3) Setting library paths fordynamic builds
(4) Installing the OracleGoldenGate software
(5) Installing support for Oraclesequences
(6) (Optional) Installing OracleGoldenGate DDL support
1.1 Downloading Oracle GoldenGate
1.2 Setting ORACLE_HOME and ORACLE_SID
Make certain that the ORACLE_HOME and ORACLE_SID system environment variables are set to thecorrect Oracle instance. The Oracle GoldenGate processes refer to them when connectingto the database.
To specify Oraclevariables on UNIX-based systems
（1） If there is one instance of Oracleon the system, set ORACLE_HOME and ORACLE_SID at the system level. If youcannot set them that way, use the following SETENV statements in the parameterfile of every Extract and Replicat group that will be connecting to the instance.
--如果只是一个instance，那么在系统级别设置ORACLE_HOME和ORACLE_SID，如果不能设置，可以设置GG Extract 和Replicat 组的SETENV 参数。
SETENV (ORACLE_HOME = “<path to Oraclehome location>”)
SETENV (ORACLE_SID = “<SID>”)
The SETENV parametersoverride the system settings and allow the Oracle GoldenGate process to set thevariables at the session level when it connects to the database.
（2） If there are multiple Oracleinstances on the system with Extract and Replicat processes connecting to them,you will need to use a SETENV statement in the parameter file of each processgroup and point it to the correct instance. For example, the following showsparameter files for two Extract groups, each capturing from a different Oracleinstance.
--如果有多个instance，那么就需要对每个Extract 和 Replicat进程组设置SETENV 参数。
SETENV (ORACLE_HOME =“/home/oracle/ora9/product”)
SETENV (ORACLE_SID = “ora9a”)
USERID ggsa, PASSWORD ggsa
SETENV (ORACLE_HOME =“/home/oracle/ora9/product”)
SETENV (ORACLE_SID = “ora9b”)
USERID ggsb, PASSWORD ggsb
1.3 Setting library paths for dynamic builds on UNIX
Oracle GoldenGate uses shared libraries. When you install Oracle GoldenGate on a UNIX system,the following must be true before you run GGSCI or any other Oracle GoldenGate process.
--GG 需要使用shared libraries，所以在使用GG 之前，要先确保如下选项
1.3.1. When OracleGoldenGate connects to the database locally, all of the following must have thesame bit type, either all 32-bit, all 64-bit, or all IA64:
1） OracleGoldenGate version
2) Oracle library versions
3) Database versions
1.3.2. When OracleGoldenGate connects through SQL*Net, the Oracle client library and the OracleGoldenGate build must match. This means that the Oracleversion, the bit type (32-bit, 64-bit, IA64) and the operating system versionall must match. If you are using the TRANLOGOPTIONS parameter with the LOGSOURCEoption and Oracle GoldenGate connects to transaction logs from a different operatingsystem, the Oracle versions must also be the same.
1.3.3. Make certain thatthe database libraries are added to the shared-library environment variables ofthe system. This procedure is usually performed atdatabase installation time. Consult your Database Administrator if you have anyquestions.
1.3.4. If you will be running an OracleGoldenGate program from outside the Oracle GoldenGate installation directory ona UNIX system:
（1） (Optional) Add the OracleGoldenGate installation directory to the PATH environment variable.
（2）(Required) Add the OracleGoldenGate installation directory to the sharedlibraries environment variable.
For example,given an Oracle GoldenGate installation directory of /users/ogg, the second commandin the following example requires these variables to be set:
Command RequiresGG libraries in environment variable?
$ users/ogg > ./ggsci No
$ users > ./ogg/ggsci Yes
To set the variables in Korn shell
<shared librariesvariable>=<absolute path of installation directory>:$<sharedlibraries variable>
export <shared libraries variable>
To set the variables in Bourne shell
export PATH=<installation directory>:$PATH
export <shared librariesvariable>=<absolute path of installation directory>:$<sharedlibraries variable>
To set the variables in C shell
setenv PATH <installation directory>:$PATH
setenv <shared libraries variable><absolute path of installation directory>:$<shared librariesvariable>
Where: <sharedlibraries variable> is one of the following:
To view thelibraries that are required by an Oracle GoldenGate process, use the ldd<process> shell command before starting the process. This command also showsan error message for any that are missing.
1.4 Installing Oracle GoldenGate on Linux and UNIX
1.4.1 Installing Oracle GoldenGate into a Linux or UNIX cluster
Follow these guidelines if installing intoa cluster configuration:
（1） Install the Oracle GoldenGatebinaries and files on a file system that is available to all cluster nodes,according to the directions that follow.
（2） After installing OracleGoldenGate, configure the Manager process within the cluster application, asdirected by the cluster documentation, so that Oracle GoldenGate will fail overproperly with the other applications.
1.4.2 Installing the Oracle GoldenGate files
1. Extract the Oracle GoldenGate mediapack.zipfile to the system and directory where you want Oracle GoldenGate to beinstalled.
2. Run the command shell.
3. Change directories to the new OracleGoldenGate directory.
4. From the Oracle GoldenGate directory,run the GGSCI program.
5. In GGSCI, issue the following command tocreate the Oracle GoldenGate working directories.
6. Issue the following command to exitGGSCI.
1.5 Installing support for Oracle sequences
To support Oracle sequences, you must install some database procedures. These proceduressupport the Oracle GoldenGate FLUSH SEQUENCE command, which you issue immediatelyafter you start the Oracle GoldenGate processes for the first time (typically whenyou perform the initial data synchronization procedure).
To install Oracle sequence objects
Follow these instructions on the source andtarget systems.
1. On the source and target Oracle systems,connect to SQL*Plus as SYSDBA.
2. If you already assigned a database userto support the Oracle GoldenGate DDL replication feature, you can skip thisstep. Otherwise, on both systems create a database user that can also be theDDL user.
SQL> CREATE USER DDLuser IDENTIFIED BY password;
SQL> GRANT CONNECT,RESOURCE,DBA TO DDLuser;
3. From the Oracle GoldenGate installationdirectory, run GGSCI.
4. In GGSCI, issue the following command.
5. In the file, enter the GGSCHEMA parameterand specify the schema of the DDL user that you created earlier in thisprocedure.
6. Save and close the file.
7. On both systems, run the sequence.sql scriptfrom the root of the Oracle GoldenGate installation directory. This scriptcreates some procedures for use by Oracle GoldenGate processes. (Do not runthem yourself.) You are prompted for the user information that you created inthe first step.
--在所有系统饿GG根目录下执行sequence.sql 脚本，该脚本会为GG 进程创建一些过程。
8. On the source system, grant EXECUTE privilegeon the updateSequence procedure to a database user that can be used to issuethe DBLOGIN command. Remember or record this user. You use DBLOGIN to log intothe database prior to issuing the FLUSH SEQUENCE command, which calls theprocedure.
SQL> GRANT EXECUTE on DDLuser.updateSequenceTO DBLOGINuser;
9. On the target system, grant EXECUTE privilegeon the replicateSequence procedure to the Replicat database user.
SQL> GRANT EXECUTE on DDLuser.replicateSequenceTO Replicatuser;
1.6 Configuring Manager and other processes
To configureOracle GoldenGate to support your business requirements, It containsinstructions to:
(1) Configure the Manager processwith a TCP/IP port and other optional parameters that control dynamic portassignments, trail file maintenance, automatic startup, and other properties.
(2) Configure Extract and Replicatprocesses to support reporting, high availability, disaster recovery, and othertopologies.
(3) Configure security to controluser access, file security, and data encryption.
(4) Configure integration,manipulation, and conversion features that enable you to customize OracleGoldenGate and support the delivery of data across heterogeneous environments.
(5) Configure utilities and othertools that support Oracle GoldenGate.
二.启用GG 对DDL 操作的支持
DDL support forsequences (CREATE, ALTER, DROP, RENAME) is compatible with, but not requiredfor, replicating the sequence values themselves. To replicate just sequencevalues, you do not need to install the Oracle GoldenGate DDL support environment. You can just use the SEQUENCE parameter.
2.1 Overview of the DDL objects
To install theOracle GoldenGate DDL environment, you will be installing the database objectsshown in Table 7.
2.2 Oracle GoldenGate DDL objects in an Oracle standby configuration
In a physical orlogical Oracle standby configuration, the Oracle GoldenGate DDL objects arepropagated by the Oracle system (along with the other changes) from the primaryserver to the standby server. The Oracle GoldenGate DDL trigger will performits function on either the primary server or the logical standby server, butnot on a physical standby server, and only if the mode of operation on theserver is READ WRITE. On a physical standby, Oracle GoldenGate DDL objects arenot active.
If DDLreplication by Oracle GoldenGate will not be used on a logical standby server,you can disable the DDL trigger there after it has been installed and enabledon the primary server. If the logical standby server will be used as a sourceof DDL replication, however, the trigger must be enabled.
2.3 Installing the DDL objects
1. Choose an Oracle GoldenGate schema oranother schema for the DDL objects.
2. Grant the following permission on theOracle GoldenGate schema.
GRANT EXECUTE ONutl_file TO <schema>;
3. Choose a tablespace for the DDL objectsthat can accommodate the growth of the GGS_DDL_HIST and GGS_MARKER tables. The GGS_DDL_HISTtable, in particular, will grow in proportion to overall DDL activity. If thetablespace that contains these objects fills up, no DDL operations can beissued on the database, and the business applications will pause.
4. Open the GLOBALS file in the homedirectory of this instance of Oracle GoldenGate. If a GLOBALS file does notexist, create one. For information on creating or editing a GLOBALS file, seethe Oracle GoldenGate Windows and UNIX Administrator’s Guide.
5. Specify the name of the DDL schema byadding the following parameter to the GLOBALS file.
6. (Optional) To change the names of otherobjects listed in Table 7, the changes must be made now, before proceeding withthe rest of the installation. Otherwise, you will need to stop OracleGoldenGate DDL processing and reinstall the DDL objects. It is recommended thatyou accept the default names of the database objects. To change any name inTable 7 (except the schema), do one or both of the following:
--在table 7里列了DDL 需要的对象名称，如果需要修改这些对象的默认名称，按以下方式来操作：
（1） Record all name changes in the params.sqlscript. Edit this script and change the appropriate parameters. Do not run thisscript.
（2） List the names shown in Table 8 inthe GLOBALS file. The correct parameters to use are listed in the Parameter columnof the table.
7. Change directories to the OracleGoldenGate installation directory.
8. Exit all Oracle sessions, includingthose of SQL*Plus, those of business applications, those of the OracleGoldenGate processes, and those of any other software that uses Oracle. Preventthe start of any new sessions.
9. Run SQL*Plus and log in as a user thathas SYSDBA privilege. This privilege is required to install the DDL trigger inthe SYS schema, which is required by Oracle. All other DDL objects areinstalled in the schema that you created in step 1.
10. Run the marker_setup.sql script.
（1） Supply the name of the OracleGoldenGate schema when prompted, and then press Enter to execute the script.
（2） This script installs support forthe Oracle GoldenGate DDL marker system.
11. Run the ddl_setup.sql script.
You are prompted to:
（1） Disable the Oracle recycle bin ifthe database is Oracle 10g.
（2） Stop current Oracle GoldenGate DDLreplication.
（3） Specify the name of the DDL schemafrom step 1.
（4） Specify the installation mode: Toinstall DDL objects the first time, use the INITIALSETUP mode.
INITIALSETUPmode assumes that no Oracle GoldenGate DDL objects exist and drops them if theydo. If the DDL objects exist and you want to reinstall them, but
preserve any DDL history, use the procedurein “Restoring an existing DDL environment to a clean state” on page 68.
12. Run the role_setup.sql script.
（1） At the prompt, supply the DDLschema name.
（2） The script drops and creates therole that is needed for DDL synchronization, and it grants DML permissions onthe Oracle GoldenGate DDL objects.
13. Grant the role that was created(default name is GGS_GGSUSER_ROLE to all Oracle GoldenGate Extract users. Youmay need to make multiple grants if the processes have different user names.
GRANT<role> TO <user>;
14. Run the ddl_enable.sql script to enablethe DDL trigger.
To install and use the optional performance tool
To improve theperformance of the DDL trigger, make the ddl_pin script part of the database startup.It must be invoked with the Oracle GoldenGate DDL user name, as in:
This script pinsthe PL/SQL package that is used by the trigger into memory. If executing thisscript from SQL*Plus, connect as SYSDBA from the Oracle GoldenGate installationdirectory. This script relies on the Oracle dmbs_shared_pool system package, soinstall that package before using ddl_pin.
Uninstalling Oracle GoldenGate from Linux or UNIX
1. Run the command shell.
2. (Suggested) Log on as the systemadministrator, or as a user with permission to issue Oracle GoldenGatecommands, and to delete files and directories from the operating system.
3. Change directories to the OracleGoldenGate installation directory.
4. Run GGSCI.
5. Stop all Oracle GoldenGate processes.
6. Stop the Manager process.
7. Exit GGSCI.
8. Remove the Oracle GoldenGate files byremoving the installation directory.
9. Drop any Oracle GoldenGate-relatedobjects from the database as needed.