使用在 OCI 運算中執行的 Oracle Database Gateway 載入資料

OracleDB for Azure 可讓 Azure 應用程式從 OCI 資料庫載入和查詢資料。此架構描述 Oracle Exadata Database Service on Dedicated Infrastructure 如何運用 OracleDB for Azure 所提供的基礎架構,透過在 OCI 運算執行處理中執行的 Oracle Database Gateway for SQL Server 軟體,使用資料庫連結從 Azure SQL Server 載入和查詢資料。

架構

此架構使用在 OCI 運算執行處理中執行的 Oracle Database Gateway for SQL Server ,將資料從 Azure SQL Server 載入至 Oracle Exadata Database Service on Dedicated InfrastructureOracle Database Gateway for SQL Server 使用 Azure 專用端點的快速延遲網路連結,連線至 Azure SQL Server

下圖說明此架構。



exadata-db-azure-odsa-gateway.zip

請注意下列與此架構的相關資訊:

  • 必須在 Oracle Exadata Database Service on Dedicated Infrastructure 從屬端子網路中建立新的安全規則,以允許傳送至連接埠 1521 的流量。
  • Oracle Database Gateway 軟體可在 OCI 運算虛擬機器或裸機上執行。必須根據 Oracle Database Gateway for SQL Server 伺服器需求和大小準則,將 OCPU、記憶體和磁碟大小指定給 OCI 運算執行處理。如需詳細資訊,請參閱下方的 Oracle Database Gateway for SQL Server 系統需求。
  • OCI 中必須要有 Azure SQL Server 端點的 IP 位址解析主機名稱。編輯 Oracle Database Gateway 伺服器上的 /etc/hosts 檔案,或設定 Oracle Exadata Database Service on Dedicated Infrastructure 之 OCI 虛擬雲端網路 (VCN) 上的專用 DNS 區域。
  • Oracle Exadata Database Service on Dedicated Infrastructure 資料庫中,參數 global_names 預設會設為 TRUE。因此,建立至 Azure SQL Server 的資料庫連結時,必須使用完整資料庫名稱。

開始之前

開始之前,請檢查本設定中所使用之主要軟體元件的版本、下載所需的軟體套裝程式,以及複查產品文件以供日後參考。

複查軟體需求

這些指示已針對下列軟體和硬體版本進行測試。

  • Oracle Exadata Database Service on Dedicated Infrastructure X8M-2
  • Oracle Database 19.16
  • Azure SQL 伺服器

下載下列套裝軟體:

關於必要的服務與角色

此解決方案需要下列服務:

  • Oracle Exadata Database Service on Dedicated Infrastructure with OracleDB for Azure
  • Oracle Cloud Infrastructure
  • Oracle Cloud Infrastructure 運算

這些是每項服務所需的角色。

服務名稱:角色 需要 ...
Oracle Exadata Database Service on Dedicated Infrastructure: sys con 設定資料庫連結。
Oracle Cloud Infrastructure :VCN Admin 新增安全規則及修改 DNS。
Oracle Cloud Infrastructure Compute :admin 建立運算執行處理以安裝 Oracle Database Gateway
Oracle Cloud Infrastructure Compute :opc/root 建立使用者以安裝並設定 Oracle Database Gateway 軟體。修改本機防火牆以允許連線至連接埠 1521。

請參閱瞭解如何取得 Oracle 解決方案適用的 Oracle Cloud 服務,以取得您需要的雲端服務。

在 OCI 運算執行處理中執行的 Oracle Database Gateway 考量

請先複查這些考量,再導入此解決方案。在 OCI 運算執行處理中執行 Oracle Database Gateway for SQL Server ,非常適合熟悉 OCI 服務的客戶。

在 OCI 運算中執行的 Oracle Database Gateway 之優點

  • Oracle Database Gateway for SQL Server 是由 Oracle 開發與支援。
  • Oracle Exadata Database Service on Dedicated Infrastructure 上不需要安裝任何其他第三方軟體,即可輕鬆更新和維護環境。
  • Oracle Database Gateway for SQL Server 是從 Oracle Exadata Database Service on Dedicated Infrastructure 在個別的運算執行處理上執行,讓兩個環境都更容易更新與維護。此外,這個解決方案經濟實惠,因為 Oracle Database Gateway 軟體以成本較低的 OCI 運算 OCPU 執行,而不是在更為專業、價格更高之 Oracle Exadata Database Service on Dedicated Infrastructure OCPU 上執行。
  • Oracle Database Gateway Server 與 Microsoft Azure SQL Server 之間的通訊會經過加密 (預設由 Microsoft Azure SQL Server 強制實行)。
  • Oracle 資料庫與 Microsoft Azure SQL Server 資料庫之間的資料類型轉換和對應會自動由 Oracle Database Gateway 軟體管理。

