{Aurora}カスタムエンドポイントの使用

カスタムエンドポイントの作成

aws rds create-db-cluster-endpoint \
--db-cluster-identifier mycluster01 \
--db-cluster-endpoint-identifier myep01 \
--endpoint-type ANY \
--static-members mydb01 mydb02 \
--tags Key=Name,Value=myep01

カスタムエンドポイントの表示

aws rds describe-db-cluster-endpoints

aws rds describe-db-cluster-endpoints | jq -c '.DBClusterEndpoints[] | [.Endpoint, .EndpointType]'

 

カスタムエンドポイントの削除

aws rds delete-db-cluster-endpoint \
--db-cluster-endpoint-identifier myep01

 

 

AWS CLI(RDS)


サブネットグループの作成
aws rds create-db-subnet-group \
--db-subnet-group-name mysubnetgroup \
--db-subnet-group-description mysubnetgroup \
--subnet-ids '["subnet-12345678901234567","subnet-12345678901234567"]'

 

サブネットグループの一覧
aws rds describe-db-subnet-groups
aws rds describe-db-subnet-groups | jq -r '.DBSubnetGroups.DBSubnetGroupName '

 

サブネットグループの削除
aws rds delete-db-subnet-group \
--db-subnet-group-name mydbsubnetgroup


パラメータグループの作成
aws rds create-db-parameter-group \
--db-parameter-group-name mydbparametergroup \
--db-parameter-group-family aurora-postgresql11 \
--description mydbparametergroup

 


パラメータグループの一覧
aws rds describe-db-parameter-groups
aws rds describe-db-parameter-groups | jq -r '.DBParameterGroups.DBParameterGroupName'


パラメータグループの削除
aws rds delete-db-parameter-group \
--db-parameter-group-name mydbparametergroup


パラメータの一覧
aws rds describe-db-parameters \
--db-parameter-group-name mydbparametergroup

aws rds describe-db-parameters \
--db-parameter-group-name mydbparametergroup | jq -r '.Parameters.ParameterName'


デフォルトパラメータの一覧
aws rds describe-engine-default-parameters \
--db-parameter-group-family aurora-postgresql11

aws rds describe-engine-default-parameters \
--db-parameter-group-family aurora-postgresql11 | jq -r '.EngineDefaults.Parameters.ParameterName'

 

Auroraクラスタパラメータグループの作成
aws rds create-db-cluster-parameter-group \
--db-cluster-parameter-group-name mydbclusterparametergroup \
--db-parameter-group-family aurora-postgresql11 \
--description mydbclusterparametergroup

 

Auroraクラスタパラメータグループの一覧
aws rds describe-db-cluster-parameter-groups
aws rds describe-db-cluster-parameter-groups | jq -r '.DBClusterParameterGroups.DBClusterParameterGroupName'

 

Auroraクラスタパラメータグループの削除
aws rds delete-db-cluster-parameter-group \
--db-cluster-parameter-group-name mydbclusterparametergroup

 

Auroraクラスタパラメータの一覧
aws rds describe-db-cluster-parameters \
--db-cluster-parameter-group-name mydbclusterparametergroup

aws rds describe-db-cluster-parameters \
--db-cluster-parameter-group-name mydbclusterparametergroup | jq -r '.Parameters.ParameterName'

クラスタレベル+インスタンスレベルの全パラメータが表示される

デフォルトAuroraクラスタパラメータの一覧

aws rds describe-engine-default-cluster-parameters \
--db-parameter-group-family aurora-postgresql11


aws rds describe-engine-default-cluster-parameters \
--db-parameter-group-family aurora-postgresql11 | jq -r '.EngineDefaults.Parameters.ParameterName'

クラスタレベルのパラメータのみ表示される

 

オプショングループの作成
aws rds create-option-group \
--option-group-name myoptiongroup \
--engine-name mysql \
--major-engine-version 5.6 \
--option-group-description myoptiongroup

 

オプショングループの一覧
aws rds describe-option-groups
aws rds describe-option-groups | jq -r '.OptionGroupsList.OptionGroupName'


オプショングループの削除
aws rds delete-option-group \
--option-group-name myoptiongroup



