AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例
本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。
与 AWS SDK或RebootDBInstance
一起使用 CLI
以下代码示例演示如何使用 RebootDBInstance
。
- CLI
-
- AWS CLI
-
重启数据库实例
以下
reboot-db-instance
示例开始重启指定的数据库实例。aws rds reboot-db-instance \ --db-instance-identifier
test-mysql-instance
输出:
{ "DBInstance": { "DBInstanceIdentifier": "test-mysql-instance", "DBInstanceClass": "db.t3.micro", "Engine": "mysql", "DBInstanceStatus": "rebooting", "MasterUsername": "admin", "Endpoint": { "Address": "test-mysql-instance.############.us-west-2.rds.amazonaws.com", "Port": 3306, "HostedZoneId": "Z1PVIF0EXAMPLE" }, ... output omitted... } }
有关更多信息,请参阅 A mazon RDS 用户指南中的重启数据库实例。
-
有关API详细信息,请参阅ebootDBInstance《AWS CLI 命令参考》中的 R
。
-
- Java
-
- SDK适用于 Java 2.x
-
注意
还有更多相关信息 GitHub。查找完整示例,学习如何在 AWS 代码示例存储库
中进行设置和运行。 import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.rds.RdsClient; import software.amazon.awssdk.services.rds.model.RebootDbInstanceRequest; import software.amazon.awssdk.services.rds.model.RebootDbInstanceResponse; import software.amazon.awssdk.services.rds.model.RdsException; /** * Before running this Java V2 code example, set up your development * environment, including your credentials. * * For more information, see the following documentation topic: * * https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/get-started.html */ public class RebootDBInstance { public static void main(String[] args) { final String usage = """ Usage: <dbInstanceIdentifier>\s Where: dbInstanceIdentifier - The database instance identifier\s """; if (args.length != 1) { System.out.println(usage); System.exit(1); } String dbInstanceIdentifier = args[0]; Region region = Region.US_WEST_2; RdsClient rdsClient = RdsClient.builder() .region(region) .build(); rebootInstance(rdsClient, dbInstanceIdentifier); rdsClient.close(); } public static void rebootInstance(RdsClient rdsClient, String dbInstanceIdentifier) { try { RebootDbInstanceRequest rebootDbInstanceRequest = RebootDbInstanceRequest.builder() .dbInstanceIdentifier(dbInstanceIdentifier) .build(); RebootDbInstanceResponse instanceResponse = rdsClient.rebootDBInstance(rebootDbInstanceRequest); System.out.print("The database " + instanceResponse.dbInstance().dbInstanceArn() + " was rebooted"); } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } } }
-
有关API详细信息,请参阅ebootDBInstance《AWS SDK for Java 2.x API参考资料》中的 R。
-
ModifyDBParameterGroup
场景