使用在 Azure VM 中執行的 Oracle Database Gateway 伺服器載入資料

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

架構

此架構使用在 Azure 虛擬機器中執行的 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-azure-vm.zip

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

  • Oracle Database Gateway for SQL Server 軟體可在 Azure 虛擬機器上執行。必須根據 Oracle Database Gateway for SQL Server 需求和大小準則,將 CPU、記憶體和磁碟大小指派給 Azure 虛擬機器。請參閱下方的 Oracle Database Gateway for SQL Server 系統需求瞭解詳細資訊。
  • Oracle Exadata Database Service on Dedicated Infrastructure needs to resolve the hostname and IP address of the Azure virtual machine running Oracle Database Gateway.編輯 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 伺服器

下載下列套裝軟體:

關於必要的服務與角色

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

  • OracleDB 適用於 Azure ,搭配 Oracle Exadata Database Service on Dedicated Infrastructure
  • Oracle Cloud Infrastructure
  • Azure 虛擬機器

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

服務名稱:角色 需要 ...
Oracle Exadata Database Service on Dedicated Infrastructure: sys con 設定資料庫連結。
Oracle Cloud Infrastructure :VCN Admin 新增安全規則、修改 DNS 以解析為 Azure 端點和 Azure VM。
Azure 虛擬機器:root 建立 oracle 使用者來安裝和設定 Oracle Database Gateway 軟體。修改本機防火牆以允許連線至連接埠 1521。

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

Azure 虛擬機器中執行的 Oracle Database Gateway 考量

在 Azure 虛擬機器中執行 Oracle Database Gateway for SQL Server ,對於熟悉 Azure 服務但不熟悉 OCI 服務的客戶而言相當理想。

在 Azure VM 中執行之 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 軟體以成本較低的 Azure OCPU 執行,而不是在更具專業化、價格更高之 Oracle Exadata Database Service on Dedicated Infrastructure OCPU 上執行,因此該解決方案可能更經濟實惠。
  • Oracle Database Gateway Server 與 Azure SQL Server 之間的通訊會經過加密 (由 Azure SQL Server 預設組態強制實行)。
  • Oracle Database 和 Azure SQL Server Database 之間的資料類型轉換和對應會自動由 Oracle Database Gateway 軟體管理。
  • Azure SQL Server 的主機名稱解析是由 Azure 在 Azure 虛擬機器層次自動管理。

Azure 虛擬機器中執行的 Oracle Database Gateway 缺點

  • 可能需要有其他 Oracle Database Gateway 軟體授權。
  • 設定 Oracle Database Gateway 伺服器時,預設不會加密 Oracle Exadata Database Service on Dedicated InfrastructureOracle Database Gateway 伺服器之間的通訊。Oracle Database Gateway sqlnet.ora 中的其他組態需要強制將 Oracle Exadata Database Service on Dedicated Infrastructure 加密至 Oracle Database Gateway 伺服器。

