35/120
VPC Peering
VPCピアとは?
2つの仮想マシン間のネットワーク接続により、2つの仮想マシン間でトラフィックをルーティング
サポートされていないPeering
1.IPv 4 CIDRブロックが同じ場合
2.複数の仮想PCはそれぞれペアリングする必要がある
BとCは通信するためにB Cに接続する必要がある.Aで対応できません
3.ゲートウェイまたはプライベート接続でリーフ間をルーティングできない
連続VPC Peering


使用可能な領域は1つだけです.次に実習するデータベースには2つの使用可能な領域が必要なので、先に作成します.

privateサブネットに接続するNATゲートウェイ設定

異なるブロック



ペアリングするローカル仮想マシンを使用してカリフォルニア州の仮想マシンを設定し、接続要求をオレゴンにある別の仮想マシンに送信します.



Aの共通ルーティングテーブルは、自分のIPをローカルに送信し、他のすべてのIPをインターネットゲートウェイに送信するように設定されている.
20.0.0.0/16(BのVPC)ピア接続

ピア接続を選択すると、接続されているピア接続が一覧表示されます.
変更を保存


デフォルトの仮想マシンではなく、作成した仮想マシンを選択します.
外部接続が必要なのでパブリックサブネットに設定(VPC名は私のように長くならないように…サブネットが遮断されているので気になります)
パブリックサブネットまたはパブリックIP

sshは自分のIP接続に設定する
接続検証がWeb上で行われるため、HTTPポートはバージョンBのVPC 20.0.0.0/16

VPCBに設定されたパブリックサブネット
ssh -i A인스턴스 키 ec2-user@A의 인스턴스 퍼블릭 IP
ssh -i B인스턴스 키 ec2-user@B의 인스턴스 퍼블릭 IP
sudo yum -y install httpd
$ sudo systemctl start httpd
$ sudo systmectl enable httpd
$ echo "TEST" > index.html
$ sudo cp index.html /var/www/html
$ curl B인스턴스의 private IP
TEST
Amazon RDS
バックアップ、ソフトウェアパッチ、監視、サイズ変更、レプリケーションなど、時間のかかるデータベース管理タスクの自動管理
EC 2インスタンスを使用する場合、バックアップや更新などの部分はユーザーが手動で行う必要がありますが、RDSを使用すると自動的に完了する点が便利です.
AWS管理
拡大・縮小

サーバを拡張する方法:
アップグレード:複数のサーバを追加することでシステムを拡張
「ロード・バランシング」が必要
すべてのサーバが同じデータを持つ必要があるため、データの変化が少ない「Webサーバ」に適しています.
拡張:高性能部品、サーバーへの交換方法
1台のサーバですべてのデータを処理し、頻繁にデータを更新する「データベース・サーバ」に最適
Amazon Aurora
新しいテクノロジー
public-webserver、private-dbserverの構成
データのセキュリティを確保するために、データベース・サーバはprivateで構成され、外部ユーザーのアクセスを防止する必要があります.
EC 2インスタンスのみを構成し、RDSは不要
上記で作成したVPCAで作成したインスタンスをpublic-webserverとして使用して、新しいインスタンスを作成し、VPCAのプライベートサブネットに接続します.


鍵ファイル手帳
ssh -i 키파일 ec2-user@웹서버의 퍼블릭 IP
[webserver ~]$ ls -al
total 16
drwx------ 3 ec2-user ec2-user 95 Mar 31 10:50 .
drwxr-xr-x 3 root root 22 Mar 31 10:39 ..
-rw------- 1 ec2-user ec2-user 16 Mar 31 10:50 .bash_history
-rw-r--r-- 1 ec2-user ec2-user 18 Jul 15 2020 .bash_logout
-rw-r--r-- 1 ec2-user ec2-user 193 Jul 15 2020 .bash_profile
-rw-r--r-- 1 ec2-user ec2-user 231 Jul 15 2020 .bashrc
drwx------ 2 ec2-user ec2-user 29 Mar 31 10:39 .ssh
[webserver ~]$ vim .ssh/key
[webserver ~]$ ls -l .ssh/key
-rw-rw-r-- 1 ec2-user ec2-user 1675 Mar 31 11:35 .ssh/key
[webserver ~]$ chmod 400 .ssh/key
[webserver ~]$ ssh -i .ssh/key ec2-user@db서버의 프라이빗 IP
$ sudo yum -y install mariadb-server mariadb
$ sudo systemctl start mariadb
$ sudo systemctl enable mariadb
$ mysql_secure_installation
mysql sercureインストール設定を参照MariaDB [mysql]> grant all privileges on *.* to root@'10.0.%' identified by '1';
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
MariaDB [mysql]> exit
Bye
dbserver $ exit
logout
Connection to dbserver closed.
webserver $ mysql -u root -p -h 데이터베이스의 프라이빗 IP
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
RDSによる構成

手作りなら



バージョン




$ mysql -u admin -p -h RDS 엔드포인트
接続されていませんセキュリティグループのIPは自動的に自分のIPに設定されます

$ mysql -u admin -p -h RDS 엔드포인트
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 16
Server version: 8.0.28 Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
Webから実際のデータベースに接続する
ネストされたセキュリティ・ルール
Webサーバへの接続のみを許可するデータベース接続



Webアプリケーションを作成するため、バージョンの調整が必要です





公共の場所で

$ sudo yum update -y
$ sudo yum install -y httpd24 php56 php56-mysqlnd
$ sudo service httpd start
$ sudo chkconfig httpd on
$ sudo groupadd www
$ sudo usermod -a -G www ec2-user
$ groups
ec2-user wheel www
$ sudo chown -R root:www /var/www
$ sudo chmod 2775 /var/www
$ find /var/www -type d -exec sudo chmod 2775 {} \;
$ find /var/www -type f -exec sudo chmod 0664 {} \;
inc,php例 $ cd /var/www
$ mkdir inc
$ cd inc
$ sudo vim dbinfo.inc
<?php
define('DB_SERVER', 'rds 엔드포인트');
define('DB_USERNAME', 'tutorial_user');
define('DB_PASSWORD', '비밀번호');
define('DB_DATABASE', 'sample');
?>
$ cd /var/www/html
$ sudo vim index.php
# 다운받은 파일 붙여넣고 저장

Reference
この問題について(35/120), 我々は、より多くの情報をここで見つけました https://velog.io/@numerok/35120テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol