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

Auf dieser Seite wird erläutert, wie Sie einen Reverse-Proxy auf einer Compute Engine-VM (Virtual Machine) einrichten, um die private Quellverbindung für heterogene Oracle-Migrationen zu erleichtern.

Eine Reverse-Proxy-VM ist erforderlich, wenn Sie eine private IP-Verbindung mit einer Quelle verwenden möchten, die sich in einem anderen VPC-Netzwerk (Virtual Private Cloud) befindet als dem, in dem Sie eine private Verbindungskonfiguration für VPC-Peering erstellen.

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 zur Maschine hergestellt haben, erstellen Sie das erforderliche iptables Routing, um den Traffic weiterzuleiten. Sie können das folgende Skript verwenden.

    Ersetzen Sie folgende Werte, bevor sie einen der Befehlsdaten verwenden:

    • SOURCE_PRIVATE_IP durch die private IP-Adresse Ihrer Quellinstanz.
    • PORT durch die Portnummer, an der Ihre Oracle-Quellinstanz auf Verbindungen wartet.
    #! /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

    Ihre Proxy-VM wird jetzt ausgeführt. Fahren Sie mit den restlichen Schritten fort, die für die Quellverbindung erforderlich sind.

Nächste Schritte