Bobcares

Access elasticache redis

by | Jan 10, 2023

Wondering how to access elasticache redis? Our in-house experts are here to help you out with this article. Our redis support is here to offer a lending hand with your queries and issues.

How to access elasticache redis?

Amazon ElastiCache is a web service that makes it easy to set up, manage, and scale a distributed in-memory data store or cache environment in the cloud.

It provides a high-performance, scalable, and cost-effective caching solution.

If ElastiCache/Redis deployments default encryption for both inflight and at-rest, then this could cause issues with connectivity for some clients, like redis-cli.

Redis offers purpose-built in-memory data structures and operators to manage real-time geospatial data at scale and speed.

Today, let us see the steps followed by support techs to access elasticache redis:

1. Firstly, using an ec2 I have an ec2 keypair for (app server):

INSTANCE_NAME=demo-appCopy Code

2. Then, find the instance ID based on Tag Name

INSTANCE_ID=$(aws ec2 describe-instances \
--filter “Name=tag:Name,Values=${INSTANCE_NAME}” \
--query “Reservations[].Instances[?State.Name == ‘running’].InstanceId[]” \
--output text)Copy Code

3. To connect to the EC2 to test connectivity

aws ssm start-session — target “${INSTANCE_ID}# — — — — — — — — — — — –
# On the EC2
# — — — — — — — — — — — –Copy Code

4. Test EC2 connectivity to redis is OK

curl -v telnet://master.demo.cache.amazonaws.com:6379Copy Code

5. Setup stunnel as per –

https://aws.amazon.com/premiumsupport/knowledge-center/elasticache-connect-redis-node/Copy Code

6. Install stunnel on ec2

sudo yum install -y stunnel

# cat /etc/stunnel/redis-cli.conf

fips = no
setuid = root
setgid = root
pid = /var/run/stunnel.pid
debug = 7
options = NO_SSLv2
options = NO_SSLv3
[redis-cli]
client = yes
accept = 127.0.0.1:6379
connect = master.demo.cache.amazonaws.com:6379
[redis-cli-slave]
client = yes
accept = 127.0.0.1:6380
connect = demo.app.cache.amazonaws.com:6379Copy Code

7. Run stunnel (as root)

sudo stunnel /etc/stunnel/redis-cli.conf

# Check if it’s up

netstat -tulnp | grep -i stunnelexit

# — — — — — — — — — — — –
# Back on the laptop
# — — — — — — — — — — — –Copy Code

8. Create 2 port forwarding tunnels for stunnel redis

aws ssm start-session --target $INSTANCE_ID \
--document-name AWS-StartPortForwardingSession \
--parameters ‘{“portNumber”:[“6379”],”localPortNumber”:[“6379”]}’

aws ssm start-session — target $INSTANCE_ID \
--document-name AWS-StartPortForwardingSession \
--parameters ‘{“portNumber”:[“6380”],”localPortNumber”:[“6380”]}’Copy Code

9. Now test from laptop

redis-cli -h localhost -p 6379 -a eNdU35somebigpasswordXpvD pingCopy Code

[Looking for a solution to another query? We’re happy to help.]

Conclusion

In this article, we provide a quick and simple solution from our Support team to access elasticache redis

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Speed issues driving customers away?
We’ve got your back!