Auroraクラスタの作成

aws rds create-db-cluster \
--availability-zones ap-northeast-1a \
--backup-retention-period 1 \
--database-name mydb01 \
--db-cluster-identifier mycluster01 \
--db-cluster-parameter-group-name mydbclusterparametergroup \
--vpc-security-group-ids sg-12345678901234567 \
--db-subnet-group-name mysubnetgroup \
--engine aurora \
--engine-version 5.6.10a \
--port 3306 \
--master-username master \
--master-user-password password \
--preferred-backup-window 04:00-04:30 \
--preferred-maintenance-window Wed:03:00-Wed:03:30 \
--tags Key=Name,Value=mycluster01 \
--storage-encrypted \
--no-enable-iam-database-authentication \
--backtrack-window 0 \
--engine-mode provisioned \
--no-deletion-protection \
--copy-tags-to-snapshot


aws rds create-db-instance \
--db-instance-identifier mydb01 \
--db-instance-class db.t2.small \
--engine aurora \
--availability-zone ap-northeast-1a \
--db-subnet-group-name mysubnetgroup \
--preferred-maintenance-window Wed:03:00-Wed:03:30 \
--db-parameter-group-name mydbparametergroup \
--no-auto-minor-version-upgrade \
--option-group-name myoptiongroup \
--no-publicly-accessible \
--tags Key=Name,Value=mydb01 \
--db-cluster-identifier mycluster01 \
--promotion-tier 1 \
--no-enable-performance-insights


aws rds create-db-instance \
--db-instance-identifier mydb02 \
--db-instance-class db.t2.small \
--engine aurora \
--availability-zone ap-northeast-1c \
--db-subnet-group-name mysubnetgroup \
--preferred-maintenance-window Wed:03:00-Wed:03:30 \
--db-parameter-group-name mydbparametergroup \
--no-auto-minor-version-upgrade \
--option-group-name myoptiongroup \
--no-publicly-accessible \
--tags Key=Name,Value=mydb02 \
--db-cluster-identifier mycluster01 \
--promotion-tier 1 \
--no-enable-performance-insights

 

 

Auroraクラスタの一覧
aws rds describe-db-clusters
aws rds describe-db-instances


aws rds describe-db-clusters | jq -c '.DBClusters | [.DBClusterIdentifier , .Status]'
aws rds describe-db-instances | jq -c '.DBInstances
| [ .DBInstanceIdentifier , .DBInstanceStatus ] '

 

 

Auroraクラスタの削除
aws rds delete-db-instance \
--db-instance-identifier mydb02 \
--skip-final-snapshot \
--delete-automated-backups

aws rds delete-db-instance \
--db-instance-identifier mydb01 \
--skip-final-snapshot \
--delete-automated-backups

aws rds delete-db-cluster \
--db-cluster-identifier mycluster01 \
--skip-final-snapshot


※削除するためには起動している必要がある

Auroraクラスタの起動
aws rds start-db-cluster \
--db-cluster-identifier mycluster01


Auroraクラスタの停止
aws rds stop-db-cluster \
--db-cluster-identifier mycluster01

 

 

 

Auroraクラスタのフェイルオーバ
aws rds failover-db-cluster \
--db-cluster-identifier mycluster01 \
--target-db-instance-identifier mydb02


Auroraクラスタスナップショットの作成
aws rds create-db-cluster-snapshot \
--db-cluster-snapshot-identifier snap01 \
--db-cluster-identifier mycluster01 \
--tags Key=Name,Value=snap01

 


Auroraクラスタスナップショットの一覧
aws rds describe-db-cluster-snapshots
aws rds describe-db-cluster-snapshots | jq -c '.DBClusterSnapshots | [ .DBClusterSnapshotIdentifier , .DBClusterIdentifier ] '

 


Auroraクラスタスナップショットの削除
aws rds delete-db-cluster-snapshot \
--db-cluster-snapshot-identifier snap01

 

 

RDSインスタンスの作成

