Private IP-Verbindung der Quelle mit einem Reverse-Proxy verwenden

Auf dieser Seite wird beschrieben, wie Sie einen Reverse-Proxy auf einer Compute Engine-VM (virtuelle Maschine) einrichten, um eine private Quellverbindung für heterogene Oracle-Migrationen zu ermöglichen.

Eine Reverse-Proxy-VM ist erforderlich, wenn du eine private IP-Verbindung mit einer Quelle verwenden möchtest, die sich in einem anderen Virtual Private Cloud-Netzwerk befindet als dem, in dem du die Konfiguration für die private Verbindung erstellst.

Reverse-Proxy einrichten

So erstellen Sie eine Compute Engine-VM zum Hosten des Proxys:

  1. Linux-VM-Instanz in der Compute Engine erstellen
  2. Nachdem Sie eine Verbindung zum Computer hergestellt haben, erstellen Sie das erforderliche iptables-Routing, um den Traffic weiterzuleiten. Sie können das folgende Script verwenden.

    Bevor Sie einen der unten aufgeführten Befehle verwenden, nehmen Sie die folgenden Ersetzungen vor:

    • SOURCE_PRIVATE_IP durch die private IP-Adresse Ihrer Quellinstanz.
    • PORT durch die Portnummer, auf die Ihre Oracle-Quell-Instanz Verbindungen überwacht.
    #! /bin/bash
    
    export DB_ADDR=SOURCE_PRIVATE_IP
    export DB_PORT=DATABASE_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

    Ihre Proxy-VM ist jetzt in Betrieb. Fahren Sie mit den restlichen Schritten fort, die für die Quellverbindung erforderlich sind.

Nächste Schritte