LoginSignup
0
0

More than 3 years have passed since last update.

【GCP】ゾーン間のVMインスタンスを接続

Last updated at Posted at 2020-02-18

VM作成

GCP Consoleで

Name: my-vm-1
Region: us-central1
Zone: us-central1-a
Boot disk: Debian GNU/Linux 9 (stretch)
Access scopes: Allow default access
Firewall: Allow HTTP traffic(受信HTTPトラフィックを許可します)

gcloud command で

リージョン指定
gcloud compute zones list | grep us-central1
ゾーン設定
gcloud config set compute/zone us-central1-b
VM作成
gcloud compute instances create "my-vm-2" \
--machine-type "n1-standard-1" \
--image-project "debian-cloud" \
--image "debian-9-stretch-v20190213" \
--subnet "default"

結果
image.png
my-vm-2
image.png

Connect between VMインスタンス

image.png
ssh クリック
my-vm-1へ接続する為、次のコマンドを実行
ssh my-vm-1
image.png
my-vm-1インスタンスで Nguixウェブサーバーインストール
sudo apt-get install nginx-light -y
image.png
sudo nanoでindex.nginx-debian.htmlファイルを編集
sudo nano /var/www/html/index.nginx-debian.html
image.png
保存して終了
Ctrl+O→Enter→Ctrl+X
my-vm-1提供するウェブサーバーを確認するコマンド
curl http://localhost/
image.png
my-vm-1コマンドプロンプトを終了、次のコマンドを実行
exit
my-vm-2コマンドプロンプトへ戻る
image.png
my-vm-2コマンドプロンプトでmy-vm-1のウェブサーバーに到達できる確認コマンド
curl http://my-vm-1/
image.png
http://my-vm-1/
image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0