0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ElastiCacheCluster作成(aws-cli)

Last updated at Posted at 2019-10-03

aws-cliでのElastiCacheClusterの作成

公式

Create ParameterGroup

memcached

aws elasticache create-cache-parameter-group \
    --cache-parameter-group-name test-memcached  \
    --cache-parameter-group-family memcached1.4 \
    --description "test parameter group for memcached1.4"

Redis

aws elasticache create-cache-parameter-group \
    --cache-parameter-group-name test-redis  \
    --cache-parameter-group-family  redis4.0\
    --description "test parameter group for redis4.0"

Create SubnetGroup

aws elasticache create-cache-subnet-group \
    --cache-subnet-group-name test-elasticache-subnet-group \
    --cache-subnet-group-description "test elasticache subnet group" \
    --subnet-ids "subnet-*******" "subnet-******"

Create cache Cluster Memcached

ECACHE_CLUSTER_ID="test-cache-mem"
ECACHE_ENGINE_NAME="memcached" 
ECACHE_ENGINE_VERSION="1.4.33"
ECACHE_PARAM_GROUP_NAME="test-memcached"
ECACHE_SUBNET_GROUP_NAME="test-elasticache-subnet-group"
ECACHE_NODE_TYPE="cache.t2.micro"
ECACHE_NODE_COUNT=2
ARRAY_VPC_SG_IDS="sg-********"
AZ_MODE="cross-az"
aws elasticache create-cache-cluster \
        --cache-cluster-id ${ECACHE_CLUSTER_ID} \
        --engine ${ECACHE_ENGINE_NAME} \
        --engine-version ${ECACHE_ENGINE_VERSION} \
        --cache-parameter-group-name ${ECACHE_PARAM_GROUP_NAME} \
        --cache-subnet-group-name ${ECACHE_SUBNET_GROUP_NAME} \
        --cache-node-type ${ECACHE_NODE_TYPE} \
        --num-cache-nodes ${ECACHE_NODE_COUNT} \
        --security-group-ids ${ARRAY_VPC_SG_IDS} \
        --az-mode ${AZ_MODE}

Create cache Cluster Redis

ECACHE_CLUSTER_ID="test-redis-001"
ECACHE_ENGINE_NAME="redis" 
ECACHE_ENGINE_VERSION="4.0.10"
ECACHE_PARAM_GROUP_NAME="test-redis"
ECACHE_SUBNET_GROUP_NAME="test-elasticache-subnet-group"
ECACHE_NODE_TYPE="cache.t2.micro"
ECACHE_NODE_COUNT=1
ARRAY_VPC_SG_IDS="sg-*********"
AZ_MODE="cross-az"
SNAP_RETENTION=1
PREFERRED_AZ="ap-northeast-1a"
aws elasticache create-cache-cluster \
        --cache-cluster-id ${ECACHE_CLUSTER_ID} \
        --engine ${ECACHE_ENGINE_NAME} \
        --engine-version ${ECACHE_ENGINE_VERSION} \
        --cache-parameter-group-name ${ECACHE_PARAM_GROUP_NAME} \
        --cache-subnet-group-name ${ECACHE_SUBNET_GROUP_NAME} \
        --cache-node-type ${ECACHE_NODE_TYPE} \
        --num-cache-nodes ${ECACHE_NODE_COUNT} \
        --security-group-ids ${ARRAY_VPC_SG_IDS} \
        --snapshot-retention-limit ${SNAP_RETENTION} \
        --preferred-availability-zone ${PREFERRED_AZ}

Create Repliaction Group

REPLICA_GROUP_ID="test-replica-group"
aws elasticache create-replication-group \
  --replication-group-id ${REPLICA_GROUP_ID} \
  --primary-cluster-id ${ECACHE_CLUSTER_ID} \
  --replication-group-description 'test replication group'

Add replica node

REPLICA_CLUSTER_ID="test-redis-002"
REPLICA_PREFERRED_AZ="ap-northeast-1c"
aws elasticache create-cache-cluster \
  --cache-cluster-id ${REPLICA_CLUSTER_ID} \
  --replication-group-id ${REPLICA_GROUP_ID} \
  --preferred-availability-zone ${REPLICA_PREFERRED_AZ}

Enable Auto Failover

aws elasticache modify-replication-group \
    --replication-group-id ${REPLICA_GROUP_ID} \
    --automatic-failover-enabled \
    --apply-immediately

Test

memcached

$ telnet endpoint 11211
ping
+PONG

Redis

$ telnet endpoint 6379
ping
+PONG
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?