在 OCI 運算中執行的 Oracle Database Gateway 缺點

  • 您可能需要額外取得 Oracle Database Gateway 軟體授權。
  • 設定 Oracle Database Gateway 伺服器時,Oracle Exadata Database Service on Dedicated InfrastructureOracle Database Gateway 伺服器之間的通訊預設不會加密。必須在 Oracle Database Gateway Server sqlnet.ora 中設定額外的組態,才能從 Oracle Exadata Database Service on Dedicated Infrastructure 強制加密至 Oracle Database Gateway 伺服器。

設定在 OCI 運算中執行的 Oracle Database Gateway

  1. 登入 Azure 主控台,以取得 Oracle Exadata Database Service on Dedicated Infrastructure 資料庫將載入並查詢資料的 Azure SQL Server 資料庫資訊。此資訊是告知 Oracle Database Gateway 伺服器如何連線至 Azure SQL Server 資料庫的必要資訊。
    取得下列詳細資訊:
    • 資料庫名稱Azure SQL Server 資料庫的名稱。
    • 完整伺服器名稱:執行 Azure SQL Server 資料庫之 SQL 伺服器的完整主機名稱,通常格式為 servername.database.windows.net
    • Azure SQL Server 專用端點:連線至 Azure SQL Server 之 Azure vnet 中的 Azure SQL Server 專用端點名稱和 IP 位址。如果尚無專用端點,請為 Azure SQL Server 建立專用端點,並記下名稱和 IP 位址。
    • Azure SQL Server 使用者名稱:允許連線至 Azure SQL Server 資料庫和綱要的現有 Azure SQL Server 使用者名稱,通常是 sqladmin
    • Azure SQL Server 使用者密碼Azure SQL Server 使用者用來連線至 Azure SQL Server 資料庫和綱要的密碼。
  2. 登入 OCI 主控台,並在 OracleDB for Azure Oracle Exadata Database Service on Dedicated Infrastructure 從屬端子網路上建立執行 Oracle Linux 7。9 的 OCI 運算執行處理。此運算執行處理將執行 Oracle Database Gateway for SQL Server
    請注意指定給此運算執行處理的 hostnameIP 位址。這是告知 Oracle Exadata Database Service on Dedicated Infrastructure 如何連線至 Oracle Database Gateway 伺服器的必要資訊。
  3. 從 OCI 功能表中,選取網路 /DNS 管理,然後建立專用 DNS 區域。在新的專用 DNS 區域中,從步驟 1 為「完整伺服器名稱」新增一筆記錄,以從步驟 1 解析為 Azure SQL Server 專用端點 IP 位址。
  4. 從 OCI 功能表建立 DNS 專用檢視。將步驟 3 中建立的專用 DNS 區域加到此 DNS 專用檢視,然後啟用變更。
  5. 從 OCI 功能表中選取網路 / 虛擬從屬端網路 (VCN) 。Select the VCN created when the OracleDB for Azure for Oracle Exadata Database Service on Dedicated Infrastructure was provisioned (change the compartment if required).選取 DNS 解析器連結,然後將先前建立的 DNS 專用檢視新增至 DNS 解析器。
    這可讓 OCI 服務 (運算和 Oracle Exadata Database Service on Dedicated Infrastructure) 的名稱和 IP 位址解析成 Azure SQL Server 專用端點。
  6. 登入其中一個 Oracle Exadata Database Service on Dedicated Infrastructure VM 叢集節點,並使用 nslookup 命令驗證主機名稱與 IP 位址解析是否適用於 Azure SQL Server 主機名稱與專用端點 IP 位址。
    例如:
    [opc@exa_dbnodex ~]$ nslookup servername.database.windows.net
    Server: 169.254.169.254
    Address: 169.254.169.254#53
    Non-authoritative answer:
    Name: servername.database.windows.net
    Address: IP_address_of_Azure_SQL_Server_private_endpoint
     [opc@exa_dbnodex ~]$
    範例中的變數具有下列值:
    • servername 是步驟 1 中 Azure SQL Server 的完整伺服器名稱。
    • IP_address_of_Azure_SQL_Server_private_endpoint 是步驟 1 之 Azure SQL Server 專用端點的 IP 位址。
  7. 安裝稍早在新 OCI 運算執行處理上下載的 Oracle Database Gateway 軟體。
  8. Configure the Oracle Database Gateway for Azure SQL Server running in the OCI Compute instance to connect to the Azure SQL Server database via the Azure SQL Server private endpoint using the fast-low latency network link configured by OracleDB for Azure between Azure and OCI.
  9. Oracle Exadata Database Service on Dedicated Infrastructure VM 叢集的所有節點上,設定 Oracle Exadata Database Service on Dedicated Infrastructure 資料庫 tnsnames.ora 以解析為 Oracle Database Gateway for SQL Server
    例如:
    [opc@exa_dbnodex ~]$ sudo su - oracle
    Last login: Tue Sep 13 20:06:30 UTC 2022
    [oracle@ exa_dbnodex ~]$ . ./exadb_name.env
    [oracle@ exa_dbnodex ~]$ cd $ORACLE_HOME
    [oracle@ exa_dbnodex dbhome_1]$ cd network/admin
    [oracle@ exa_dbnodex admin]$ cd exadb_name/
    [oracle@ exa_dbnodex exadb_name]$ tail -10 tnsnames.ora
    Database_Name_From_Step_1 =
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST=OCI_Compute_Instance_Hostname_From_Step_2)(PORT=1521))
    (CONNECT_DATA=(SID=Database_Name_From_Step_1,))
    (HS=OK)
    )
    範例中的變數具有下列值:
    • exadb_nameOracle Exadata Database Service on Dedicated Infrastructure 資料庫的名稱。
    • Database_Name_From_Step_1 是步驟 1 的資料庫名稱。
    • OCI_Compute_Instance_Hostname_From_Step_2 是 OCI 運算執行處理從步驟 2 開始的主機名稱。
  10. 使用 tnsping 命令測試在 OCI 運算中執行的 Oracle Exadata Database Service on Dedicated InfrastructureOracle Database Gateway 之間的連線 (此連線完全在 OCI VCN 內)。
    例如:
    [oracle@exajc-dbnodex ~]$ tnsping Database_Name_From_Step_1
    TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 16-SEP-2022 21:28:34
    Used parameter files:
    /u02/app/oracle/product/19.0.0.0/dbhome_1/network/admin/exadb_name/s
    qlnet.ora
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION= 
    (ADDRESS=(PROTOCOL=tcp)(HOST==OCI_Compute_Instance_Hostname_From_Step_2)(PORT=1521)) (CONNECT_DATA=(SID=Database_Name_From_Step_1)) 
    (HS=OK))
    OK (0 msec)
    [oracle@exadbnodex ~]$
    範例中的變數具有下列值:
    • Database_Name_From_Step_1 是步驟 1 中 Azure SQL Server 資料庫的名稱。
    • exadb_nameOracle Exadata Database Service on Dedicated Infrastructure 資料庫的名稱。
    • OCI_Compute_Instance_Hostname_From_Step_2 是 OCI 運算執行處理從步驟 2 開始的主機名稱。
  11. Oracle Exadata Database Service on Dedicated Infrastructure 可插式資料庫 (PDB) (不在 CDB 中),建立與 Azure SQL Server 資料庫的資料庫連結。Oracle Exadata Database Service on Dedicated Infrastructure 資料庫中參數 global_names 預設為 TRUE,因此必須使用完整的資料庫名稱來建立資料庫連結。建立資料庫連結之後,您可以使用此連結,從 Azure SQL Server 資料庫查詢和載入資料至 Oracle Exadata Database Service on Dedicated Infrastructure 可插式資料庫。
    [opc@exadbnodex ~]$ sudo su - oracle
    Last login: Tue Sep 13 20:06:30 UTC 2022
    [oracle@exadbnodex ~]$ . ./exadb_name.env
    [oracle@exadbnodex ~]$sqlplus / as sysdba
    SQL> show pdbs;
    CON_ID CON_NAME OPEN MODE RESTRICTED
    ---------- ------------------------------ ---------- ----------
     2 PDB$SEED READ ONLY NO
     3 PDBName READ WRITE NO
    SQL> alter session set container=PDBName;
    Session altered.
    SQL>create public database 
    link Fully_Qualified_Server_Name_From_Step_1 connect to 
    "Azure_SQL_Server_Username" identified by 
    "Azure_SQL_User_password" using 
    'Database_Name_From_Step_1';
    Database link created.
    請注意,使用者名稱和密碼會以雙引號 (" ") 括住,而 Azure SQL Server 資料庫名稱則以單引號 (' ') 括住。
    範例中的變數具有下列值:
    • exadb_nameOracle Exadata Database Service on Dedicated Infrastructure 資料庫的名稱。
    • PDBName 是可插拔資料庫的名稱。
    • Fully_Qualified_Server_Name_From_Step_1 是執行 Azure SQL Server 資料庫之 SQL 伺服器的完整主機名稱,從步驟 1 開始。
    • Azure_SQL_Server_Username 是現有 Azure SQL Server 使用者名稱,從步驟 1 開始。
    • Azure_SQL_User_PasswordAzure SQL Server 使用者從步驟 1 連線至資料庫的密碼。
    • Database_Name_From_Step_1Azure SQL Server 資料庫的名稱,從步驟 1 開始。
  12. 透過執行查詢來測試新建立的資料庫連結。例如:
    SQL> select count(*) from 
    some_table@DatabaseLink_Name_From_Previous_Step;
    範例中的變數具有下列值:
    • some_table 是資料庫中要查詢的表格名稱。
    • DatabaseLink_Name_From_Previous_Step 是步驟 11 的資料庫連結名稱。