--MySQL、シングルAZ
aws rds create-db-instance \
--db-name test \
--db-instance-identifier mydb01 \
--allocated-storage 20 \
--db-instance-class db.t3.micro \
--engine mysql \
--master-username master \
--master-user-password password \
--vpc-security-group-ids sg-12345678901234567 \
--availability-zone ap-northeast-1a \
--db-subnet-group-name mysubnetgroup \
--preferred-maintenance-window Wed:03:00-Wed:03:30 \
--db-parameter-group-name mydbparametergroup \
--backup-retention-period 1 \
--preferred-backup-window 04:00-04:30 \
--port 3306 \
--no-multi-az \
--engine-version 5.6.48 \
--no-auto-minor-version-upgrade \
--option-group-name myoptiongroup \
--no-publicly-accessible \
--tags Key=Name,Value=mydb01 \
--storage-type gp2 \
--storage-encrypted \
--copy-tags-to-snapshot \
--no-enable-iam-database-authentication \
--no-enable-performance-insights \
--no-deletion-protection \
--max-allocated-storage 40


--MySQL、マルチAZ
aws rds create-db-instance \
--db-name test \
--db-instance-identifier mydb01 \
--allocated-storage 20 \
--db-instance-class db.t3.micro \
--engine mysql \
--master-username master \
--master-user-password password \
--vpc-security-group-ids sg-12345678901234567 \
--db-subnet-group-name mysubnetgroup \
--preferred-maintenance-window Wed:03:00-Wed:03:30 \
--db-parameter-group-name mydbparametergroup \
--backup-retention-period 1 \
--preferred-backup-window 04:00-04:30 \
--port 3306 \
--multi-az \
--engine-version 5.6.48 \
--no-auto-minor-version-upgrade \
--option-group-name myoptiongroup \
--no-publicly-accessible \
--tags Key=Name,Value=mydb01 \
--storage-type gp2 \
--storage-encrypted \
--copy-tags-to-snapshot \
--no-enable-iam-database-authentication \
--no-enable-performance-insights \
--no-deletion-protection \
--max-allocated-storage 40

 


RDSインスタンスの一覧

aws rds describe-db-instances
aws rds describe-db-instances | jq -c '.DBInstances | [ .DBInstanceIdentifier , .DBInstanceStatus ] '


RDSインスタンスの削除
aws rds delete-db-instance \
--db-instance-identifier mydb01 \
--skip-final-snapshot \
--delete-automated-backups

 


RDSインスタンスの起動
aws rds start-db-instance \
--db-instance-identifier mydb01


RDSインスタンスの停止
aws rds stop-db-instance \
--db-instance-identifier mydb01

 

RDSインスタンスの再起動

aws rds reboot-db-instance \
--db-instance-identifier mydb01 \
--no-force-failover

aws rds reboot-db-instance \
--db-instance-identifier mydb01 \
--force-failover

 

 

RDSインスタンススナップショットの作成
aws rds create-db-snapshot \
--db-snapshot-identifier snap01 \
--db-instance-identifier mydb01 \
--tags Key=Name,Value=snap01

 


RDSインスタンススナップショットの一覧
aws rds describe-db-snapshots
aws rds describe-db-snapshots | jq -c '.DBSnapshots | [ .DBSnapshotIdentifier , .DBInstanceIdentifier ] '

 


RDSインスタンススナップショットの削除
aws rds delete-db-snapshot \
--db-snapshot-identifier snap01

 

DBエンジンの一覧
aws rds describe-db-engine-versions

aws rds describe-db-engine-versions \
--engine mysql

aws rds describe-db-engine-versions \
--engine mysql \
| jq -c '.DBEngineVersions | [ .Engine, .EngineVersion ]'


DBログファイルの一覧
aws rds describe-db-log-files \
--db-instance-identifier mydb01


aws rds describe-db-log-files \
--db-instance-identifier mydb01 \
| jq -c '.DescribeDBLogFiles | [.LogFileName, .LastWritten]'

 

イベントの一覧
aws rds describe-events \
--source-identifier mydb01 \
--source-type db-instance

aws rds describe-events \
--source-identifier mydb01 \
--source-type db-instance \
| jq -c '.Events | [ .Date, .Message ]'

 

 

AWS CLI(Cost Explorer)