設定在 Azure Virtual Machine 中執行的 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 Server 的完整主機名稱,通常格式為 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. 在為 OracleDB for Azure 設定的 vnet 上建立執行 Linux 7.9 的 Azure 虛擬機器。此虛擬機器將執行 Oracle Database Gateway for SQL Server 。注意指派給此虛擬機器的 hostnameIP 位址 (在 Azure vnet 上),必須提供此資訊,告知 Oracle Exadata Database Service on Dedicated Infrastructure 資料庫如何連線至 Oracle Database Gateway 伺服器。主機名稱的格式通常是 servername.windows.net
  3. 從 OCI 主功能表選取網路 /DNS 管理以建立專用 DNS 區域。在新的專用 DNS 區域中,新增在上一步建立的 Azure VM 記錄主機名稱和 IP 位址。
  4. 從 OCI 主功能表選取網路 /DNS 管理 (Networking/DNS Management) ,以建立 DNS 專用檢視。將在上一個步驟中建立的專用 DNS 區域加到這個新建立的 DNS 專用檢視,然後啟用變更。
  5. 從 OCI 主功能表選取網路 / 虛擬從屬端網路 (VCN) 。選取佈建 Oracle Database Gateway Oracle Exadata Database Service on Dedicated Infrastructure 服務時所建立的 VCN (視需要變更區間)。按一下 DNS 解析器連結,然後將從上一個步驟建立的 DNS 專用檢視新增至 DNS 解析器。這將允許將名稱和 IP 位址解析從 Oracle Exadata Database Service on Dedicated Infrastructure 到執行 Oracle Database Gateway 的 Azure VM。
  6. Log in to one of the Oracle Exadata Database Service on Dedicated Infrastructure VM Cluster nodes to use nslookup to verify the hostname to IP address resolution is working for the Azure VM that will run Oracle Database Gateway.
    例如:
    [opc@exa_dbnodex ~]$ nslookup servername.windows.net
    Server: 169.254.169.254
    Address: 169.254.169.254#53
    Non-authoritative answer:
    Name: servername.windows.net
    Address: IP_address_of_Azure_VM_from_step_2
    [opc@exa_dbnodex ~]$
    範例中的變數具有下列值:
    • servername 是步驟 1 中 Azure SQL Server 專用端點的名稱。
    • IP_address_of_Azure_VM_from_step_2 是步驟 2 中 Azure VM 的 IP 位址。
  7. 安裝稍早在新 Azure 虛擬機器上下載的 Oracle Database Gateway 軟體。
  8. 設定 Oracle Database Gateway for Azure SQL Server ,使用 Azure SQL Server 專用端點連線至 Azure SQL Server 資料庫。
    請注意,執行 Oracle Database GatewayAzure SQL Server 專用端點的 Azure 虛擬機器,位於相同的 Azure vnet。
  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=Azure_VM_Hostname_From_Step_2)(PORT=15
    21))
    (CONNECT_DATA=(SID=Database_Name_From_Step_1))
    (HS=OK)
    )
    範例中的變數具有下列值:
    • exadb_nameOracle Exadata Database Service on Dedicated Infrastructure 資料庫的名稱。
    • Database_Name_From_Step_1 是步驟 1 的資料庫名稱。
    • Azure_VM_Hostname_From_Step_2 是步驟 2 中 Azure VM 的主機名稱。
  10. 使用 tnsping 測試 Oracle Exadata Database Service on Dedicated Infrastructure 資料庫與 Azure 虛擬機器中執行之 Oracle Database Gateway for SQL Server 之間的連線 (此連線使用 Azure 與 OCI 之間 OracleDB for Azure 所建立的快速延遲網路連結)。
    [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=Azure_VM_Hostname_From_Step_2)(PORT=15
    21)) (CONNECT_DATA=(SID=Database_Name_From_Step_1)) (HS=OK))
    OK (0 msec)
    [oracle@exadbnodex ~]$
    範例中的變數具有下列值:
    • exadb_nameOracle Exadata Database Service on Dedicated Infrastructure 資料庫的名稱。
    • Database_Name_From_Step_1 是步驟 1 的資料庫名稱。
    • Azure_VM_Hostname_From_Step_2 是步驟 2 中 Azure VM 的主機名稱。
  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 可插式資料庫 (PDB)
    [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;
    範例中的變數具有下列值:
    • some_table 是資料庫中要查詢的表格名稱。
    • DatabaseLink_Name 是步驟 11 的資料庫連結名稱。

安裝 Oracle Database Gateway Server

這些步驟描述如何在執行 Oracle Linux 7。9 的 Azure 虛擬機器上安裝 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 Server 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 的 Azure 虛擬機器上安裝 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:1433//Database_Name_From_Step_1
    # alternate connect format is hostname/serverinstance/databasename
    HS_DB_NAME=Database_Name_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 是執行 Azure SQL Server 資料庫之 SQL 伺服器的完整主機名稱,從步驟 1
    • Database_Domain_Name 是資料庫位於步驟 1 的網域名稱,通常為 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
    Azure_SQL_Server_Database_Name =
    (DESCRIPTION=
    (ADDRESS=(PROTOCOL=tcp)(HOST= 
    Azure_VM_Hostname_From_Step_2)(PORT=1521))
    (CONNECT_DATA=(SID=Azure_SQL_Server_Database_Name))
    (HS=OK)
    )
    範例中的變數具有下列值:
    • Azure_SQL_Server_Database_Name步驟 1Azure SQL Server 資料庫的名稱。
    • Azure_VM_Hostname_From_Step_2 是 Azure VM 的主機名稱,來自步驟 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=
    Azure_VM_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)
    )
    )
    範例中的變數具有下列值:
    • Azure_VM_Hostname_From_Step_2 是 Azure VM 的主機名稱,來自步驟 2
    • Database_Name_From_Step_1Azure SQL Server 資料庫的名稱,從步驟 1 取得。
  4. Oracle Database Gateway 伺服器中啟動在 Azure VM 中執行的監聽器,並測試閘道的連線。
    例如:
    [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= 
    Azure_VM_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_1Azure SQL Server 資料庫的名稱,從步驟 1 取得。
    • Azure_VM_Hostname_From_Step_2 是 Azure VM 的主機名稱,來自步驟 2