临时停止Amazon RDS数据库实例 [英] Stopping an Amazon RDS DB Instance Temporarily

查看:81
本文介绍了临时停止Amazon RDS数据库实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在AWS中创建每天自动启动/停止数据库的cron作业?

Is there a way to create a cron job in AWS that automatically starts / stops the DB everyday ?

推荐答案

您可以使用 AWS Lambda计划的事件,以使用适用于RDS的AWS开发工具包启动和停止RDS服务器编写代码.您可以使用 startDBInstance stopDBInstance 方法.以下示例显示了如何使用适用于NodeJS的AWS开发工具包停止数据库实例.

You can use AWS Lambda Scheduled Events to start and stop the RDS Server writing code using AWS SDK for RDS. You can use startDBInstance and stopDBInstance methods. Following example shows how to stop the DB instance using AWS SDK for NodeJS.

var params = {
  DBInstanceIdentifier: 'STRING_VALUE', /* required */
  DBSnapshotIdentifier: 'STRING_VALUE'
};
rds.stopDBInstance(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});

这篇关于临时停止Amazon RDS数据库实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