Tag: cheatsheet

cheetsheet/aws/elasticache

aws-cliでキャッシュを作成する aws elasticache create-cache-cluster \ --cache-cluster-id 'test-20170925' \ --engine 'redis' \ --engine-version '3.2.4' \ --cache-parameter-group-name 'default.redis3.2' \ --cache-node-type 'cache.t2.micro' \ --num-cache-nodes 1 \ --security-group-ids 'sg-111111' \ --cache-subnet-group-name cachesubnet キャッシュを削除 aws elasticache delete-cache-cluster --cache-cluster-id test-20170925 Read more...

cheatsheet/aws/cloudwatch

ログストリームをまたいで検索 下記を参照 [新機能]CloudWatch Logs がアップデート、ログストリームをまたいで検索できるように! | Developers.IO 更に時間を指定する場合、–start-time と –end-time をつけると絞り込みができる。 この時刻は UTC で Unix date をミリ秒で表現する必要がある( 1000 倍する ) 04/19 16:30 の場合 ( unix date 出して、UTC との時差、9 時間を引いて、ミリ秒にしている echo $(( ($(date -d “2017-04-19 16:30” +%s) - 60 _ 60 _ 9) * 1000 )) => 1492554600000 04/19 17:30 の場合 echo $(( ($(date -d “2017-04-19 17:30” +%s) - 60 _ 60 _ 9) * 1000 )) => 1492558200000 検索例) aws logs filter-log-events –region ap-northeast-1 –log-group-name sns/ap-northeast-1/11111111111111/app/APNS/ExampleProduction –max-items 300000 –start-time 1492554600000 –end-time 1492558200000 Read more...

cheetsheet/aws/rds

パラメーターグループ 作る aws rds create-db-cluster-parameter-group \ --db-cluster-parameter-group-name hoge-canvas-postgresql10 \ --db-parameter-group-family aurora-postgresql10 \ --description "for wal_level must be set to logical" 参考 aws rds create-db-cluster-parameter-group help 編集 aws rds modify-db-cluster-parameter-group \ --db-cluster-parameter-group-name hoge-canvas-postgresql10 \ --parameters "ParameterName=rds.logical_replication,ParameterValue=1,ApplyMethod=pending-reboot" 設定するパラメーターによっては即時反映 ApplyMethod=immediate が使えず An error occurred (InvalidParameterCombination) when calling the ModifyDBClusterParameterGroup operation: cannot use immediate apply method for static parameter というエラーが出る。この場合、 ApplyMethod=pending-reboot を使う必要がある。 staticかどうか?はWebUIの『タイプの適用』の箇所を見るとわかる。 反映 aws rds modify-db-cluster \ --apply-immediately \ --db-cluster-identifier hoge \ --db-cluster-parameter-group-name hoge-canvas-postgresql10 パラメータグループ作成 パラメータグループ名: test-aurora 説明: utf8mb4 ファミリー: aurora5. Read more...

cheetsheet/aws/runcommand

SSMエージェントがインストール済みのサーバに対して、あるコマンド、スクリプトを実行できる仕組みを構築した。 エージェントが入っているインスタンス一覧 aws ssm describe-instance-information --output text --query "InstanceInformationList[*]" コマンド実行 aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids i-1111111111111 --parameters '{"commands":["/etc/init.d/gitpull start"],"executionTimeout":["300"]}' 複数サーバにコマンドを実行する aws ssm send-command --document-name "AWS-RunShellScript" --instance-ids $(aws ssm describe-instance-information --output text --query "InstanceInformationList[*]" |grep -E 'i-.*' | awk '{print $2}' ) --parameters '{"commands":["/etc/init.d/gitpull start"],"executionTimeout":["300"]}' githubへの接続が上手く行かなかったら、アップデートもresetもしない git remote show origin > /dev/null 2>&1 Read more...

dd

50GBの空のファイルを作る dd if=/dev/zero bs=1M count=52400 |pv -L 25m > k001.img 壊れた # dd if=/dev/sdb of=/dev/sdc bs=512 conv=noerror,sync を実行しドライブをコピーします。 ※数時間かかります。 ※convでエラーをスキップするように指定します。 ※bs=512 は512バイトずつコピーしますよ、という意味です。 エラーがある部分をスキップする際もこの単位でスキップします。 この値が大きいとコピー速度が速くなりますが壊れている部分があると道連れになる範囲も大きくなります。 この値を小さくするとエラー時に道連れになる範囲は最小で済みますがコピー速度が遅くなります。 UNIXの部屋 コマンド検索:dd (*BSD/Linux) dd if=/dev/ad0 | gzip -c > ad0backup.dump.gz ⇒ 圧縮しつつバックアップ ディスククリア dd if=/dev/zero of=/mnt bs=1024 count=xxxxってな感じかな。 Read more...