安裝 Oracle Database Gateway 伺服器

以下步驟描述如何在執行 Oracle Linux 7。9 的 OCI 運算執行處理上安裝 Oracle Database Gateway Server 軟體。

  1. 使用 yum 來安裝 Oracle 先決條件套裝軟體。
    [root@dbgw ~]# yum install oracle-database-preinstall-19c
  2. 建立 useroracledba 群組。
    [root@dbgw ~]# useradd -u 1001 -g dba -d /home/oracle -m -s /bin/bash oracle
    [root@dbgw ~]# groupadd -g 1001 dba
  3. 建立 Oracle Database Gateway 19.3 的安裝目錄。
    [root@dbgw ~]# mkdir /u01
    [root@dbgw ~]# chown oracle:dba /u01
  4. 修改本機防火牆以允許連線至連接埠 1521。
    [root@dbgw ~]# firewall-cmd --get-active-zones
    public
    interfaces: eth0
    [root@dbgw ~]# firewall-cmd --zone=public --add-port=1521/tcp –permanent
    [root@dbgw ~]# firewall-cmd --reload
    [root@dbgw ~]# firewall-cmd --zone=public --list-ports
    1521/tcp
    [root@dbgw ~]# systemctl stop firewalld
    [root@dbgw ~]# systemctl start firewalld
  5. 將先前下載的 Oracle Database Gateway 19.3 zip 檔案複製到 linux VM 的 /home/oracle 目錄,然後解壓縮 Oracle Database Gateway 19.3 zip 檔案。
    [oracle@dbgw ~]$ unzip LINUX.X64_193000_gateways.zip
  6. 從包含的範本建立安裝回應檔。
    [oracle@dbgw response]$ cd /home/oracle/gateways/response/
    [oracle@dbgw response]$ cp tg.rsp/home/oracle/tg-jc.rsp
  7. 使用下列選項修改回應檔。
    UNIX_GROUP_NAME=oracle
    INVENTORY_LOCATION=/u01/app/oraInventory
    ORACLE_HOME=/u01/app/oracle/product/gateway
    ORACLE_BASE=/u01/app/oracle
    oracle.install.tg.msqlConStr={Fully_Qualified_Server_Name_From_Step_1,1433,
    Database_Name_From_Step_1,Database_Name_From_Step_1}
    範例中的變數具有下列值:
    • Fully_Qualified_Server_Name_From_Step_1 是執行 Azure SQL Server 資料庫之 SQL 伺服器的完整主機名稱,從步驟 1
    • Database_Name_From_Step_1Azure SQL Server 資料庫的名稱,從步驟 1 取得。
  8. 執行無訊息安裝以安裝 Oracle Database Gateway 19.3。
    [oracle@dbgw gateways]$./runInstaller -silent -noconfig -
    responseFile /home/oracle/tg-jc.rsp
  9. 設定使用者 oracle 的 Oracle 本位目錄和路徑。
    [oracle@dbgw ~]$ tail -6 .bash_profile
    ORACLE_HOME=/u01/app/oracle/product/gateway
    export ORACLE_HOME
    PATH=$PATH:$ORACLE_HOME/bin
    export PATH
    [oracle@dbgw ~]$

