Skip to main content

Command Palette

Search for a command to run...

Redis - Roboshop Project

Updated
2 min read

The Code to create EC2 T2.Small server.

{
  "MaxCount": 1,
  "MinCount": 1,
  "ImageId": "ami-0089b8e98cd95257d",
  "InstanceType": "t2.small",
  "EbsOptimized": false,
  "NetworkInterfaces": [
    {
      "DeviceIndex": 0,
      "AssociatePublicIpAddress": true,
      "SubnetId": "subnet-086a045ade7eae99f",
      "Groups": [
        "sg-0c2e3fdd288a74d3a"
      ]
    }
  ],
  "TagSpecifications": [
    {
      "ResourceType": "instance",
      "Tags": [
        {
          "Key": "Name",
          "Value": "redis"
        }
      ]
    },
    {
      "ResourceType": "spot-instances-request",
      "Tags": [
        {
          "Key": "Name",
          "Value": "redis"
        }
      ]
    }
  ],
  "InstanceMarketOptions": {
    "MarketType": "spot",
    "SpotOptions": {
      "InstanceInterruptionBehavior": "stop",
      "SpotInstanceType": "persistent"
    }
  },
  "PrivateDnsNameOptions": {
    "HostnameType": "ip-name",
    "EnableResourceNameDnsARecord": true,
    "EnableResourceNameDnsAAAARecord": false
  }
}

Redis Configuration

This script sets up Redis, which is used for in-memory data storage (caching) and allows users to access the data of a database over an API.

To begin, the developer's chosen version of the DB software should be confirmed. Redis provides a repo file as an RPM, so the first step is to install it using the following command:

yum install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y

Next, Redis 6.2 should be enabled from package streams using this command:

dnf module enable redis:remi-6.2 -y

After that, Redis can be installed with the following command:

yum install redis -y

By default, Redis only opens the port to the localhost (127.0.0.1), which means that this service can only be accessed by the application that is hosted on this server. However, if we need to access this service from another server, we must modify the configuration accordingly. Specifically, we need to update the listen address from 127.0.0.1 to 0.0.0.0 in both /etc/redis.conf and /etc/redis/redis.conf.

Once the Redis configuration has been updated, we can start and enable the Redis service with these commands:

systemctl enable redis 
systemctl start redis
1 views