Amazon ElastiCache - Hands On Demo

Step 1: Create an EC2 instance

 

  1. Open the Amazon EC2 console.

  2. From the EC2 console dashboard, in the Launch instance box, choose Launch instance.

  3. Under Name and tags, for Name, enter a descriptive name for your instance.

  4. Under Application and OS Images (Amazon Machine Image), do the following:

    1. Choose Quick Start, and then choose Amazon Linux. This is the operating system (OS) for your instance.

    2. From Amazon Machine Image (AMI), select an HVM version of Amazon Linux 2. Notice that these AMIs are marked Free Tier eligible

  5. Under Instance type, from the Instance type list, you can select the hardware configuration for your instance. Choose the t2.micro instance type, which is selected by default. The t2.micro instance type is eligible for the Free Tier. In Regions where t2.micro is unavailable, you can use a t3.micro instance under the Free Tier. 

  6. Under Key pair (login), for Key pair name, create a new key pair or choose an existing one.

  7. Under Network settings, click "Select existing security group". Select the "default" security group.

  8. Keep the default selections for the other configuration settings for your instance.

  9. Review a summary of your instance configuration in the Summary panel, and when you're ready, choose Launch instance.

  10. It can take a few minutes for the instance to be ready for you to connect to it. Check that your instance has passed its status checks; you can view this information in the Status check column.

elasticache-connect

Step 2 : Grant network access from an Amazon VPC security group to your cache

 

 

  1. In the navigation pane, under Network & Security, choose Security Groups.

  2. From the list of security groups, choose the security group for your Amazon VPC. Unless you created a security group for ElastiCache use, this security group will be named default.

  3. Choose the Inbound tab, and then:

    1. Choose Edit.

    2. Choose Add rule.

    3. In the Type column, choose Custom TCP rule.

    4. In the Port range box, type 6379.

    5. In the Source box, choose Anywhere which has the port range (0.0.0.0/0) so that any Amazon EC2 instance that you launch within your Amazon VPC can connect to your cache.

    6. Add another rule by choosing Add rule.

    7. In the Type column, choose Custom TCP rule.

    8. In the Port rangebox, type 6380.

    9. In the Source box, choose Anywhere which has the port range (0.0.0.0/0) so that any Amazon EC2 instance that you launch within your Amazon VPC can connect to your cache.

    10. Add a rule to allow ssh port 22 also so that we can connect to the EC2 Instance.

    11. Choose Save

Step 3 : Connect using the Amazon EC2 console

 

 

To connect to your instance using the browser-based client from the Amazon EC2 console
  1. Open the Amazon EC2 console.

  2. In the navigation pane, choose Instances.

  3. Select the instance and choose Connect.

  4. Choose EC2 Instance Connect.

  5. Verify the user name and choose Connect to open a terminal window.

Step 4 : Download and set up redis-cli

sudo amazon-linux-extras install epel -y
sudo yum install gcc jemalloc-devel openssl-devel tcl tcl-devel -y
sudo wget http://download.redis.io/redis-stable.tar.gz
sudo tar xvzf redis-stable.tar.gz
cd redis-stable
sudo make BUILD_TLS=yes

Step 5 : Create a cache

 

  1. Sign in to the AWS Management Console and open the Elasticache service.

  2. In the navigation pane on the left side of the console, choose Redis caches.

  3. On the right side of the console, choose Create Redis cache

  4. In the Cache settings enter a Name. You can optionally enter a description for the cache.

  5. Leave the default settings selected.

  6. Click Create to create the cache.

  7. Once the cache is in "ACTIVE" status, you can begin writing and reading data to the cache. 

redis-cache

Step 6 : Read and write data to the cache

 

  1. In the Cache details, locate and copy the cache endpoint.

  2. You can log in to your EC2 instance and connect to the cache.

src/redis-cli -h cache-endpoint --tls -p 6379
set a "hello"
OK
get a
"hello"

Step 7 : Clean up

 

To delete your cache using the console:

  1. Sign in to the AWS Management Console and open the Amazon ElastiCache console.

  2. In the navigation pane on the left side of the console, choose Redis Caches.

  3. Choose the radio button next to the cache you want to delete.

  4. Select Actions on the top right, and select Delete.

  5. You can optionally choose to take a final snapshot before you delete your cache.

  6. In the Delete confirmation screen, re-enter the cache name and choose Delete to delete the cluster.

Step 8 : Terminate EC2 instance

 

  1. Open the Amazon EC2 console.

  2. In the navigation pane, choose Instances.

  3. Select the instance, and choose Instance state, Terminate instance.

  4. Choose Terminate when prompted for confirmation.

 

 

Thanks

For

Watching