Professional Documents
Culture Documents
Each AZ has independent power, cooling, and physical security and is connected via redundant,
ultra-low-latency networks. AWS customers focused on high availability can design their applications
to run in multiple AZs to achieve even greater fault-tolerance. AWS infrastructure Regions meet the
highest levels of security, compliance, and data protection.
All AZs in an AWS Region are interconnected with high-bandwidth, low-latency networking, over fully
redundant, dedicated metro fiber providing high-throughput, low-latency networking between AZs. All
traffic between AZs is encrypted. The network performance is sufficient to accomplish synchronous
replication between AZs. AZs make partitioning applications for high availability easy. If an
application is partitioned across AZs, companies are better isolated and protected from issues such
as power outages, lightning strikes, tornadoes, earthquakes, and more. AZs are physically
separated by a meaningful distance, many kilometers, from any other AZ, although all are within 100
km (60 miles) of each other.
Amazon Aurora
Amazon Aurora (Aurora) is a fully managed relational database engine that's compatible with
MySQL and PostgreSQL.
An Amazon Aurora DB cluster consists of one or more DB instances and a cluster volume that
manages the data for those DB instances.
Primary DB instance – Supports read and write operations, and performs all of the data
modifications to the cluster volume. Each Aurora DB cluster has one primary DB
instance.
Aurora Replica – Connects to the same storage volume as the primary DB instance and
supports only read operations. Each Aurora DB cluster can have up to 15 Aurora
Replicas in addition to the primary DB instance. Maintain high availability by locating
Aurora Replicas in separate Availability Zones. Aurora automatically fails over to an
Aurora Replica in case the primary DB instance becomes unavailable. You can specify
the failover priority for Aurora Replicas. Aurora Replicas can also offload read
workloads from the primary DB instance.
Backtracking in Aurora
By using backtracking in Aurora, you return the state of an Aurora cluster to a specific
point in time, without restoring data from a backup. It completes within seconds, even
for large databases.
Aurora backtracking is available for Aurora MySQL only. It's not available for Aurora
PostgreSQL.
Each Aurora DB cluster has one cluster endpoint and one primary DB instance.
The cluster endpoint provides failover support for read/write connections to the DB
cluster. If the current primary DB instance of a DB cluster fails, Aurora automatically
fails over to a new primary DB instance. During a failover, the DB cluster continues to
serve connection requests to the cluster endpoint from the new primary DB instance,
with minimal interruption of service.
The following example illustrates a cluster endpoint for an Aurora MySQL DB cluster.
mydbcluster.cluster-123456789012.us-east-1.rds.amazonaws.com:3306
Reader endpoint
A reader endpoint for an Aurora DB cluster provides load-balancing support for read-
only connections to the DB cluster. Use the reader endpoint for read operations, such
as queries. By processing those statements on the read-only Aurora Replicas, this
endpoint reduces the overhead on the primary instance. It also helps the cluster to scale
the capacity to handle simultaneous SELECT queries, proportional to the number of
Aurora Replicas in the cluster. Each Aurora DB cluster has one reader endpoint.
If the cluster contains one or more Aurora Replicas, the reader endpoint load-balances
each connection request among the Aurora Replicas. In that case, you can only
perform read-only statements such as SELECT in that session. If the cluster only
contains a primary instance and no Aurora Replicas, the reader endpoint connects to
the primary instance. In that case, you can perform write operations through the
endpoint.
The following example illustrates a reader endpoint for an Aurora MySQL DB cluster.
mydbcluster.cluster-ro-123456789012.us-east-1.rds.amazonaws.com:3306
Custom endpoint
A custom endpoint for an Aurora cluster represents a set of DB instances that you
choose. When you connect to the endpoint, Aurora performs load balancing and
chooses one of the instances in the group to handle the connection. You define which
instances this endpoint refers to, and you decide what purpose the endpoint serves.
An Aurora DB cluster has no custom endpoints until you create one. You can create up
to five custom endpoints for each provisioned Aurora cluster. You can't use custom
endpoints for Aurora Serverless clusters.
Instance endpoint
An instance endpoint connects to a specific DB instance within an Aurora cluster.
Each DB instance in a DB cluster has its own unique instance endpoint. So there is one
instance endpoint for the current primary DB instance of the DB cluster, and there is
one instance endpoint for each of the Aurora Replicas in the DB cluster.
mydbinstance.123456789012.us-east-1.rds.amazonaws.com:3306
pgdb=> \db
List of tablespaces
Name | Owner | Location
------------+----------+----------
pg_default | rdsadmin |
pg_global | rdsadmin |
(2 rows)
pgdb=> \du
List of roles
Role name | Attributes | Member of
-----------------+------------------------------------------------------------+-------------------------------------
------------------------
postgres | Create role, Create DB +| {rds_superuser}
| Password valid until infinity |
rds_ad | Cannot login | {}
rds_iam | Cannot login | {}
rds_password | Cannot login | {}
rds_replication | Cannot login | {}
rds_superuser | Cannot login | {pg_monitor,pg_signal_backend,rds_re
plication,rds_password}
rdsadmin | Superuser, Create role, Create DB, Replication, Bypass RLS+| {}
| Password valid until infinity |
CREATE ROLE
GRANT
psql --host=pg-cluster-01.cluster-cyl1dmhpwxpb.us-east-2.rds.amazonaws.com --port=5432 --
username=app_user --password --dbname=pgdb
3) Databases:
pgdb=> \list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
pgdb | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
rdsadmin | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | rdsadmin=CTc/rdsadmin
template0 | rdsadmin | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/rdsadmin +
| | | | | rdsadmin=CTc/rdsadmin
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres +
| | | | | postgres=CTc/postgres
(5 rows)
current_database
------------------
pgdb
(1 row)
To switch to another databases:
4) Create Schema:
CREATE SCHEMA
pgdb=> \dn
List of schemas
Name | Owner
------------+----------
app_schema | postgres
public | postgres
(2 rows)
5) Create table:
CREATE TABLE
pgdb=> insert into app_schema.test_table_01 values (1) ;
INSERT 0 1
id
----
on;
off;
AWS CLI
-bash-4.2$ cd $HOME/.aws
-bash-4.2$ ls -ltr
total 4
-rw-r--r--. 1 postgres postgres 136 Sep 2 16:55 config
{
"DBClusters": [
{
"MasterUsername": "postgres",
"ReaderEndpoint": "pg-cluster-01.cluster-ro-cyl1dmhpwxpb.us-east-2.rds.amazonaws.com",
"HttpEndpointEnabled": false,
"ReadReplicaIdentifiers": [],
"VpcSecurityGroups": [
{
"Status": "active",
"VpcSecurityGroupId": "sg-0f75ccce52c5caaa6"
}
],
"CopyTagsToSnapshot": false,
"HostedZoneId": "Z2XHWR1WZ565X2",
"EngineMode": "provisioned",
"Status": "available",
"MultiAZ": true,
"LatestRestorableTime": "2021-09-02T21:57:20.873Z",
"PreferredBackupWindow": "09:34-10:04",
"DBSubnetGroup": "default-vpc-0bd335e3a338ec446",
"AllocatedStorage": 1,
"ActivityStreamStatus": "stopped",
"BackupRetentionPeriod": 1,
"PreferredMaintenanceWindow": "mon:07:00-mon:09:00",
"Engine": "aurora-postgresql",
"Endpoint": "pg-cluster-01.cluster-cyl1dmhpwxpb.us-east-2.rds.amazonaws.com",
"AssociatedRoles": [],
"EarliestRestorableTime": "2021-09-02T21:24:18.567Z",
"CrossAccountClone": false,
"IAMDatabaseAuthenticationEnabled": false,
"ClusterCreateTime": "2021-09-02T21:23:06.794Z",
"EngineVersion": "12.7",
"DeletionProtection": false,
"DBClusterIdentifier": "pg-cluster-01",
"DbClusterResourceId": "cluster-FKDAIUYTUFNYZ5T23H2OAWQNYU",
"DBClusterMembers": [
{
"IsClusterWriter": false,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1,
"DBInstanceIdentifier": "pg-cluster-01-instance-1-us-east-2c"
},
{
"IsClusterWriter": true,
"DBClusterParameterGroupStatus": "in-sync",
"PromotionTier": 1,
"DBInstanceIdentifier": "pg-cluster-01-instance-1"
}
],
"DBClusterArn": "arn:aws:rds:us-east-2:005663991416:cluster:pg-cluster-01",
"KmsKeyId": "arn:aws:kms:us-east-2:005663991416:key/4803271a-a2cb-42b6-9de0-
dc72ac397b31",
"StorageEncrypted": true,
"DatabaseName": "pgdb",
"DBClusterParameterGroup": "default.aurora-postgresql12",
"AvailabilityZones": [
"us-east-2b",
"us-east-2c",
"us-east-2a"
],
"Port": 5432
}
]
}
[
{
"CustomEndpoints": null,
"Endpoint": "pg-cluster-01.cluster-cyl1dmhpwxpb.us-east-2.rds.amazonaws.com",
"ReaderEndpoint": "pg-cluster-01.cluster-ro-cyl1dmhpwxpb.us-east-2.rds.amazonaws.com"
}
]
--preferred-maintenance-window
--db-cluster-identifier <value>
--preferred-backup-window <value>]
[--preferred-maintenance-window <value>
Backup Retention: