-フェイルオーバーとは、稼働中のシステムで問題が生じてシステムやサーバーが停止してしまった際に、自動的に待機システムに切り替える仕組み
-HA機能ともいわれ、システムの可用性を高めるための冗長化.
Requiredなイベントについて、事前に知る必要がある。
随机应变 ABCD: Always Be Coding and … : хороший
-フェイルオーバーとは、稼働中のシステムで問題が生じてシステムやサーバーが停止してしまった際に、自動的に待機システムに切り替える仕組み
-HA機能ともいわれ、システムの可用性を高めるための冗長化.
Requiredなイベントについて、事前に知る必要がある。
なるほど、ここでサブネットとavailability zoneをchoiceするのね。
メンテナンスウィンドウの設定
なるほど♪
おおおおお、すげー
やけに時間かかるじゃねーか
ステータス バックアップ中 ってどういうことだ??
とりあえずこれ、vagrantから接続できるんだろうか。。。
vagrantからはつながらないようです。
[vagrant@localhost aws]$ mysql -u root -p -h rds-mysql-server.hoge.ap-northeast-1.rds.amazonaws.com
Enter password:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘rds-mysql-server.c7fqvxerfcrm.ap-northeast-1.rds.amazonaws.com’ (110)
>EC2インスタンスのセキュリティグループには、Amazon RDS for MySQLインスタンスのセキュリティグループ[example-rds-mysql-server]に対するMySQL接続許可を追加した[example-server]セキュリティグループを割り当てます。
これか!
インバウンドルール
そのセキュリティグループに関連付けられたインスタンスにアクセスできるトラフィックを規制するルール
[ec2-user@ip-hoge ~]$ mysql -u root -p -h rds-mysql-server.hoge.ap-northeast-1.rds.amazonaws.com
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.7.22-log Source distribution
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>
おおおおおおおおおおおおおおおおおおお、きたきたきたーーーーーーーーーー
セキュリティグループで若干手間取りましたがwww
サブネットグループの次はパラメーターグループをつくります。
パラメーターグループできました。
DBインスタンス
Amazon Aurora, MySQL, MariaDB, PostgreSQL, Oracle, Microsoft SQL Serverがあります。なるほど。
ユースケース 開発/テストを選択する
DBインスタンスのクラス
db.t2.micro – 1 vCPU, 1 GiB RAM
20 GiB
概算月間コスト
21.74 USD
たけーな、なんでLinuxのEC2よりDBエンジンのコストの方が高くなるのかわからん。
まずセキュリティグループを作ります。
まずconsoleのログイントップ
Amazon RDS for MySQLインスタンス(MySQLバージョン5.6.27のMySQLデータベースサーバ)を作成し、Amazon EC2インスタンス(Amazon Linux)からMySQLデータベースへ接続して利用開始する
RDSサービス詳細
https://aws.amazon.com/jp/rds/
対象:Amazon Aurora, PostgreSQL, MySQL, MariaDB, ORACLE, SQL Server
MongoDBなどNo SQLはないのかな。。
まず、EC2からRDS用のセキュリティグループを作ります。
サブネットグループをつくる
abilability zoneを作る
ap-northeast-1a
この ap-northeast-1a ってよく出てくるな。
——–
Amazon EC2 は、世界各地のロケーションでホスティングされています。これらのロケーションは、リージョンとアベイラビリティーゾーンから構成されています。リージョンはそれぞれ、地理的に離れた領域です。1 つのリージョンに複数のそれぞれ独立したロケーションがあり、このロケーションを「アベイラビリティーゾーン」といいます。Amazon EC2 では、お客様がインスタンスなどのリソースとデータを複数のロケーションに配置できます。複数のリージョンにまたがってリソースのレプリケーションを行うには、お客様がそのように指定する必要があります。
リージョンでロケーションが異なるのね。
なるほど、東京と大阪か。
ap-northeast-1
アジアパシフィック (東京)
ap-northeast-2
アジアパシフィック (ソウル)
ap-northeast-3
アジアパシフィック (大阪: ローカル)
サブネットが出来ました。
今度こそ行けるかな?
$ sudo yum install cpan
これでいいですか? [y/N]y
パッケージをダウンロードしています:
(1/2): perl-CPAN-1.9402-144.el6.x86_64.rpm | 247 kB 00:00
(2/2): perl-Digest-SHA-5.47-144.el6.x86_64.rpm | 65 kB 00:00
——————————————————————————–
合計 128 kB/s | 312 kB 00:02
ほう。
cpanのupgrade
# perl -MCPAN -e shell
cpan[1]> o conf prerequisites_policy follow
cpan[2]> o conf commit
cpan[3]> upgrade
upgradeがやたら長いぞ。
なんだこれ、永遠と終わらんぞ。。
git hubからgit cloneします。
git clone https://github.com/PerlDancer/Dancer2.git
ここからどーするか。。
ルーティングのサンプルはいっぱいあるんだが、どこにファイルを置けばいいの?
$ sudo cpan
cpan[1]> upgrade
$ cpan Dancer
Reading ‘/home/vagrant/.cpan/sources/authors/01mailrc.txt.gz’
………………………………………………………………….DONE
Reading ‘/home/vagrant/.cpan/sources/modules/02packages.details.txt.gz’
Database was generated on Tue, 11 Sep 2018 09:17:02 GMT
HTTP::Date not available
………….
New CPAN.pm version (v2.16) available.
[Currently running version is v2.00]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
…………………………………………….Killed
あああああああああ、もうubuntuではできん。。centosでやろう。
なんだこりゃ、どうしろってんだ。。。
—
CPAN(シーパン、Comprehensive Perl Archive Network)とは、Perlのライブラリ・モジュールやその他のPerlで書かれたソフトウェアを集めた巨大なアーカイブで、世界中のサーバにその内容がミラーリングされている。再利用性・汎用性の高いモジュールが登録されており、Perlプログラマができるだけ車輪の再発明をせずに済むための支援環境となっている。登録モジュールの検索システムも提供されているため、Perlプログラマは望む機能を持ったモジュールを容易に入手することができる。
—
vagrant@vagrant-ubuntu-trusty-64:~/perl$ cpan Dancer
Reading ‘/home/vagrant/.cpan/sources/authors/01mailrc.txt.gz’
………………………………………………………………….DONE
Reading ‘/home/vagrant/.cpan/sources/modules/02packages.details.txt.gz’
Database was generated on Tue, 11 Sep 2018 09:17:02 GMT
HTTP::Date not available
Warning: Your system date is 1 days behind this index file!
System time: Mon Sep 10 07:24:39 2018
Timestamp index file: Tue, 11 Sep 2018 09:17:02 GMT
Please fix your system time, problems with the make command expected.
なんだと!
vagrant@vagrant-ubuntu-trusty-64:~/perl$ sudo ntpdate ntp.nict.jp
11 Sep 13:19:42 ntpdate[20614]: step time server 133.243.238.164 offset 107448.537336 sec
vagrant@vagrant-ubuntu-trusty-64:~/perl$ date
Tue Sep 11 13:21:24 UTC 2018
いいね~
vagrant@vagrant-ubuntu-trusty-64:~/perl$ cpan Dancer
Fetching with HTTP::Tiny:
http://ftp.jaist.ac.jp/pub/CPAN/authors/01mailrc.txt.gz
Reading ‘/home/vagrant/.cpan/sources/authors/01mailrc.txt.gz’
………………………………………………………………….DONE
Fetching with HTTP::Tiny:
http://ftp.jaist.ac.jp/pub/CPAN/modules/02packages.details.txt.gz
Reading ‘/home/vagrant/.cpan/sources/modules/02packages.details.txt.gz’
Database was generated on Tue, 11 Sep 2018 09:17:02 GMT
HTTP::Date not available
………….
New CPAN.pm version (v2.16) available.
[Currently running version is v2.00]
You might want to try
install CPAN
reload cpan
to both upgrade CPAN.pm and run the new version without leaving
the current session.
……………………………………………Killed
open(my $in, "<", "test.dat") or die("could not open file."); while(<$in>){ $_ =~ s/abc/ABC/; print $_; } close($in);
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
ABC
def
ghi
123
456
while(<$in>){ $_ =~ s/abc/ABC/; if($_ =~ /[a-z]/){ print $_; } }
なるほど、面白い
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
def
ghi
サブルーチンをつくる。
sub max { my $max = $_[0]; if ($_[1] > $max){ $max = $_[1]; } return $max; } print max(2, 8);
サブルーチンという名称ですが、要するに関数ですな。
sub max { my $max = shift(@_); foreach(@_){ $max = $_ if $_ > $max; } return $max; } print max(2, 8, 100, 23, 38);
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
100
なんかかなり駆け足できましたが、基礎はこれ位にしてdancerに入りましょう。
fileをopenします。
open(my $in, "<", "test.dat") or die("could not open file."); while(<$in>){ print $_; } close($in);
vagrant@vagrant-ubuntu-trusty-64:~/app$ cat test.dat
abc
def
ghi
123
456
789vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
abc
def
ghi
123
456
789
open(my $in, "<", "test.dat") or die("could not open file."); open(my $out, ">", "test.out") or die("could not open file."); while(<$in>){ print $out $_; } close($in); close($out);
vagrant@vagrant-ubuntu-trusty-64:~/app$ perl hello.pl
vagrant@vagrant-ubuntu-trusty-64:~/app$ cat test.out
abc
def
ghi
123
456
789
書き込みですな。