設定 Oracle Database Gateway for SQL Server

在執行 Linux 7.9 的 OCI 運算執行處理上安裝 Oracle Database Gateway 之後,必須將它設定為使用 Azure SQL Server 專用端點連線至 Azure SQL Server 資料庫。

  1. Azure SQL Server 資料庫資訊新增至在 OCI 運算執行處理上執行的 Oracle Database Gateway for SQL Server 初始化檔案。此資訊會告訴 Oracle Database Gateway 如何連線至 Azure SQL Server 資料庫。
    例如:
    [oracle@dbgw ~]$ cd $ORACLE_HOME/dg4msql/admin
    [oracle@dbgw admin]$ cp initdg4msql.ora 
    initDatabase_Name_From_Step_1.ora
    [oracle@dbgw admin]$ cat initDatabase_Name_From_Step_1.ora
    # This is a customized agent init file that contains the HS parameters
    # that are needed for the Database Gateway for Microsoft SQL Server
    # HS init parameters
    #
    HS_FDS_CONNECT_INFO=Fully_Qualified_Server_Name_From_Step_1:1433//Database_Name_From_Step_1
    # alternate connect format is hostname/serverinstance/databasename
    HS_DB_NAME=Database_Hostname_From_Step_1
    HS_DB_DOMAIN=Database_Domain_Name #usually database.windows.net
    HS_FDS_TRACE_LEVEL=OFF
    HS_FDS_RECOVERY_ACCOUNT=RECOVER
    HS_FDS_RECOVERY_PWD=RECOVER
    HS_FDS_ENCRYPT_SESSION=SSL
    HS_FDS_VALIDATE_SERVER_CERT=0
    範例中的變數具有下列值:
    • Database_Name_From_Step_1Azure SQL Server 資料庫的名稱,從步驟 1 取得。
    • Fully_Qualified_Server_Name_From_Step_1 是執行 Azure SQL Server 資料庫之 SQL 伺服器的完整主機名稱,從步驟 1
    • Database_Hostname_From_Step_1 是資料庫的主機名稱,從步驟 1 開始。
    • Database_Domain_Name 是資料庫所在的網域名稱,通常為 database.windows.net
    請注意,若要加密 Oracle Database Gateway 伺服器和 Azure SQL Server 之間的連線,需要參數 HS_FDS_ENCRYPT_SESSIONHS_FDS_VALIDATE_SERVER_CERT
  2. Oracle Database Gateway 伺服器上,修改 tnsnames.ora 以解析為此閘道提供的閘道服務,如下所示:
    [oracle@dbgw ~]$ cat $ORACLE_HOME/network/admin/tnsnames.ora
    # This is a sample tnsnames.ora that contains the NET8 parameters that are
    # needed to connect to an HS Agent
    Database_Name_From_Step_1 =
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST= 
    OCI_Compute_Instance_Hostname_From_Step_2)(PORT=1521))
    (CONNECT_DATA=(SID=Database_Name_From_Step_1))
    (HS=OK)
    )
    範例中的變數具有下列值:
    • Database_Name_From_Step_1Azure SQL Server 資料庫的名稱,從步驟 1 取得。
    • OCI_Compute_Instance_Hostname_From_Step_2 是 OCI 運算執行處理的主機名稱,來自步驟 2
  3. Oracle Database Gateway 伺服器上,修改 listener.ora 以包含 Oracle Database Gateway 資訊。
    [oracle@dbgw-jc admin]$ cat ../../network/admin/listener.ora
    # This is a sample listener.ora that contains the NET8 parameters that are
    # needed to connect to an HS Agent
    LISTENER =
    (ADDRESS_LIST=
    (ADDRESS=(PROTOCOL=tcp)(HOST=
    OCI_Compute_Instance_Hostname_From_Step_2)(PORT=1521))
    )
    SID_LIST_LISTENER=
    (SID_LIST=
    (SID_DESC=
     (SID_NAME=Database_Name_From_Step_1)
     (ORACLE_HOME=/u01/app/oracle/product/gateway)
     (PROGRAM=dg4msql)
    )
    )
    範例中的變數具有下列值:
    • OCI_Compute_Instance_Hostname_From_Step_2 是 OCI 運算執行處理的主機名稱,來自步驟 2
    • Database_Name_From_Step_1步驟 1Azure SQL Server 資料庫的名稱。
  4. 在 OCI 運算執行處理中執行的 Oracle Database Gateway 伺服器中啟動監聽器,並測試對閘道的連線。
    例如:
    [oracle@dbgw admin]$lsnrctl start
    [oracle@dbgw admin]$ tnsping Database_Name_From_Step_1
    TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 16-SEP-2022 21:18:39
    Used TNSNAMES adapter to resolve the alias
    Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST= 
    OCI_Compute_Instance_Hostname_From_Step_2)(PORT=1521)) 
    (CONNECT_DATA=(SID=Database_Name_From_Step_1)) (HS=OK))
    OK (0 msec)
    [oracle@dbgw-jc admin]$
    範例中的變數具有下列值:
    • Database_Name_From_Step_1步驟 1Azure SQL Server 資料庫的名稱。
    • OCI_Compute_Instance_Hostname_From_Step_2 是 OCI 運算執行處理的主機名稱,來自步驟 2