本頁面說明如何在 Compute Engine 虛擬機器 (VM) 設定反向 Proxy,為異質 Oracle 遷移作業建立來源私人連線。
如要使用 私人 IP 連線,且來源所在的虛擬私有雲網路,與您為虛擬私有雲對接建立私人連線設定的網路不同,則必須使用反向 Proxy VM。
設定反向 Proxy
如要建立 Compute Engine VM 來託管 Proxy,請按照下列步驟操作:
- 在 Compute Engine 中建立 Linux VM 執行個體。
-
連線至機器後,請建立必要的
iptables轉送規則來轉送流量。您可以使用下列指令碼。使用下列任何指令資料前,請先替換以下項目:
- SOURCE_PRIVATE_IP 替換為來源執行個體的私人 IP 位址。
- PORT 替換為來源 Oracle 執行個體監聽連線的通訊埠編號。
#! /bin/bash export DB_ADDR=SOURCE_PRIVATE_IP export DB_PORT=PORT # Enable the VM to receive packets whose destinations do # not match any running process local to the VM echo 1 > /proc/sys/net/ipv4/ip_forward # Ask the Metadata server for the IP address of the VM nic0 # network interface: md_url_prefix="http://169.254.169.254/computeMetadata/v1/instance" vm_nic_ip="$(curl -H "Metadata-Flavor: Google" ${md_url_prefix}/network-interfaces/0/ip)" # Clear any existing iptables NAT table entries (all chains): iptables -t nat -F # Create a NAT table entry in the prerouting chain, matching # any packets with destination database port, changing the destination # IP address of the packet to your source instance IP address: iptables -t nat -A PREROUTING \ -p tcp --dport $DB_PORT \ -j DNAT \ --to-destination $DB_ADDR # Create a NAT table entry in the postrouting chain, matching # any packets with destination database port, changing the source IP # address of the packet to the NAT VM's primary internal IPv4 address: iptables -t nat -A POSTROUTING \ -p tcp --dport $DB_PORT \ -j SNAT \ --to-source $vm_nic_ip # Save iptables configuration: iptables-save
Proxy VM 現在會開始運作。繼續完成來源連線所需的其餘步驟。
後續步驟
進一步瞭解來源連線方法。請參閱「 來源連線方式總覽」。
如需完整的逐步遷移指南,請參閱「 從 Oracle 遷移至 AlloyDB for PostgreSQL 指南」。