`
jackytang520
  • 浏览: 138529 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

Configuring Oracle Database Gateway for SQL Server

阅读更多

该文章来自Oracle 透明网关安装方便的帮助文档,在这里需要注意,连接sql server2000时,请确认你的sql server2000已经打好SP3,SP4补丁,我因为没打这两个补丁折腾了一个晚上,总是提示sa用户不能登录。

After installing the gateway, perform the following tasks to configure Oracle Database Gateway for SQL Server:

  1. Configure the Gateway Initialization Parameter File

  2. Configure Oracle Net for the Gateway

  3. Configure the Oracle Database for Gateway Access

  4. Create Database Links

  5. Configure Two-Phase Commit

  6. Create SQL Server Views for Data Dictionary Support

  7. Encrypt Gateway Initialization Parameter Values

  8. Configure the Gateway to Access Multiple SQL Server Databases

Configure the Gateway Initialization Parameter File

Perform the following tasks to configure the gateway initialization parameter file:

  1. Choose a System Identifier for the Gateway

  2. Customize the Initialization Parameter File

Choose a System Identifier for the Gateway

The gateway system identifier (SID) is an alphanumeric character string that identifies a gateway instance. You need one gateway instance, and therefore one gateway SID, for each SQL Server database you are accessing. The SID is used as part of the file name for the initialization parameter file. The default SID is dg4msql.

You can define a gateway SID, but using the default of dg4msql is easier because you do not need to change the initialization parameter file name. However, if you want to access two SQL Server databases, you need two gateway SIDs, one for each instance of the gateway. If you have only one SQL Server database and want to access it sometimes with one set of gateway parameter settings, and other times with different gateway parameter settings, then you will need multiple gateway SIDs for the single SQL Server database.

<!---->

Customize the Initialization Parameter File

The initialization parameter file must be available when the gateway is started. During installation, the following default initialization parameter file is created:

ORACLE_HOME\dg4msql\admin\initdg4msql.ora

Where ORACLE_HOME is the directory under which the gateway is installed.

This initialization file is for the default gateway SID. If you are not using dg4msql as the gateway SID, you must rename the initialization parameter file using the SID you chose in the preceding step "Choose a System Identifier for the Gateway". This default initialization parameter file is sufficient for starting the gateway, verifying a successful installation, and running the demonstration scripts.

A number of initialization parameters can be used to modify the gateway behavior. Refer to Appendix C, "Initialization Parameters" for the complete list of initialization parameters that can be set. Changes made to the initialization parameters only take effect in the next gateway session. The most important parameter is the HS_FDS_CONNECT_INFO which describes the connection to the non-Oracle system.

The default initialization parameter file already has an entry for this parameter. The syntax for HS_FDS_CONNECT_INFO is as follows:

HS_FDS_CONNECT_INFO= host_name/[instance_name][/database_name]

Where:

VariableDescription
host_name is the host name or IP address of the machine hosting the SQL Server database.
instance_name is the instance of SQL Server running on the machine.
database_name is the SQL Server Database database name.

<!---->

Both instance_name and database_name are optional. If instance_name is omitted and database_name is provided, the slash (/) is required. This can be shown as follows:

HS_FDS_CONNECT_INFO= host_name//database_name

See Also:

Appendix C, "Initialization Parameters" and Oracle Database Heterogeneous Connectivity Administrator's Guide for more information about customizing the initialization parameter file.
<!---->
<!---->

Configure Oracle Net for the Gateway

The gateway requires Oracle Net to communicate with the Oracle database. After configuring the gateway, perform the following tasks to configure Oracle Net to work with the gateway:

  1. Configure Oracle Net Listener for the Gateway

  2. Stop and Start the Oracle Net Listener for the Gateway

Configure Oracle Net Listener for the Gateway

The Oracle Net Listener listens for incoming requests from the Oracle database. For the Oracle Net Listener to listen for the gateway, information about the gateway must be added to the Oracle Net Listener configuration file, listener.ora. This file by default is located in ORACLE_HOME\network\admin, where ORACLE_HOME is the directory under which the gateway is installed.

The following entries must be added to the listener.ora file:

  • A list of Oracle Net addresses on which the Oracle Net Listener listens

  • The executable name of the gateway that the Oracle Net Listener starts in response to incoming connection requests

A sample of the listener.ora entry (listener.ora.sample) is available in the ORACLE_HOME\dg4msql\admin directory where ORACLE_HOME is the directory under which the gateway is installed.

Syntax of listener.ora File Entries

The Oracle database communicates with the gateway using Oracle Net and any supported protocol adapters. The following is the syntax of the address on which the Oracle Net Listener listens using the TCP/IP protocol adapter:

LISTENER=
        (ADDRESS= 
          (PROTOCOL=TCP)
          (HOST=host_name)
          (PORT=port_number))

Where:

VariableDescription
host_name specifies the name of the machine on which the gateway is installed.
port_number specifies the port number used by the Oracle Net Listener. If you have other listeners running on the same machine, then the value of port_number must be different from the other listeners' port numbers.

<!---->

To direct the Oracle Net Listener to start the gateway in response to incoming connection requests, add an entry to the listener.ora file.

Note:

You must use the same SID value in the listener.ora file and the tnsnames.ora file which will be configured in the next step.
SID_LIST_LISTENER=
   (SID_LIST=
      (SID_DESC= 
         (SID_NAME=gateway_sid)
         (ORACLE_HOME=oracle_home_directory)
         (PROGRAM=dg4msql)
      )
   )

Where:

VariableDescription
gateway_sid specifies the SID of the gateway and matches the gateway SID specified in the connect descriptor entry in the tnsnames.ora file.
oracle_home_directory specifies the Oracle home directory where the gateway resides.
dg4msql specifies the executable name of the Oracle Database Gateway for SQL Server.

<!---->

If you already have an existing Oracle Net Listener, then add the following syntax to SID_LIST in the existing listener.ora file:

SID_LIST_LISTENER=
(SID_LIST= 
   (SID_DESC=.
     .
   )
   (SID_DESC=.
     .
   )
   (SID_DESC=
      (SID_NAME=gateway_sid)
      (ORACLE_HOME=oracle_home_directory)
      (PROGRAM=dg4msql)
   )
)

See Also:

Oracle Database Net Services Administrator's Guide for information about changing the listener.ora file.
<!---->
<!---->

Stop and Start the Oracle Net Listener for the Gateway

You must stop and restart the Oracle Net Listener to initiate the new settings, as follows:

  1. From the Start menu, select Settings, Control Panel and then select Services.

  2. Select the Oracle Net Listener service for the gateway.

  3. If the service is already running, click Stop to stop it.

  4. Click Start to start or restart the service.

<!---->
<!---->

Configure the Oracle Database for Gateway Access

Before you use the gateway to access SQL Server data you must configure the Oracle database to enable communication with the gateway over Oracle Net.

To configure the Oracle database you must add connect descriptors to the tnsnames.ora file. By default, this file is in ORACLE_HOME\network\admin, where ORACLE_HOME is the directory in which the Oracle database is installed. You cannot use the Oracle Net Assistant or the Oracle Net Easy Config tools to configure the tnsnames.ora file. You must edit the file manually.

A sample of the tnsnames.ora entry (tnsnames.ora.sample) is available in the ORACLE_HOME\dg4msql\admin directory where ORACLE_HOME is the directory under which the gateway is installed.

See Also:

Oracle Database Administrator's Guide for information about editing the tnsnames.ora file.

Configuring tnsnames.ora

Edit the tnsnames.ora file to add a connect descriptor for the gateway. The following is a syntax of the Oracle Net entry using the TCP/IP protocol:

connect_descriptor=
   (DESCRIPTION=
      (ADDRESS=
         (PROTOCOL=TCP)
         (HOST=host_name)
         (PORT=port_number)
      )
      (CONNECT_DATA=
         (SID=gateway_sid))
      (HS=OK))

Where:

VariableDescription
connect_descriptor is the description of the object to connect to as specified when creating the database link, such as dg4msql.

Check the sqlnet.ora file in the Oracle database's ORACLE_HOME for the following lines:

  • names.directory_path = (TNSNAMES, HOSTNAME)

  • names.default_domain = world

  • name.default_zone = world

Note: If the Oracle database is on Microsoft Windows, the file is ORACLE_HOME\network\admin\sqlnet.ora.

If the sqlnet.ora file has these lines, connect_descriptor must end with the extension .world.

TCP is the TCP protocol used for TCP/IP connections.
host_name specifies the machine where the gateway is running.
port_number matches the port number used by the Oracle Net Listener that is listening for the gateway. The Oracle Net Listener's port number can be found in the listener.ora file used by the Oracle Net Listener. See "Syntax of listener.ora File Entries".
gateway_sid specifies the SID of the gateway and matches the SID specified in the listener.ora file of the Oracle Net Listener that is listening for the gateway. See"Configure Oracle Net Listener for the Gateway" for more information.
(HS=OK) specifies that this connect descriptor connects to a non-Oracle system.

<!---->
<!---->
<!---->

Create Database Links

Any Oracle client connected to the Oracle database can access SQL Server data through the gateway. The Oracle client and the Oracle database can reside on different machines. The gateway accepts connections only from the Oracle database.

A connection to the gateway is established through a database link when it is first used in an Oracle session. In this context, a connection refers to the connection between the Oracle database and the gateway. The connection remains established until the Oracle session ends. Another session or user can access the same database link and get a distinct connection to the gateway and SQL Server database.

Database links are active for the duration of a gateway session. If you want to close a database link during a session, you can do so with the ALTER SESSION statement.

To access the SQL Server, you must create a database link. A public database link is the most common of database links.

SQL> CREATE PUBLIC DATABASE LINK dblink CONNECT TO
2  "user" IDENTIFIED BY "password" USING 'tns_name_entry';

Where:

VariableDescription
dblink is the complete database link name.
tns_name_entry specifies the Oracle Net connect descriptor specified in the tnsnames.ora file that identifies the gateway

<!---->

After the database link is created you can verify the connection to the SQL Server database, as follows:

SQL> SELECT * FROM DUAL@dblink;
<!---->

Configure Two-Phase Commit

The gateway supports the following transaction capabilities:

  • COMMIT_CONFIRM

  • READ_ONLY

  • SINGLE_SITE

The transaction model is set using the HS_TRANSACTION_MODEL initialization parameter. By default, the gateway runs in COMMIT_CONFIRM transaction mode. When the SQL Server database is updated by a transaction, the gateway becomes the commit point site. The Oracle database commits the unit of work in the SQL Server database after verifying that all Oracle databases in the transaction have successfully prepared the transaction. Only one gateway instance can participate in an Oracle two-phase commit transaction as the commit point site.

See Also:

Oracle Database Heterogeneous Connectivity Administrator's Guide for information about the two-phase commit process.

To enable the COMMIT_CONFIRM transaction mode, perform the following tasks:

  1. Create a Recovery Account and Password

  2. Create the Transaction Log Table

The log table, called HS_TRANSACTION_LOG, is where two-phase commit transactions are recorded.

Create a Recovery Account and Password

For the gateway to recover distributed transactions, a recovery account and password must be set up in the SQL Server database. By default, both the user name of the account and the password are RECOVER. The name of the account can be changed with the gateway initialization parameter HS_FDS_RECOVERY_ACCOUNT. The account password can be changed with the gateway initialization parameter HS_FDS_RECOVERY_PWD.

Note:

Oracle recommends that you do not use the default value RECOVER for the user name and password. Moreover, storing plain-text as user name and password in the initialization file is not a good security policy. There is now a utility called dg4pwd, that should be used for encryption. Refer to Section 4.2.3, 'Encrypting Initialization parameters' in the Oracle Database Heterogeneous Connectivity Administrator's Guide for further details.
  1. Set up a user account in the SQL Server database. Both the user name and password must be a valid SQL Server user name and password.

  2. In the initialization parameter file, set the following gateway initialization parameters:

    • HS_FDS_RECOVERY_ACCOUNT to the user name of the SQL Server user account you set up for recovery.

    • HS_FDS_RECOVERY_PWD to the password of the SQL Server user account you set up for recovery.

      See Also:

      "Customize the Initialization Parameter File" for information about editing the initialization parameter file. For information about HS_FDS_RECOVERY_ACCOUNT and HS_FDS_RECOVERY_PWD, see Appendix C, "Initialization Parameters".
<!---->

Create the Transaction Log Table

When configuring the gateway for two-phase commit, a table must be created in the SQL Server database for logging transactions. The gateway uses the transaction log table to check the status of failed transactions that were started at the SQL Server database by the gateway and registered in the table.

Note:

Updates to the transaction log table cannot be part of an Oracle distributed transaction.

Note:

The information in the transaction log table is required by the recovery process and must not be altered. The table must be used, accessed, or updated only by the gateway.

The table, called HS_TRANSACTION_LOG, consists of two columns, GLOBAL_TRAN_ID, data type CHAR(64) NOT NULL and TRAN_COMMENT, data type CHAR(255).

You can use another name for the log table, other than HS_TRANSACTION_LOG, by specifying the other name using the HS_FDS_TRANSACTION_LOG initialization parameter.

See Also:

Appendix C, "Initialization Parameters" for information about the HS_FDS_TRANSACTION_LOG initialization parameter.

Create the transaction log table in the user account you created in "Create a Recovery Account and Password". Because the transaction log table is used to record the status of a gateway transaction, the table must reside at the database where the SQL Server update takes place. Also, the transaction log table must be created under the owner of the recovery account.

Note:

To utilize the transaction log table, users of the gateway must be granted privileges on the table.

To create a transaction log table use the dg4msql_tx.sql script, located in the directory ORACLE_HOME\dg4msql\admin where ORACLE_HOME is the directory under which the gateway is installed. Use isql to execute the script at the MS-DOS prompt, as follows:

> isql -Urecovery_account -Precovery_account_password [-Sserver] -idg4msql_tx.sql
<!---->
<!---->

Create SQL Server Views for Data Dictionary Support

To enable Oracle data dictionary translation support use the dg4msql_cvw.sql script, located in the directory $ORACLE_HOME/dg4msql/admin where $ORACLE_HOME is the directory under which the gateway is installed. You must run this script on each SQL Server database that you want to access through the gateway. Use isql to execute the script, as follows:

$ isql -Usa_user -Psa_pwd [-Sserver] [-ddatabase] -e -i dg4msql_cvw.sql

where sa_user and sa_pwd are the SQL Server system administrator user ID and password respectively.

<!---->

Encrypt Gateway Initialization Parameter Values

The gateway uses user IDs and passwords to access the information in the remote database. Some user IDs and passwords must be defined in the gateway initialization file to handle functions such as resource recovery. In the current security conscious environment, having plain-text passwords that are accessible in the initialization file is deemed insecure. The dg4pwd encryption utility has been added as part of Heterogeneous Services to help make this more secure. This utility is accessible by this gateway. The initialization parameters which contain sensitive values can be stored in an encrypted form.

See Also:

Oracle Database Heterogeneous Connectivity Administrator's Guide for more information about using this utility.
<!---->

Configure the Gateway to Access Multiple SQL Server Databases

The tasks for configuring the gateway to access multiple SQL Server databases are similar to the tasks for configuring the gateway for a single database. The configuration example assumes the following:

  • The gateway is installed and configured with the default SID of dg4msql

  • The gateway is configured for one SQL Server database named db1

  • Two SQL Server databases named db2 and db3 on a host with IP Address 204.179.79.15 are being added

Multiple SQL Server Databases Example: Configuring the Gateway

Choose One System ID for Each SQL Server Database

A separate instance of the gateway is needed for each SQL Server database. Each instance needs its own gateway System ID (SID). For this example, the gateway SIDs are chosen for the instances that access the SQL Server databases:

  • dg4msql2 for the gateway accessing database db2

  • dg4msql3 for the gateway accessing database db3

Create Two Initialization Parameter Files

Create an initialization parameter file for each instance of the gateway by copying the original initialization parameter file: ORACLE_HOME\dg4msql\admin\initdg4msql.ora, twice, naming one with the gateway SID for db2 and the other with the gateway SID for db3:

> cd ORACLE_HOME\dg4msql\admin
> copy initdg4msql.ora initdg4msql2.ora
> copy initdg4msql.ora initdg4msql3.ora

Change the value of the HS_FDS_CONNECT_INFO parameter in the new files.

For initdg4msql2.ora, enter the following:

HS_FDS_CONNECT_INFO=204.179.79.15//db2

For initdg4msql3.ora, enter the following:

HS_FDS_CONNECT_INFO=204.179.79.15//db3

Note:

If you have multiple gateway SIDs for the same SQL Server database because you want to use different gateway parameter settings at different times, follow the same procedure. You create several initialization parameter files, each with different SIDs and different parameter settings.
<!---->

Multiple SQL Server Databases Example: Configuring Oracle Net Listener

Add Entries to listener.ora

Add two new entries to the Oracle Net Listener configuration file, listener.ora. You must have an entry for each gateway instance, even when multiple gateway instances access the same database.

The following example shows the entry for the original installed gateway first, followed by the new entries:

SID_LIST_LISTENER=
(SID_LIST=
   (SID_DESC=
      (SID_NAME=dg4msql)
      (ORACLE_HOME=oracle_home_directory)
      (PROGRAM=dg4msql)
   )
   (SID_DESC=
      (SID_NAME=dg4msql2)
      (ORACLE_HOME=oracle_home_directory)
      (PROGRAM=dg4msql)
   )
   (SID_DESC=
      (SID_NAME=dg4msql3)
      (ORACLE_HOME=oracle_home_directory)
      (PROGRAM=dg4msql)
   )
)

where, oracle_home_directory is the directory where the gateway resides.

<!---->

Multiple SQL Server Databases Example: Stopping and Starting the Oracle Net Listener

Perform the following steps:

  1. From the Start menu, select Settings, Control Panel and then select Services.

  2. Select the Oracle Net Listener service for the gateway.

  3. Click Stop.

  4. Click Start.

<!---->

Multiple SQL Server Databases Example: Configuring Oracle Database for Gateway Access

Add two connect descriptor entries to the tnsnames.ora file. You must have an entry for each gateway instance, even if the gateway instances access the same database.

This example describes how to configure Oracle Net on the Oracle database for multiple gateway instances. It shows the entry for the original installed gateway first, followed by the two entries for the new gateway instances:

old_db_using=(DESCRIPTION=
              (ADDRESS=
                (PROTOCOL=TCP)
                (PORT=port_number)
                (HOST=host_name))
                (CONNECT_DATA=
                    (SID=dg4msql))
               (HS=OK))
new_db2_using=(DESCRIPTION=
              (ADDRESS=
                (PROTOCOL=TCP)
                (PORT=port_number)
                (HOST=host_name))
                (CONNECT_DATA=
                    (SID=dg4msql2))
                (HS=OK))
new_db3_using=(DESCRIPTION=
              (ADDRESS=
                (PROTOCOL=TCP)
                (PORT=port_number)
                (HOST=host_name))
                (CONNECT_DATA=
                    (SID=dg4msql3))
                (HS=OK))

The value for PORT is the TCP/IP port number of the Oracle Net Listener that is listening for the gateway. The number can be found in the listener.ora file used by the Oracle Net Listener. The value for HOST is the name of the machine on which the gateway is running. The name also can be found in the listener.ora file used by the Oracle Net Listener.

<!---->

Multiple SQL Server Databases Example: Accessing SQL Server Data

Enter the following to create a database link for the dg4msql2 gateway:

SQL> CREATE PUBLIC DATABASE LINK MSQL2 CONNECT TO
  2  "user2" IDENTIFIED BY "password2" USING 'new_db2_using';

Enter the following to create a database link for the dg4msql3 gateway:

SQL> CREATE PUBLIC DATABASE LINK MSQL3 CONNECT TO
  2  "user3" IDENTIFIED BY "password3" USING 'new_db3_using';

After the database links are created, you can verify the connection to the new SQL Server databases, as in the following:

SQL> SELECT * FROM ALL_USERS@MSQL2;
SQL> SELECT * FROM ALL_USERS@MSQL3;
<!---->
<!----><!---->
分享到:
评论

相关推荐

    Pro SQL Server 2008 Replication pdf

    Pro SQL Server 2008 Replication is for Microsoft database developers and administrators who want to learn about the different types of replication and those best suited to SQL Server 2008. This book ...

    running rac on oracle vm server for sparc 2.0

    ### Oracle Real Application Clusters (RAC) on Oracle VM Server for SPARC 2.0 #### Introduction In the realm of enterprise computing, organizations are constantly seeking ways to reduce costs while ...

    Oracle Database 10g PL-SQL Programming

    PL/SQL (Procedural Language for SQL) is a procedural extension to SQL that provides a powerful way to manipulate data within the Oracle database environment. This section introduces the basics of PL/...

    SQL Server AlwaysOn Revealed(Apress,2ed,2016)

    Get a fast start to using AlwaysOn, the SQL ...Database administrators interested in growing their knowledge and skills in Microsoft SQL Server’s high-availability and disaster recovery feature set.

    Oracle_Database11g-Administration_Workshop_I-1-1212.pdf

    6 Configuring the Oracle Network Environment 7 Managing Database Storage Structures 8 Administering User Security 9 Managing Data Concurrency 10 Managing Undo Data 11 Implementing Oracle Database...

    Configuring Oracle Applications 11i With Oracle Portal (Doc ID 1

    Configuring Oracle Applications 11i With Oracle Portal (Doc ID 146469.1)

    Oracle_Database11g-Administration_Workshop2-2-1212.pdf

    6 Configuring the Oracle Network Environment 7 Managing Database Storage Structures 8 Administering User Security 9 Managing Data Concurrency 10 Managing Undo Data 11 Implementing Oracle Database...

    Direct Oracle Access 4.1.2 Full Source for Delphi 2010

    With the Direct Oracle Access components and objects you access an Oracle database directly, skipping the Borland Database Engine, only using SQL*Net. This gives you the following advantages: ...

    Virtualizing SQL Server with VMware_English

    The book "Virtualizing SQL Server with VMware" provides an in-depth exploration of best practices and techniques for virtualizing SQL Server using VMware solutions. Here, we delve into key knowledge ...

    Beginning Microsoft SQL Server 2008 Administration.pdf

    7. **第七章:Configuring SQL Server Network Communication** - 介绍如何配置SQL Server 2008的网络通信,包括TCP/IP、Named Pipes等协议的设置方法。 8. **第八章:Automating Administrative Tasks** - 探讨如何...

    Oracle_Database11g-Administration_Workshop2-3-1212.pdf

    6 Configuring the Oracle Network Environment 7 Managing Database Storage Structures 8 Administering User Security 9 Managing Data Concurrency 10 Managing Undo Data 11 Implementing Oracle Database...

    SQLDirect v6.5 for D5-10.1 Berlin Full Source

    SQLDirect Component Library is a light-weight Borland Database Engine replacement for Borland/CodeGear/Embarcadero Delphi v.5 - 10, 2010, XE-XE10 and C++Builder v.5 - 2010, XE-XE10. It uses the native...

    Oracle 2 Day DBA

    Oracle快速DBA入门文档 Oracle Database 2 Day DBA is a database administration quick start guide that ...troubleshooting, creating backups for your database, performance monitoring activities, and more.

    configuring and tuning oracle storage with veritas database edition

    VERITAS Database Edition for Oracle 是一套集成的存储管理软件产品,能够增强 Oracle 数据库的性能、可用性、可恢复性和可管理性。 #### VERITAS Database Edition for Oracle 组件 VERITAS Database Edition for...

    Oracle Security

    Standards for the Oracle Security Server Standards for Employees Sample Security Plan Index Sample Security Plan Checklist Chapter 8 Installing and Starting Oracle Segmenting Application ...

    Exam Ref 70-410: Installing and Configuring Windows Server 2012 R2

    Prepare for Microsoft Exam 70-410 – and help demonstrate your real-world mastery of implementing and configuring core services in Windows Server 2012 R2. Designed for experienced IT professionals ...

    SQLSERVER2012

    - 在“Installing, configuring, and upgrading”这一章节中,很可能会详细讲解SQL Server 2012的安装过程,包括硬件和软件的最小需求、安装向导的使用、安装选项的配置(如认证模式、排序规则、实例配置等)。...

Global site tag (gtag.js) - Google Analytics