亚马逊提供的RDS中包含oracle, sql server, mysql, postgresql.
是一个DaaS服务.
作为一个DaaS服务, AWS的RDS提供了哪些功能呢?
1. 数据库参数是预配置好的, 所以用户不需要对数据库进行配置.
2. 监控
3. 自动打补丁
4. 自动备份
5. 数据库快照(自动/手动接口)
6. 事件触发告警, 提供SMS短信, 邮件等接口
7. 存储provision(即可以预知IOPS和容量, 但是可能不使用这么多容量或IOPS, 有点类似宽带里面的共享带宽的概念)
8. 快速硬件扩容(可能需要分钟级的DOWN机切换), 但是如果你使用了provision的话, 如果扩展到provision以内的指标则不需要DOWN机.
9. 自动主机替换(即当主机异常时, 自动切换到正常主机)
10. 数据复制(目前好像提供了两种复制方案, 一种提供只读(类似PG流复制, MYSQL的binlog复制), 一种应该不提供只读(可能是存储级别对数据库透明的复制))
11. 数据库网络隔离, 例如数据库不暴露在外网, 而是使用VPN拨号访问数据库.
12. 资源级别的权限控制(例如可以对不同的管理用户, 分配不同的管理权限, 如创建快照, 创建数据库实例等不同的权限)
13. 数据库级别的特性, 例如PG支持postgis, hstore, json, full text search, language extension等.
从以上功能来看, 有一点可能是比较难做到的 :
8. 快速硬件扩容(可能需要分钟级的DOWN机切换), 但是如果你使用了provision的话, 如果扩展到provision以内的指标则不需要DOWN机.
假设AWS RDS是基于虚拟化技术来实现的 :
IOPS和容量的扩容势必需要对底层块设备进行扩容, 但是直接扩块设备显然是需要停机的, 所以provisioin应该是这个数据库就运行在一个比较强劲的设备上, 那么不需要停机, 只需要调整QoS和磁盘配额即可.
但是如果一开始数据库跑在一个比较差的环境中, 要扩容量和IOPS就涉及到虚拟机的迁移, 即虚拟机迁移到一个比较强劲的环境.
但是虚拟化技术如KVM, 对性能的损失还是比较大的, 如果使用Docker类似的虚拟化产生可以提升性能, 但是虚拟机的迁移可能就没有那么平滑, 例如数据文件的传输. 所以这样的话考验网络传输能力, 而且肯定是需要停机传输的.
我个人还是决定AWS RDS用docker类似的技术可能性比较大, 因为传统虚拟机技术对性能损耗确实有点大.
AWS还对iops和网卡做了QoS的限制, 目前docker还没有整合这两块的限制功能. 如果要用docker来做一个类似RDS的产品, 这方面还需要改进一下.
因为AWS没有对RDS做架构方面的介绍, 这里大胆的假设一下, 罗列几种可能的架构, 使用本地块设备 或者 使用远程块设备.
本地块设备架构 :
主机分为几类, 按照内存, CPU, IOPS能力, 存储容量来分类.
使用本地磁盘, (弊端是FAILOVER, 如果使用DRBD或流复制来切换不是不可能, 但是增加了FAILOVER的复杂度)
每个实例使用docker封装, 或者其他虚拟化技术.
注意对磁盘iops和网络,CPU,磁盘容量的配额.
扩容方案一, 更换主机,
因为使用的是本地磁盘, 注意更换主机时, 需要从备份中还原数据库.
为了得到一致性的数据, 必须关库后, 将最后的XLOG归档后, 再实施还原.
扩容方案二, A类主机可能本来就是高性能主机, 只要provision允许范围内, 扩容都不需要更换主机, 调整QoS即可.
failover模式A,
因为使用本地磁盘, 所以failover涉及数据恢复步骤. 数据恢复到另一台主机可能比较慢, 由数据库的大小和网络带宽以及IOPS能力有关.
另一种failover模式, 主要解决的问题是还原速度的问题, 可能直接就在备份上面克隆一个镜像来还原, 并使用.
这种模式的failover还需要failback, 只是临时用用的. 毕竟还是需要用本地硬盘的.
远程块设备架构 :
因为使用远程块设备, 所以failover就变简单了, 但是远程块设备本身需要提供高可用能力.
另外使用远程块设备的话, 扩容的同时也需要扩容远程块设备.
貌似远程块设备更靠谱一点.
最后, 备份这一层其实也不一定要数据库来实现, 因为AWS RDS并没有指出它可以恢复到任意时间点,
所以极其可能在存储层来实现自动备份, 例如存储的块级别增量备份.
使用存储层面的自动备份的好处, 可以简化备份方案, 和数据库没有关系了, 所以sql server, mysql, oracle, postgresql 的RDS可以用同一套备份方案.
Amazon RDS Functionality
Amazon RDS is designed for developers or businesses who require the full features and capabilities of a relational database, or who wish to migrate existing applications and tools that utilize a relational database. It gives you access to the capabilities of a MySQL, Oracle, SQL Server, or PostgreSQL database engines running on your own Amazon RDS cloud-based database instance.
To use Amazon RDS, you simply:
- Use the AWS Management Console or Amazon RDS APIs to launch a Database Instance (DB Instance), selecting the DB Engine (MySQL, Oracle, SQL Server, or PostgreSQL), License Type, DB Instance class and storage capacity that best meets your needs.
- Connect to your DB Instance using your favorite database tool or programming language. Since you have direct access to a native MySQL, Oracle, SQL Server, or PostgreSQL database engine, most tools designed for these engines should work unmodified with Amazon RDS.
- Monitor the compute and storage resource utilization of your DB Instance, for no additional charge, via Amazon CloudWatch metrics available using the AWS Management Console “DB Instances” tab or Amazon CloudWatch APIs. If at any point you need additional capacity, you can scale the compute and storage resources associated with your DB Instance with a few clicks of the console or a simple API call.
- Pay only for the resources you actually consume, based on your DB Instance hours consumed, database storage, backup storage, and data transfer.
Features
The features provided by Amazon RDS depend on the DB Engine you select. Visit the Amazon RDS for MySQL page for supported features for the MySQL engine, the Amazon RDS for Oracle Database page for supported features of the Oracle database engine, theAmazon RDS for SQL Server page for supported features for the SQL Server engine, or the Amazon RDS for PostgreSQL page for supported features for the PostgreSQL engine.
Pre-configured Parameters
Amazon RDS DB Instances are pre-configured with an appropriate set of parameters and settings appropriate for the DB Instance class you have selected. You can simply launch a MySQL, Oracle, SQL Server, or PostgreSQL DB Instance and connect your application within minutes without additional configuration. If you desire additional control, you can achieve it via DB Parameter Groups.
Monitoring and Metrics
Amazon RDS provides Amazon CloudWatch metrics for your DB Instance deployments at no additional charge. You can use the AWS Management Console to view key operational metrics for your DB Instance deployments, including compute/memory/storage capacity utilization, I/O activity, and DB Instance connections.
Automatic Software Patching
Amazon RDS will make sure that the relational database software powering your deployment stays up-to-date with the latest patches. You can exert optional control over when and if your DB Instance is patched via DB Engine Version Management.
Automated Backups
Turned on by default, the automated backup feature of Amazon RDS enables point-in-time recovery for your DB Instance. Amazon RDS will backup your database and transaction logs and store both for a user-specified retention period. This allows you to restore your DB Instance to any second during your retention period, up to the last five minutes. Your automatic backup retention period can be configured to up to thirty five days.
DB Snapshots
DB Snapshots are user-initiated backups of your DB Instance. These full database backups will be stored by Amazon RDS until you explicitly delete them. You can create a new DB Instance from a DB Snapshot whenever you desire.
DB Event Notifications
Amazon RDS provides Amazon SNS notifications via email or SMS for your DB Instance deployments. You can use the AWS Management Console or the Amazon RDS APIs to subscribe to over 40 different DB events associated with your Amazon RDS deployments.
Multi-Availability Zone (Multi-AZ) Deployments
Amazon RDS Multi-AZ deployments provide enhanced availability and durability for Database (DB) Instances, making them a natural fit for production database workloads. When you provision a Multi-AZ DB Instance, Amazon RDS automatically creates a primary DB instance and synchronously replicates the data to a standby instance in a different Availability Zone (AZ). Each AZ runs on its own physically distinct, independent infrastructure, and is engineered to be highly reliable. In case of an infrastructure failure (for example, instance crash, storage failure, or network disruption), Amazon RDS performs an automatic failover to the standby so that you can resume database operations as soon as the failover is complete. Since the endpoint for your DB Instance remains the same after a failover, your application can resume database operation without the need for manual administrative intervention. Learn More.
Provisioned IOPS
The following applies to MySQL, Oracle, and PostgreSQL database engines:
- You can provision up to 3TB storage and 30,000 IOPS per database instance. For a workload with 50% writes and 50% reads running on an m2.4xlarge instance, you can realize up to 25,000 IOPS for Oracle. For a similar workload running on cr1.8xlarge you can realize up to 20,000 IOPS for MySQL or PostgreSQL. However, by provisioning up to 30,000 IOPS, you may be able to achieve lower latency and higher throughput. Your actual realized IOPS may vary from the amount you provisioned based on your database workload, instance type, and database engine choice. Refer to the Factors That Affect Realized IOPS section of the Amazon RDS User Guide to learn more.
- You can convert from standard storage to Provisioned IOPS storage and get consistent throughput and low I/O latencies. You will encounter a short availability impact when doing so. You can independently scale IOPS (in increments of 1000) and storage on-the-fly with zero downtime. The ratio of IOPS provisioned to the storage requested (in GB) should be between 3 and 10. For example, for a database instance with 1000 GB of storage, you can provision from 3,000 to 10,000 IOPS. You can scale the IOPS up or down depending on factors such as seasonal variability of traffic to your applications.
If you are using SQL Server, the maximum storage you can provision is 1TB and maximum IOPS you can provision is 10,000 IOPS. The ratio of IOPS to storage (in GB) should be 10 and scaling storage or IOPS of a running DB Instance is not currently supported.
To learn more and get started with Amazon RDS Provisioned IOPS, please refer to the Working with Provisioned IOPS storage section of the Amazon RDS User Guide.
Push-Button Scaling
Using the Amazon RDS APIs or with a few clicks on the AWS Management Console, you can scale the compute and memory resources powering your deployment up or down. Scale compute operations typically complete within a handful of minutes. For the MySQL, Oracle, and PostgreSQL database engines, as your storage requirements grow, you can also provision additional storage on-the-fly with zero downtime. If you are using RDS Provisioned IOPS with the MySQL, Oracle, and PostgreSQL database engines, you can also scale the throughput of your DB Instance by specifying the IOPS rate from 1,000 IOPS to 30,000 IOPS in 1,000 IOPS increments and storage from 100GB to 3TB.
Automatic Host Replacement
Amazon RDS will automatically replace the compute instance powering your deployment in the event of a hardware failure.
Replication
Amazon RDS provides two distinct but complementary replication features: Multi-AZ deployments and Read Replicas that can be used in conjunction to gain enhanced database availability, protect your latest database updates against unplanned outages, and scale beyond the capacity constraints of a single DB Instance for read-heavy database workloads. Multi-AZ deployments are available for the MySQLand Oracle database engines. Read Replicas are currently supported for the MySQL database engine.
Isolation and Security
Using Amazon VPC, you can isolate your DB Instances in your own virtual network, and connect to your existing IT infrastructure using industry-standard encrypted IPsec VPN. The VPC functionality is supported by all RDS DB Engines. To learn more about Amazon RDS in VPC, refer to the Amazon RDS User Guide. In addition, using Amazon RDS, you can configure firewall settings and control network access to your DB Instances.
Resource-Level Permissions
Amazon RDS provides you the ability to control the actions that your AWS IAM users and groups can take on specific Amazon RDS resources (e.g. DB Instances, DB Snapshots, DB Parameter Groups, DB Event Subscriptions, DB Options Groups). In addition, you can tag your RDS resources, and control the actions that your IAM users and groups can take on groups of resources that have the same tag (and tag value). For example, developers can modify "Development" DB Instances, but only Database Administrators can modify and delete "Production" DB Instances. For more information about Resource-Level Permissions, refer to Using AWS IAM with Amazon RDS Resources and Tagging Amazon RDS Resources.
DB Instance Classes
Amazon RDS currently supports the following DB Instance Classes:
Instance Type | vCPU | Memory (GiB) | PIOPS-Optimized | Network Performance |
Standard - current generation | ||||
db.m3.medium | 1 | 3.75 | - | Moderate |
db.m3.large | 2 | 7.5 | - | Moderate |
db.m3.xlarge | 4 | 15 | Yes | Moderate |
db.m3.2xlarge | 8 | 30 | Yes | High |
Memory optimized - current generation | ||||
db.r3.large | 2 | 15 | - | Moderate |
db.r3.xlarge | 4 | 30.5 | Yes | Moderate |
db.r3.2xlarge | 8 | 61 | Yes | High |
db.r3.4xlarge | 16 | 122 | Yes | High |
db.r3.8xlarge | 32 | 244 | - | 10 Gigabit |
Burstable performance instances | ||||
db.t2.micro | 1 | 1 | - | Low to Moderate |
db.t2.small | 1 | 2 | - | Low to Moderate |
db.t2.medium | 2 | 4 | - | Low to Moderate |
Looking for T1, M1, M2, or CR1 DB Instances? See the Previous Generation Instances page.
Working with Amazon RDS
Amazon RDS allows you to use the AWS Management Console or a simple set of web services APIs to create, delete and modify relational database instances (DB Instances). You can also control access and security for your DB Instance(s) and manage your database backups and snapshots. For a full list of the available Amazon RDS APIs, please see the Amazon RDS API Guide. Some of the most commonly used APIs and their functionality are listed below:
- Launch DB Instance — Provision a new DB Instance, specifying DB Engine, License Model, DB Instance class, storage capacity, DB Engine version (optional), the backup retention policy you wish to use, and whether you want to run the DB Instance as a Multi-AZ deployment. A few clicks on the AWS Management Console is all that’s needed to give you access to a running MySQL, Oracle, SQL Server, or PostgreSQL database engine, with the software pre-installed and the available resource capacity you request. For MySQL, you can also use create a Read Replica for a given source DB Instance deployment.
- Modify DB Instance — Modify settings for a running DB Instance. This functionality lets you scale the resources available to your DB Instance in response to the load on your database, or change how it is automatically backed up and maintained on your behalf, or convert your DB Instance to or from a Multi-AZ deployment. You can also use this functionality to gain optional control over minor version upgrades for your DB Instance – maintain compatibility with specific database versions, test new versions with your application before deploying in production, and perform version upgrades on your own terms and timelines.
- Take DB Snapshot — Generate a snapshot of your DB Instance. You can restore your DB Instance to these user-created snapshots at any point, even to reinstate a previously deleted DB Instance.
Restore To Point In Time — Create a new DB Instance from a point-in-time backup. You can restore to any point within the retention period you specified, usually up to the last five minutes of your database’s usage. - Delete DB Instance — Delete a running DB Instance. With Amazon RDS, you can terminate your DB Instance at any time and pay only for the resources you used.
For a brief explanation on how simple it is to get started using Amazon RDS, see AWS Evangelist Jeff Barr’s post announcing Amazon RDS. If you wish to run more than 40 DB Instances, please complete this form and we will promptly respond to your request.
Easily port your existing applications
If your application already relies on a MySQL, Oracle, SQL Server, or PostgreSQL database engine, porting to Amazon RDS is simple. Please refer to the following import guides for best practices:
- MySQL: Data Import Guide for MySQL
- Oracle: Data Import Guide for Oracle
- SQL Server: Data Import Guide for SQL Server
- PostgreSQL: Data Import Guide for PostgreSQL
Paying for What You Use
You will be charged at the end of each month for the Amazon RDS resources you actually consume. Once a DB Instance you have created is available for connection, you will be charged for each hour your DB Instance is running. Each DB Instance will run until termination, which occurs when you issue an API call to delete the DB Instance, or in the event of an instance failure. Partial DB Instance hours consumed are billed as full hours. In addition to DB Instance hours, you are also billed for your monthly storage, IO requests, and backups. If you scale your storage capacity within the billing period, your bill will be pro-rated accordingly.
Intended Usage and Restrictions
Your use of this service is subject to the Amazon Web Services Customer Agreement.
Amazon RDS for PostgreSQL
Amazon RDS makes it easy to set up, operate, and scale PostgreSQL deployments in the cloud. With Amazon RDS, you can deploy scalable PostgreSQL deployments in minutes with cost-efficient and resizable hardware capacity. Amazon RDS manages complex and time-consuming administrative tasks such as PostgreSQL software installation and upgrades, storage management, replication for high availability and back-ups for disaster recovery. With just a few clicks in the AWS Management Console, you can deploy a PostgreSQL database with automatically configured database parameters for optimal performance. Amazon RDS for PostgreSQL database instances can be provisioned with either standard storage or Provisioned IOPS storage. Once provisioned, you can scale from 5GB to 3TB of storage and from 1,000 IOPS to 30,000 IOPS.
Over the past few years, PostgreSQL has become the preferred open source relational database for many enterprise developers and start-ups, powering leading geospatial and mobile applications. Amazon RDS for PostgreSQL gives you access to the capabilities of a familiar PostgreSQL database engine. This means that the code, applications, and tools you already use today with your existing databases can be used with Amazon RDS.
Amazon RDS now offers new Memory Optimized DB Instances with better performance at lower cost
You can now take advantage of the R3 instance type with Amazon RDS. R3 instances are optimized for memory-intensive applications, have the lowest cost per GiB of RAM among Amazon RDS instance types, and are recommended for high performance database workloads. Learn more ?
Launch PostgreSQL with Multi-AZ for High Availability
You can deploy production PostgreSQL applications using the Multi-AZ deployment option for high availability, and Amazon RDS will operate a synchronous stand-by replica with an automated fail-over mechanism. Learn More.
Features
Easy, Managed Deployments
Amazon RDS for PostgreSQL is designed for developers or businesses who require the full features and capabilities of a PostgreSQL database, or who wish to migrate existing applications and tools that utilize a PostgreSQL database. Since Amazon RDS for PostgreSQL provides you direct access to familiar PostgreSQL database software running on your own Amazon RDS DB Instance, your applications should work seamlessly.
- Pre-configured Parameters – Amazon RDS for PostgreSQL deployments are pre-configured with a sensible set of parameters and settings appropriate for the DB Instance class you have selected. You can simply launch a PostgreSQL Instance and connect your application within minutes without additional configuration. If you desire additional control, you can achieve it via DB Parameter Groups.
- Monitoring and Metrics –Amazon RDS provides Amazon CloudWatch metrics for you DB Instance deployments at no additional charge. You can use the AWS Management Console to view key operational metrics for your DB Instance deployments, including compute/memory/storage capacity utilization, I/O activity, and DB Instance connections.
- DB Event Notifications –Amazon RDS provides Amazon SNS notifications via email or SMS for your DB Instance deployments. You can use the AWS Management Console or the Amazon RDS APIs to subscribe to over 40 different DB events associated with your Amazon RDS deployments.
- Automatic Software Patching – Amazon RDS will make sure that the PostgreSQL software powering your deployment stays up-to-date with the latest patches. You can exert optional control over when and if your DB Instance is patched via DB Engine Version Management.
Fast, Predictable Performance
- Provisioned IOPS – You can provision up to 3TB storage and 30,000 IOPS per database instance. For a workload with 50% writes and 50% reads running on a cr1.8xlarge instance, you can realize over 25,000 IOPS for PostgreSQL. However, by provisioning more than this limit, you may be able to achieve lower latency and higher throughput. Your actual realized IOPS may vary from the amount you provisioned based on your database workload, instance type, and database engine choice. Refer to the Factors That Affect Realized IOPS section of the Amazon RDS User Guide to learn more.
You can convert from standard storage to Provisioned IOPS storage and get consistent throughput and low I/O latencies. You will encounter a short availability impact when doing so. You can independently scale IOPS (in increments of 1000) and storage on-the-fly with zero downtime. The ratio of IOPS provisioned to the storage requested (in GB) should be between 3 and 10. For example, for a database instance with 1000 GB of storage, you can provision from 3,000 to 10,000 IOPS. You can scale the IOPS up or down depending on factors such as seasonal variability of traffic to your applications.
To learn more and get started with Amazon RDS Provisioned IOPS, please refer to the Working with Provisioned IOPS storage section of the Amazon RDS User Guide.
Backup & Recovery
- Automated Backups – Turned on by default, the automated backup feature of Amazon RDS enables point-in-time recovery for your DB Instance. Amazon RDS will backup your database and transaction logs and store both for a user-specified retention period. This allows you to restore your DB Instance to any second during your retention period, up to the last five minutes. Your automatic backup retention period can be configured to up to thirty five days.
- DB Snapshots – DB Snapshots are user-initiated backups of your DB Instance. These full database backups will be stored by Amazon RDS until you explicitly delete them. You can create a new DB Instance from a DB Snapshot whenever you desire. You can also copy DB Snapshots across AWS Regions for geographical migration or disaster recovery use cases.
Push-Button Scaling
- DB Instance Class – Using the Amazon RDS APIs or a few clicks of the AWS Management Console, you can scale the compute and memory resources powering your deployment up or down. Scaling operations typically complete within a handful of minutes.
- Storage and IOPS – As your storage requirements grow you can provision additional storage on-the-fly with zero downtime. If you are using RDS Provisioned IOPS, you can also scale the throughput of your DB Instance by specifying the IOPS rate from 1,000 IOPS to 30,000 IOPS in 1,000 IOPS increments and storage from 100GB and 3TB.
High Availability
- Multi-AZ Deployments – This deployment option for your production DB Instances enhances database availability while protecting your latest database updates against unplanned outages. When you create or modify your DB Instance to run as a Multi-AZ deployment, Amazon RDS will automatically provision and manage a “standby” replica in a different Availability Zone (independent infrastructure in a physically separate location). Database updates are made concurrently on the primary and standby resources to prevent replication lag. In the event of planned database maintenance, DB Instance failure, or an Availability Zone failure, Amazon RDS will automatically failover to the up-to-date standby so that database operations can resume quickly without administrative intervention. Prior to failover you cannot directly access the standby, and it cannot be used to serve read traffic.
Isolation and Security
Using Amazon VPC, you can isolate your DB Instances in your own virtual network, and connect to your existing IT infrastructure using industry-standard encrypted IPSec VPN. To learn more about Amazon RDS in VPC, refer to the Amazon RDS User Guide. In addition, using Amazon RDS, you can configure firewall settings and control network access to your DB Instances.
PostgreSQL Features Supported
- PostGIS – PostGIS is a spatial database extender for PostgreSQL object-relational database. It adds support for geographic objects allowing you to run location queries to be run in SQL.
- Language Extensions – PostgreSQL allows procedural languages to be loaded into the database through extensions. Three language extensions are included with PostgreSQL to support Perl, pgSQL and Tcl .
- Full Text Search Dictionaries – PostgreSQL supports Full Text Searching that provides the capability to identify natural-language documents that satisfy a query, and optionally to sort them by relevance to the query. Dictionaries, besides improving search quality, normalization and removal of stop words also improve performance of queries.
- HStore, JSON Data Types – PostgreSQL includes support for ‘JSON’ data type and two JSON functions. These allow return of JSON directly from the database server. PostgreSQL has an extension that implements the ‘hstore’ data type for storing sets of key/value pairs within a single PostgreSQL value.
- Core PostgreSQL engine features – For a detailed list of PostgreSQL core engine features, please refer here.