Top Banner
Cloud Onr Cloud OnAir Cloud OnAir 2018 2 15 放送 e-Learning 補助資料 クラウド移行後の最適化方法を伝授。 でも最適化ってなんですか?
31

[Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Mar 16, 2018

Download

Technology

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud Onr

Cloud OnAir

Cloud OnAir

2018 年 2 月 15 日 放送 e-Learning 補助資料

クラウド移行後の最適化方法を伝授。でも最適化ってなんですか?

Page 2: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

はじめに

2

クラウドの最適化(運用)についてご紹介します。

運用

マネージドサービス

オートスケール

Page 3: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 0. 既存システムの構成

3

Web サイト(ブログ)

管理者

Content Server / DatabaseCompute Engine

Page 4: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 1. マネージドサービスへの移行

4

Web サイト(ブログ)

管理者

Content ServerCompute Engine

DatabaseCloud SQL

Page 5: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 1. マネージドサービスへの移行

5

管理者

Content ServerCompute Engine

DatabaseCloud SQL

1. データベースのバックアップを行う

2. データベースの切り替えを行う

3. ブログにアクセスする

Page 6: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 2. オートスケーリング導入

6

Webサイト(ブログ)

管理者

DatabaseCloud SQL

Content ServerCompute Engine

Autoscaling

Proxy for DatabaseCompute Engine

Page 7: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 2. オートスケーリング導入

7

管理者

DatabaseCloud SQL

Content ServerCompute Engine

Autoscaling

Proxy for DatabaseCompute Engine

1. カスタムイメージを作成

2. インスタンステンプレートを作成

3. インスタンスグループを作成

4. 負荷分散を作成

5. 負荷を掛けてみる

Page 8: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Step 3. DB のスケール対策

8

Web サイト(ブログ)

管理者

Content ServerCompute Engine

Autoscaling

Database(Master)Cloud SQL

Content Server(Master)Compute Engine

Proxy for DatabaseCompute Engine

Autoscaling

Database(Read)Cloud SQL

Database(Read)Cloud SQL

Page 9: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Cloud OnAir

まとめ

Page 10: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

まとめ

10

クラウドの最適化(運用)についてご紹介しました。

運用

マネージドサービス

オートスケールCompute

Engine

Cloud SQL

Page 11: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Cloud OnAir

本日の手順

Page 12: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その1

12

● GCE インスタンスを作成

○ ブートディスクを CentOS 7 に変更する

Page 13: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その2

13

アプリケーションの準備

$ sudo yum install php php-mysql mariadb-server mariadb httpd -y$ sudo systemctl start httpd.service$ sudo systemctl enable httpd.service$ sudo systemctl start mariadb$ sudo systemctl enable mariadb.service$ curl -O https://wordpress.org/wordpress-4.9.2.tar.gz$ tar zxvf wordpress-4.9.2.tar.gz$ sudo cp -R wordpress/* /var/www/html/$ sudo chown -R apache:apache /var/www/html

Page 14: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その3

14

セキュリティ設定変更

$ sudo setenforce 0/etc/selinux/config をエディタで開き、該当箇所を修正する

SELINUX=disabled

データベース作成

$ mysql -u root> CREATE DATABASE wordpress;> GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@'%' IDENTIFIED BY 'Hy4X4vsCvcFXgIqa';> GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'Hy4X4vsCvcFXgIqa';> FLUSH PRIVILEGES;> exit;

Page 15: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その4

15

ブラウザ(http)で GCE のインスタンスにアクセスする

Page 16: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その5

16

Page 17: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その6

17

Page 18: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その7

18

Page 19: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Wordpress サーバーの作成手順 その8

19

Page 20: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. CloudSQL の初期設定

20

1. Cloud SQLでインスタンスを作成

MySQLを選択

Page 21: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. CloudSQL の初期設定

21

Page 22: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. CloudSQL の初期設定

22

Page 23: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. CloudSQL の初期設定

23

ネットワークの追加を押した後、wordpressサーバのIPを登録する。(例: xxx.xxx.xxx.xxx/32)

Page 24: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. CloudSQL の初期設定

24

1. Wordpress サーバに SSH 接続する

2. Cloud SQL のインスタンスに接続する

3. Cloud SQL で作成したインスタンス上にデータベースを作成 (Appendix. Wordpress サーバーの作成手順 その2と同じ

コマンド)

$ mysql -u root -p<パスワード> -h <IPアドレス>

Page 25: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 1. データベースバックアップ・マイグレーション

25

1. データベースのバックアップコマンド

2. データベースのマイグレーションコマンド

$ mysqldump -u wordpressuser -pHy4X4vsCvcFXgIqa -hlocalhost wordpress > wordpress-bkup.dump

$ mysql -uwordpressuser -pHy4X4vsCvcFXgIqa -h 35.187.220.179 wordpress < wordpress-bkup.dump

Page 26: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Step 2.の手順

26

データベースのスケール対応

1. Step1.で作成したインスタンスからリードレプリカを作成

2. リードレプリカに対して、FQDN を設定

3. Wordpress の接続先のデータベースをリードレプリカの FQDN に設定

オートスケーリング対応

4. GCE インスタンスからインスタンステンプレートを作成

5. インスタンステンプレートからインスタンスグループを作成

6. ロードバランサーを作成

Page 27: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Mysql-proxy の作成手順 その1

27

1. Wordpressサーバーの作成手順 その1 通りインスタンスを作成する

2. 作ったサーバに ssh 接続する

3. 以下コマンドで SELINUX を無効化する

4. /etc/selinux/config ファイルをエディタで開き、該当箇所を修正する

SELINUX=disabled

SELINUX=xxx となっている設定を上記設定に変更する

$ sudo setenforce 0 # temp

Page 28: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Mysql-proxy の作成手順 その2

28

1. 以下コマンドで haproxy (プロキシ用ソフトウェア) をインストールする

2. /etc/haproxy/haproxy.cfg ファイルをエディタで開き、内容を全て消し、以下内

容を記述する。

$ sudo yum install haproxy

global log 127.0.0.1 local0 notice user haproxy group haproxy

defaults log global retries 2 timeout connect 3000 timeout server 5000 timeout client 5000

listen mysql-cluster bind 0.0.0.0:3306 mode tcp balance roundrobin server mysql-1 <CloudSQLのIP>:3306 check

<CloudSQLのIP> は実際の値に置き換えて記述する

Page 29: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Mysql-proxyの作成手順 その3

29

1. 以下コマンドで haproxy の起動・有効化(インスタンス再起動時に

自動的に起動する)を行う

$ sudo systemctl start haproxy$ sudo systemctl enable haproxy

Page 30: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. apache-benchの作成手順 その1

30

1. Wordpress サーバーの作成手順 その1 通りインスタンスを作成する

2. 作ったサーバに ssh 接続する

3. 以下コマンドで SELINUX を無効化する

4. /etc/selinux/config ファイルをエディタで開き、該当箇所を修正する

SELINUX=disabled

SELINUX=xxx となっている設定を上記設定に変更する

$ sudo setenforce 0 # temp

Page 31: [Cloud OnAir] クラウド移行後の最適化方法を伝授。でも最適化ってなんですか? (e Learning) 2018年2月15日 放送

Cloud OnAir

Appendix. Apache-bench の作成手順 その2

31

1. 以下コマンドでhttpd (webサーバ、web操作ツール) をインストールする

$ sudo yum install httpd