https://qiita.com/shinsaka/items/c368c403935549b4401b
https://dev.classmethod.jp/articles/road-to-jq-master-apprentice/

 

※1リクエスト当たり0.01ドル課金される

コスト合計
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost"

aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
| jq -c '.ResultsByTime.Total.BlendedCost.Amount '

 


サービス別コスト
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE

 

aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE \
| jq -c '.ResultsByTime.Groups | { (.Keys) : .Metrics.BlendedCost.Amount} '


5ドル以上のサービス
aws ce get-cost-and-usage \
--time-period Start=2020-08-01,End=2020-09-01 \
--granularity MONTHLY \
--metrics "BlendedCost" \
--group-by Type=DIMENSION,Key=SERVICE \
| jq -c '.ResultsByTime.Groups | { (.Keys[]) : .Metrics.BlendedCost.Amount} ' \
| sed -e 's/{//g' -e 's/"//g' -e 's/}//g' \
| awk -F: '$2>=5{print $0}'

 

アセンブラでHello World

(20)
http://hironemu.hatenablog.com/entry/20090210/1234279094

apt install nasm
nasm --version

vim hello.asm

section .text
global _start

msg db 'Hello world!', 0x0A
msglen equ $ - msg

_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80

nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello

(10)

apt install nasm
nasm --version

vim hello.asm

section .text
global _start

msg db 'Hello world!', 0x0A
msglen equ $ - msg

_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80

nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello

 

(8)

dnf install https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/linux/nasm-2.15.05-0.fc31.x86_64.rpm


nasm --version

vim hello.asm

section .text
global _start

msg db 'Hello world!', 0x0A
msglen equ $ - msg

_start:
mov ecx, msg
mov edx, msglen
mov eax, 4
mov ebx, 1
int 0x80
mov eax, 1
mov ebx, 0
int 0x80

nasm -f elf64 hello.asm
ld -s -o hello hello.o
./hello

 

(2019)
https://qiita.com/0gajun/items/e772e1223f6e596eb362
https://stackoverflow.com/questions/1023593/how-to-write-hello-world-in-assembler-under-windows/1029093#1029093


前提:
「Build Tools for Visual Studio 2019」 インストール済み
Visual Studio Community 2019」 インストール済み (ワークロード指定なしでよい)

https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/win64/

cd C:\Users\Administrator\Downloads\nasm-2.15.05-win64\nasm-2.15.05

nasm --version

notepad hello.asm


global _main

extern _GetStdHandle@4
extern _WriteFile@20
extern _ExitProcess@4


section .text

_main:
; DWORD bytes;
; <- prepare local variable
mov ebp, esp
sub esp, 4

; hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)
; (STD_OUTPUT_HANDLE = -11)
push -11
call _GetStdHandle@4
mov ebx, eax

; WriteFile( hStdOut, msg, length(msg), &size, 0)
push 0
lea eax, [ebp - 4]
push eax
push (message_end - message)
push message
push ebx
call _WriteFile@20

; ExitProcess(0)
push 0
call _ExitProcess@4

; never here
hlt

message:
db 'Hello world!', 10
message_end:


nasm -fwin32 hello.asm

"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Tools\MSVC\14.27.29110\bin\Hostx86\x86\link.exe" hello.obj kernel32.lib /ENTRY:main /SUBSYSTEM:CONSOLE

hello

※kernel32.libは下記からコピー
C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\um\x86

CでHello World

(20)
http://yamada.daiji.ro/blog/?p=1044

apt install build-essential

gcc --version

vim hello.c

#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}

gcc -o hello hello.c
./hello

--
vim web.c

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main() {
int sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
int sock;
int yes = 1;

char buf[2048];
char inbuf[2048];

sock0 = socket(AF_INET, SOCK_STREAM, 0);

addr.sin_family = AF_INET;
addr.sin_port = htons(8080);
addr.sin_addr.s_addr = INADDR_ANY;
setsockopt(sock0, SOL_SOCKET, SO_REUSEADDR, (const char *) &yes, sizeof(yes));
bind(sock0, (struct sockaddr *) &addr, sizeof(addr));
listen(sock0, 5);

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf),
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"Hello World!!\r\n");
while (1) {
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *) &client, &len);
memset(inbuf, 0, sizeof(inbuf));
recv(sock, inbuf, sizeof(inbuf), 0);
send(sock, buf, (int) strlen(buf), 0);
close(sock);
}
close(sock0);
return 0;
}


