์ด ํ์ด์ง์์๋ ์ด๊ธฐ์ข Oracle ๋ง์ด๊ทธ๋ ์ด์ ์ ์์ค ๋น๊ณต๊ฐ ์ฐ๊ฒฐ์ ์ฉ์ดํ๊ฒ ํ๊ธฐ ์ํด Compute Engine ๊ฐ์ ๋จธ์ (VM)์ ๋ฆฌ๋ฒ์ค ํ๋ก์๋ฅผ ์ค์ ํ๋ ๋ฐฉ๋ฒ์ ์ค๋ช ํฉ๋๋ค.
๋น๊ณต๊ฐ ์ฐ๊ฒฐ ๊ตฌ์ฑ์ ๋ง๋๋ Virtual Private Cloud ๋คํธ์ํฌ์ ๋ค๋ฅธ Virtual Private Cloud ๋คํธ์ํฌ์ ์๋ ์์ค์ ํจ๊ป ๋น๊ณต๊ฐ IP ์ฐ๊ฒฐ์ ์ฌ์ฉํ๋ ค๋ฉด ๋ฆฌ๋ฒ์ค ํ๋ก์ VM์ด ํ์ํฉ๋๋ค.
๋ฆฌ๋ฒ์ค ํ๋ก์ ์ค์
ํ๋ก์๋ฅผ ํธ์คํ ํ Compute Engine VM์ ๋ง๋ค๋ ค๋ฉด ๋ค์ ๋จ๊ณ๋ฅผ ๋ฐ๋ฅด์ธ์.
- 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
์ด์ ํ๋ก์ VM์ด ์คํ๋ฉ๋๋ค. ์์ค ์ฐ๊ฒฐ์ ํ์ํ ๋๋จธ์ง ๋จ๊ณ๋ฅผ ๊ณ์ ์งํํฉ๋๋ค.
๋ค์ ๋จ๊ณ
์์ค ์ฐ๊ฒฐ ๋ฐฉ๋ฒ์ ๋ํด ์์ธํ ์์๋ณด์ธ์. ์์ค ์ฐ๊ฒฐ ๋ฐฉ๋ฒ ๊ฐ์๋ฅผ ์ฐธ๊ณ ํ์ธ์.
๋จ๊ณ๋ณ ๋ง์ด๊ทธ๋ ์ด์ ์๋ด๋ฅผ ํ์ธํ๋ ค๋ฉด Oracle์์ PostgreSQL์ฉ Cloud SQL๋ก ๋ง์ด๊ทธ๋ ์ด์ ๊ฐ์ด๋๋ฅผ ์ฐธ๊ณ ํ์ธ์.