Complete a 3 Question Survey and Earn a re:Post Badge
Help improve AWS Support Official channel in re:Post and share your experience - complete a quick three-question survey to earn a re:Post badge!
Come posso utilizzare Amazon RDS Proxy per connettermi alla mia istanza database Amazon RDS per MySQL o al mio cluster di database Aurora compatibile con MySQL?
Desidero utilizzare il proxy Amazon Relational Database Service (Amazon RDS) per connettermi alla mia istanza database Amazon RDS per MySQL o al mio cluster di database Amazon Aurora Edition compatibile con MySQL.
Risoluzione
Prerequisito: il proxy deve trovarsi nello stesso cloud privato virtuale (VPC) del database. È possibile rendere il database accessibile al pubblico, ma il proxy non può essere accessibile pubblicamente.
Crea il proxy e connettilo alla tua istanza database
Completa i seguenti passaggi:
-
Crea le credenziali del database in AWS Secrets Manager.
Nota: quando crei il segreto, utilizza lo stesso nome utente e password del tuo database. -
(Facoltativo) Crea una policy di AWS Identity and Access Management (IAM) e un ruolo IAM.
Nota: Amazon RDS Proxy crea automaticamente un ruolo IAM. Tuttavia, puoi creare il tuo ruolo IAM. -
Esegui il seguente comando per verificare se l'endpoint proxy è raggiungibile:
nc -zv proxy_endpoint 3306
Nota: sostituisci proxy_endpoint con l'indirizzo del tuo server proxy. Esegui il comando precedente solo su una macchina Amazon Elastic Compute Cloud (Amazon EC2) che si trova nello stesso VPC del proxy. Il comando non viene eseguito su computer locali.
Esempio di output:Connection to test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com 3306 port [tcp/mysql] succeeded
-
Esegui il seguente comando per utilizzare il proxy per connetterti all'istanza database RDS:
mysql -h proxy_endpoint -u username -p
Nota: sostituisci proxy_endpoint con l'indirizzo del tuo server proxy.
Esempio di output:Server version: 5.7.28-log Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
(Facoltativo) Utilizza il proxy con una connessione TLS/SSL
Completa i seguenti passaggi:
-
Quando crei il proxy, attiva Richiede Transport Layer Security. Puoi anche modificare un proxy esistente.
Nota: quando utilizzi un protocollo TLS/SSL, il proxy rifiuta le connessioni in chiaro. -
Scarica il file .pem del trustore Amazon Root CA 1 da Amazon Trust Services:
wget https://www.amazontrust.com/repository/AmazonRootCA1.pem
-
Esegui il seguente comando per utilizzare TLS/SSL per connetterti all'istanza database:
mysql -h test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=REQUIRED --ssl-ca=AmazonRootCA1.pem -p
Oppure, per connetterti all'istanza database, puoi eseguire il seguente comando con la modalità TLS/SSL VERIFY_IDENTITY:
mysql -h test-proxy.proxy-#############.eu-west-1.rds.amazonaws.com -u admin --ssl-mode=VERIFY_IDENTITY --ssl-ca=AmazonRootCA1.pem -p
Nota: il proxy utilizza certificati wildcard. Se utilizzi il client MySQL per connetterti con la modalità TLS/SSL VERIFY_IDENTITY, è necessario utilizzare il comando mysql compatibile con MySQL 8.0.
Esempio di output:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 12659040 Server version: 5.7.28-log Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
Informazioni correlate
Video correlati

