okochangの馬鹿でありがとう

ふらふら適当に世間を生きる日々でございます

ElastiCacheのCLIツールでVPCにクラスタを作る

本日、AWS界隈の方はRedshiftのBetaリリースで盛り上がっているようです。

【AWS発表】Amazon Redshift がどなたでもご利用可能に!

そんな中、今日も私はElastiCacheのCLIツールのブログを書きます ( ꒪⌓꒪)
前回動作確認が出来たCLIツールで、VPC内にクラスタを作ってみたいと思いますよ。

作成手順

RDSと同じようにVPC内にElastiCacheを構築する場合はサブネットグループが必要になります。

$ elasticache-create-cache-subnet-group yanase-subnet-group --description "development group" --subnet-ID-list subnet-34270c5d,subnet-0a270c63,subnet-06270c6f
SUBNETGROUP  yanase-subnet-group  development group  vpc-0fc5a566
      SUBNET  subnet-06270c6f  ap-northeast-1b
      SUBNET  subnet-0a270c63  ap-northeast-1a
      SUBNET  subnet-34270c5d  ap-northeast-1c

次にElastiCacheで使用するセキュリティグループを作成します。
VPCの場合、セキュリティグループはEC2などで使えるものと統合されているので、EC2のCLIツールで作ります。

$ ec2-create-group yanase-cache-group --description "development group" --vpc vpc-0fc5a566
GROUP	sg-ee9a8582	yanase-cache-group	development group

※もしVPCでない場合はElastiCacheのCLIツールで作ります。

elasticache-create-cache-security-group --cache-security-group-name yanase-security-group --description "development group"

ElastiCacheのパラメータグループを作成します。

$ elasticache-create-cache-parameter-group yanase-paramater-group --cache-parameter-group-family memcached1.4 --description "development group"
CACHEPARAMETERGROUP  yanase-paramater-group  memcached1.4  development group

そして最後にクラスタを作成します。

$ elasticache-create-cache-cluster yanase-cache \
--num-cache-nodes 2 \
--cache-node-type cache.t1.micro \
--engine memcached --engine-version 1.4.14 \
--security-group-ids sg-ee9a8582 \
--port 11211 \
--preferred-availability-zone ap-northeast-1a \
--cache-parameter-group-name yanase-paramater-group \
--auto-minor-version-upgrade true \
--cache-subnet-group-name yanase-subnet-group
CACHECLUSTER  yanase-cache  https://console.aws.amazon.com/elasticache/home#client-download:  cache.t1.micro  memcached  creating  2  ap-northeast-1a  1.4.14
      CACHEPARAMETERGROUP  yanase-paramater-group  in-sync
      CACHESUBNETGROUP  yanase-subnet-group
      SECURITYGROUPID  sg-ee9a8582  active

あとがき

無事に作成が出来ましたね―。
Management Consoleはとても便利ですが、CLIツールの方が作業が早く出来たりする場合もあると思うのでなかなか重宝出来そうですよ。