gcc -o web web.c
./web

 

(10)

apt install build-essential

gcc --version

vim hello.c

#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}

gcc -o hello hello.c
./hello

--
vim web.c

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main() {
int sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
int sock;
int yes = 1;

char buf[2048];
char inbuf[2048];

sock0 = socket(AF_INET, SOCK_STREAM, 0);

addr.sin_family = AF_INET;
addr.sin_port = htons(8080);
addr.sin_addr.s_addr = INADDR_ANY;
setsockopt(sock0, SOL_SOCKET, SO_REUSEADDR, (const char *) &yes, sizeof(yes));
bind(sock0, (struct sockaddr *) &addr, sizeof(addr));
listen(sock0, 5);

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf),
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"Hello World!!\r\n");
while (1) {
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *) &client, &len);
memset(inbuf, 0, sizeof(inbuf));
recv(sock, inbuf, sizeof(inbuf), 0);
send(sock, buf, (int) strlen(buf), 0);
close(sock);
}
close(sock0);
return 0;
}


gcc -o web web.c
./web

 

 

(8)

gcc --version

vim hello.c

#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}

gcc -o hello hello.c
./hello

--
vim web.c

#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>

int main() {
int sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
int sock;
int yes = 1;

char buf[2048];
char inbuf[2048];

sock0 = socket(AF_INET, SOCK_STREAM, 0);

addr.sin_family = AF_INET;
addr.sin_port = htons(8080);
addr.sin_addr.s_addr = INADDR_ANY;
setsockopt(sock0, SOL_SOCKET, SO_REUSEADDR, (const char *) &yes, sizeof(yes));
bind(sock0, (struct sockaddr *) &addr, sizeof(addr));
listen(sock0, 5);

memset(buf, 0, sizeof(buf));
snprintf(buf, sizeof(buf),
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"Hello World!!\r\n");
while (1) {
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *) &client, &len);
memset(inbuf, 0, sizeof(inbuf));
recv(sock, inbuf, sizeof(inbuf), 0);
send(sock, buf, (int) strlen(buf), 0);
close(sock);
}
close(sock0);
return 0;
}


gcc -o web web.c
./web

 

(2019)

https://hacknote.jp/archives/53289/
https://www.geekpage.jp/programming/winsock/http-server.php

cd C:\MinGW\bin

gcc --version

notepad hello.c

#include <stdio.h>

int main(void)
{
printf("Hello World!\n");

return 0;
}

gcc -o hello hello.c
hello

--
notepad web.c

#include <stdio.h>
#include <winsock2.h>

int
main()
{
WSADATA wsaData;
SOCKET sock0;
struct sockaddr_in addr;
struct sockaddr_in client;
int len;
SOCKET sock;
BOOL yes = 1;

char buf[2048];
char inbuf[2048];

WSAStartup(MAKEWORD(2,0), &wsaData);

sock0 = socket(AF_INET, SOCK_STREAM, 0);

addr.sin_family = AF_INET;
addr.sin_port = htons(8080);
addr.sin_addr.S_un.S_addr = INADDR_ANY;
setsockopt(sock0, SOL_SOCKET, SO_REUSEADDR, (const char *)&yes, sizeof(yes));
bind(sock0, (struct sockaddr *)&addr, sizeof(addr));
listen(sock0, 5);

memset(buf, 0, sizeof(buf));
_snprintf(buf, sizeof(buf),
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"\r\n"
"Hello World!!\r\n");
while (1) {
len = sizeof(client);
sock = accept(sock0, (struct sockaddr *)&client, &len);
memset(inbuf, 0, sizeof(inbuf));
recv(sock, inbuf, sizeof(inbuf), 0);
send(sock, buf, (int)strlen(buf), 0);
closesocket(sock);
}

WSACleanup();

return 0;
}

gcc -o web web.c -lwsock32 -lws2_32
web