<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Megha Gupta on Medium]]></title>
        <description><![CDATA[Stories by Megha Gupta on Medium]]></description>
        <link>https://medium.com/@gupta.megha?source=rss-820aeabfec2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*SeX8MNXJ3W9fjCLSq6j59g.png</url>
            <title>Stories by Megha Gupta on Medium</title>
            <link>https://medium.com/@gupta.megha?source=rss-820aeabfec2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 00:47:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@gupta.megha/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[AWS RDS Blue/Green Deployment]]></title>
            <link>https://medium.com/@gupta.megha/aws-rds-blue-green-deployment-3751e6f8884f?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/3751e6f8884f</guid>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[blue-green-deployment]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Tue, 14 Feb 2023 22:02:35 GMT</pubDate>
            <atom:updated>2023-02-14T22:02:35.608Z</atom:updated>
            <content:encoded><![CDATA[<p>What is Blue/Green Deployment?</p><p>A blue/green deployment is a deployment strategy in which you create two separate, but identical environments. One environment (blue) is running the current application version and one environment (green) is running the new application version. Using a blue/green deployment strategy increases application availability and reduces deployment risk by simplifying the rollback process if a deployment fails. Once testing has been completed on the green environment, live application traffic is directed to the green environment and the blue environment is deprecated.</p><p>AWS recently launched the blue/green deployment functionality in RDS. Currently the feature is available with RDS MySQL and Aurora for MySQL. Its recommended to use this with InnoDB storage engine as the blue/green deployment isn’t optimized for MyISAM.</p><p>Benefits of blue/green deployment:</p><p>This feature has been out for few months and I have already used it for multiple customers who were running MySQL 5.6 and needed to upgrade to MySQL 5.7 due to AWS stopping support for MySQL 5.6 by Feb 28th 2023. There are many benefits to using this feature:</p><ul><li>Dramatically reduces application downtime.</li><li>Easily and quickly create staging environments.</li><li>Test changes in staging environment before making it production.</li><li>Switch over to staging is very fast and without any data loss if planned properly.</li><li>One of the most coolest benefits is — no endpoint change after the switchover. Yes, you heard it right! With this feature you do not have to worry about changing the DNS and changing your application connection configuration.</li></ul><p>NOTE: Blue/green deployments are currently not support for cross-region replicas. Multi-AZ is supported. Currently there is no support for Cloudformation as well.</p><p>Overview of Blue/green architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lZ7ZEhXgFb66o0jVBOOxDw.png" /></figure><p>Steps to implement blue/green deployment:</p><p><strong>Step 1: Enable Binary logging</strong></p><p>The very first step you will have to perform is to enable binary logging if not already enbaled as that is what it uses to capture changes in your Blue deployment to replicate it to the Green deployment.</p><p>I have already created a test cluster and created custom DB Cluster Group and DB Parameter Group. You cannot edit the default DB Cluster Group and DB Parameter Group.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1ZYJQP56PjVDKdeVVMdrw.png" /></figure><p>Once you have created the Custom DB cluster parameter group and the DB instance Parameter group, attach it to your Aurora cluster.</p><pre>aws rds modify-db-cluster \<br>--db-cluster-identifier test-aurora-cluster \<br>--db-cluster-parameter-group-name custom-aurora-parameter-group \<br>--db-instance-parameter-group-name custom-aurora-db-group \<br>--apply-immediately</pre><p>Edit the DB Cluster Parameter Group to set binlog_format from OFF to ROW</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UZqg9_DeWaQ5IeQLvuhIlg.png" /></figure><p>Reboot the Cluster after the DB cluster group and instance parameter groups have been modified.</p><p><strong>Step 2: Create the Blue/Green Deployment</strong></p><p>Select the Aurora Cluster that you want to create a Blue/Green deployment for and in the Actions drop down select ‘create blue/green deployment — new’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*v2cKlpbhjUnOSFwtpHYh7g.png" /></figure><p><strong>NOTE</strong>: if you are using Secrets Manager to manage your master password, you will have to disable that as Blue/Green deployments does not support Secrets Manager as of yet.</p><p>Choose a name for your Blue/Green identifier and the engine version. My blue environment was 5.6 and I am creating a green deployment of 5.7 to upgrade.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/889/1*GiGGLmJAfdWWAAPQ_tt0JA.png" /></figure><p>While the Green Cluster is getting created, you will see something like this:</p><p>The existing environment is nicely labeled as ‘Blue’ and the new staging environment is labeled as ‘Green’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hZsMBkgYF2xRzvS01eH3zg.png" /></figure><p>Once Green cluster is fully provisioned, you can see this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QX-076DmLP8NnR10jikBpQ.png" /></figure><p>Step 3: Compare Blue/Green Database Parameters</p><p>There is considerable amount of difference between MySQL 5.6 and 5.7. Make sure you compare the DB parameters and add any custom variables in the MySQL 5.7 that are present in your 5.6 deployment parameter group before you look into making the green deployment as production.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*cKGwr37IDz1BI7xfIgu5zw.png" /></figure><p>Step 4: Switchover to Green Cluster</p><p>Before we can switchover to the green cluster, we need to check and make sure that the newly created staging cluster is all caught up with changes these are called switchover guardrails.</p><ul><li>Make sure that you can connect to green environment</li><li>Check for data consistency</li><li>Verify the ReplicaLag in CloudWatch to make sure Green environment is all caught up with changes</li><li>Stop all the database connections to Blue environment so there are no new writes happening to the database during switchover</li><li>Do the failover at a time when there is least traffic to the application</li></ul><p>To failover, select the blue/green deployment and select ‘Switch over’ from the Actions drop down.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gNzKgciknm6-SFrSRKW6rw.png" /></figure><p>After switching over, you will see the status of Blue/Green deployment changing from being available to ‘Switching over’</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zOXRbzXKkaqN3lnVDfVVvw.png" /></figure><p>Depending on how large your database is — it can take anywhere from 5 minutes to 15 minutes for the failover to take place.</p><p>In my test environment, it was almost instant. After the switchover, the blue cluster is labeled as ‘old’ and green environment looks exactly like the Blue environment was. In the screenshot, the top part is the Green deployment. The endpoint of the writer and reader remains exactly same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wMQXpQktOQ1GmGEpCqU6Ew.png" /></figure><p>You can delete the Blue/green deployment after everything has been verified. I typically stop the blue/green deployment and leave it for few days before deleting it.</p><p>This concludes a use case scenario to use Blue/green deployment.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3751e6f8884f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automate AWS RDS stop start]]></title>
            <link>https://medium.com/@gupta.megha/how-to-automate-rds-stop-start-1e8b0bbf56cb?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e8b0bbf56cb</guid>
            <category><![CDATA[aws-rds]]></category>
            <category><![CDATA[aws-system-manager]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Tue, 17 Jan 2023 03:50:35 GMT</pubDate>
            <atom:updated>2023-01-17T03:57:31.502Z</atom:updated>
            <content:encoded><![CDATA[<p>Forgetting your resources after spinning them for testing? Been there, done that! And then we see the AWS bill and think why I forgot to stop my test RDS instance. Your customers might also be looking to stop the DEV/TEST type instances during the off hours or weekend to save some cost.</p><p>Once an RDS instance is stopped, it starts automatically after 7 days. There are some other limitations like a Read replica cannot be stopped and RDS for SQL Server in a Multi-AZ configuration cannot be stopped either.</p><p>So how do we get around that if we want to save cost? There are multiple ways you can automatically stop the RDS instance/s. You can use Lambda and Event Bridge to automatically stop your RDS instances when not used. There is another method which is using AWS System Manager runbook and that’s the method I have used extensively in my customer’s environment.</p><h4><strong>AWS System Manager runbook automation</strong></h4><p>AWS Systems Manager provides automation runbook to automatically stop/start an Amazon RDS DB instance using System Manager Maintenance Window. It provides ‘AWS-StopRdsInstance’ and ‘AWS-StartRdsInstance’ runbooks to stop and start RDS DB instances. That means you do not have to write any custom code with AWS Lambda functions or Event Bridge rules.</p><p>Before we begin, we need to create an IAM role with an inline policy to allow SSM access to RDS instances.</p><h4>Step 1: Create an IAM role to allow SSM access to RDS instance</h4><ul><li>On the IAM console, under Access Management, click Roles and select create role</li><li>Under Trusted Entity Type, select AWS services and under common use cases, select Systems Manager. Click Systems Manager to allow SSM to call other services and click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*4pHjivQFmZ_-pjvCW8CqjA.png" /></figure><ul><li>Under Add Permissions, search for AmazonSSMAutomationRole, select it and click Next</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*i5MbjNqovgqBnLp6Nx505g.png" /></figure><ul><li>Name the role as ‘StopStartRDSAutomationRole’ and create Role</li></ul><h4>Step 2: Create an inline policy to SSM to call RDS</h4><ul><li>Select the role we created in the first step and select Add Permissions -&gt; Create inline policy</li><li>Use the following JSON to create an inline policy:</li></ul><pre>{<br>  &quot;Version&quot;: &quot;2012–10–17&quot;,<br>  &quot;Statement&quot;: [<br>  {<br>    &quot;Sid&quot;: &quot;RdsStartStop&quot;,<br>    &quot;Effect&quot;: &quot;Allow&quot;,<br>    &quot;Action&quot;: [<br>        &quot;rds:StopDBInstance&quot;,<br>        &quot;rds:StartDBInstance&quot;<br>      ],<br>  &quot;Resource&quot;: &quot;arn:aws:rds:&lt;your_region&gt;:&lt;your_account_number&gt;:db:*&quot;<br>  },<br>  {<br>    &quot;Sid&quot;: &quot;RdsDescribe&quot;,<br>    &quot;Effect&quot;: &quot;Allow&quot;,<br>    &quot;Action&quot;: &quot;rds:DescribeDBInstances&quot;,<br>    &quot;Resource&quot;: &quot;*&quot;<br>  }<br>]<br>}</pre><ul><li>Click Review Policy and Save changes</li></ul><h4>Step 3: Use State Manager to Stop RDS instances</h4><ul><li>Browse to AWS Systems Manager and select ‘State Manager’ from the left navigation pane. Select ‘Create Association. Provide a name for the association like ‘stoprdsinstance’</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*zAdmOA7BIobQxOkqkl-a8w.png" /></figure><ul><li>Under Document, find the AWS-StopRdsInstance automation document and select the document</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*0T80kuxs03jkIYzbuFsttg.png" /></figure><ul><li>Under Execution, choose rate control. In most cases you would want this automation to be applied to multiple RDS instance. If that’s not the case, and you only want to apply it to a single instance, then you can use simple execution. I am using Rate Control as I like to apply this to multiple instances.</li><li>Under Targets, choose InstanceId as parameter and choose Tags as your targets. I have created a Tag with Key=AutoOff and Value=True for all the instances I would like to automatically stop.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*igCyY_V2xIqr0OUc88_cOw.png" /></figure><ul><li>Under Input Parameters, choose the Role we created in step 1 and specify a schedule when you would like this automation to run. I selected Daily at 00:00.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LInAsfS7QsfrSO39H2BLgA.png" /></figure><ul><li>Specify the Rate Control. For Concurrency choose 100% which means all the instances will be stop simultaneously which has the specific tag and for Errors also choose 100% which means all the errors will be ignored.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*LInAsfS7QsfrSO39H2BLgA.png" /></figure><ul><li>Click create association</li></ul><h4>Step 4: View the execution history and details</h4><p>Once the Automation has run, you can come back and check the execution history. Check resources that were stopped as part of this association.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*rz3a3Y3Z-rkuK7UaAVcqgA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*OB8OHunqZ7WxPESjBIiuzw.png" /></figure><h4>Step 5: Start RDS instances using State Manager</h4><p>Similar to Stopped RDS instance, you can start RDS instances as well automatically using the AWS System Manager runbook ‘AWS-StartRdsInstance’. For this I am using tag with Key=AutoOff and Value=False</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*nmw14PVlQuDasSY3gHqYtg.png" /></figure><ul><li>Use the same role we created and set up a schedule according to your requirements</li><li>Under rate control, choose 100% for concurrency and error and select Create association</li></ul><h4>Conclusion</h4><p>AWS Systems Manager runbook automation provides a quick easy way to stop/start RDS instances automatically while keeping the cost under control specially for Dev/Test type of RDS instances.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e8b0bbf56cb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Export/Import RDS Oracle Database using Oracle Data Pump]]></title>
            <link>https://medium.com/@gupta.megha/export-import-rds-oracle-database-using-oracle-data-pump-53c7d60d074e?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/53c7d60d074e</guid>
            <category><![CDATA[oracle-database]]></category>
            <category><![CDATA[aws-rds-oracle]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 20:50:38 GMT</pubDate>
            <atom:updated>2022-10-18T14:31:19.395Z</atom:updated>
            <content:encoded><![CDATA[<p>One of the recent requests from a customer was to export their Production Oracle RDS Enterprise Edition to a Development Oracle RDS Standard Edition. For this I used Data Pump to do the export/import. You might ask, why not just use RDS Snapshots? RDS Snapshots is not supported between the editions in Oracle and that’s why you must use export/import method.</p><p><strong>Overview of the solution</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/922/1*9YACTUnrpeAVBL7oQYf67Q.png" /></figure><p>Data Pump is a native Oracle utility to export and import data or the entire schema. This utility has been slightly changed in RDS in terms of its usage.</p><p><strong>Pre-requisites</strong></p><ul><li>Oracle RDS EE is already created and running</li><li>Oracle RDS SE is already created and running</li><li>IAM role and Security group is set up for both RDS instances</li><li>S3 bucket for housing the export is already set up</li><li>S3 integration with both RDS instances has been established</li><li>EC2 instance that we will be using as a Bastion to run SQLPlus. Oracle client is already installed and configured.</li><li>The Security Groups are all set up correctly between EC2 and both the RDS instances</li></ul><p>Let’s get started with steps on how to export Oracle schema using Data Pump in RDS:</p><p><strong>STEP 1: Create the export job</strong></p><p>Once connected to the RDS instance using the master account, run the following PL/SQL:</p><pre>DECLARE</pre><pre>v_hdnl NUMBER;</pre><pre>BEGIN</pre><pre>v_hdnl := DBMS_DATAPUMP.OPEN(<br>operation =&gt; ‘EXPORT’, <br>job_mode =&gt; ‘SCHEMA’, <br>job_name=&gt;null);</pre><pre>DBMS_DATAPUMP.ADD_FILE(<br>handle =&gt; v_hdnl, <br>filename =&gt; ‘<em>dump_filename</em>.dmp’, <br>directory =&gt; ‘DATA_PUMP_DIR’, <br>filetype =&gt; dbms_datapump.ku$_file_type_dump_file);</pre><pre>DBMS_DATAPUMP.ADD_FILE(<br>handle =&gt; v_hdnl, <br>filename =&gt; ‘<em>dump_logfilename</em>.log’, <br>directory =&gt; ‘DATA_PUMP_DIR’, <br>filetype =&gt; dbms_datapump.ku$_file_type_log_file);</pre><pre>DBMS_DATAPUMP.METADATA_FILTER(v_hdnl,’SCHEMA_EXPR’,’IN (‘’<em>SCHEMANAME</em>’’)’);</pre><pre>DBMS_DATAPUMP.METADATA_FILTER(v_hdnl,’EXCLUDE_NAME_EXPR’, <br>q’[IN (SELECT NAME FROM sys.OBJ$ WHERE TYPE# IN (66,67,74,79,59,62,46) AND OWNER# IN <br>(SELECT USER# FROM SYS.USER$ WHERE NAME IN (‘RDSADMIN’,’SYS’,’SYSTEM’,’RDS_DATAGUARD’,’RDSSEC’)))]’,’PROCOBJ’);</pre><pre>DBMS_DATAPUMP.START_JOB(v_hdnl);</pre><pre>END;</pre><pre>/</pre><p>Where,</p><ul><li>SCHEMANAME is the schema you want to export</li><li>Dump_filename is the name of the Dump file you want to create</li><li>Dump_Logfilename is the name of the log file</li></ul><p>The DATA_PUMP_DIR is the file system that RDS has allocated for storing the dumpfile. As far as I know, there is no limit on the file size. I have successfully dumped a multi terabyte database without the DATA_PUMP_DIR to run out of disk space. To view the actual location (if you are interested), you can query the following table:</p><pre>set linesize 180<br>column owner format a20<br>column directory_name format a40<br>column directory_path format a50</pre><pre>select owner, directory_name, directory_path from dba_directories where directory_name=‘DATA_PUMP_DIR’;</pre><p><strong>STEP 2: Check the status of the job</strong></p><p>There are multiple ways to check the state of the job:</p><p>1. Check the Data Pump directory size using the following query — you will see a dump file when you query the data_pump_dir table</p><pre>SELECT * FROM TABLE(RDSADMIN.RDS_FILE_UTIL.LISTDIR(‘DATA_PUMP_DIR’)) ORDER by mtime;</pre><p>2. Check the dba_datapump_jobs table for Data Pump executing jobs</p><pre>SELECT owner_name, job_name, state from dba_datapump_jobs where state=’EXECUTING’;</pre><p>The above will give an output of all the data pump jobs that are currently executing.</p><p><strong>STEP 3: Upload the dump file to the S3 bucket</strong></p><pre>SELECT rdsadmin.rdsadmin_s3_tasks.upload_to_s3(<br>              p_bucket_name    =&gt; ‘mys3bucket’, <br>              p_prefix         =&gt; &#39;dump_&#39;, <br>              p_s3_prefix      =&gt; &#39;&#39;, <br>              p_directory_name =&gt; ‘DATA_PUMP_DIR’) <br>AS TASK_ID FROM DUAL;</pre><p>Note: The AWS console can be used to point and click for the upload to the S3 bucket.</p><p>I have used prefix here to upload all files in the DATA_PUMP_DIR that start with ‘dump_*’ to upload the log file as well. A lot of time the materialized views do not get exported by the Datapump. Take note of the objects that were missed and create them manually.</p><p><strong>STEP 4: Copy the dump file from S3 to the data pump directory of the RDS instance</strong></p><p>Login to the SE RDS instance and upload the dump from S3</p><pre>SELECT rdsadmin.rdsadmin_s3_tasks.download_from_s3 (p_bucket_name =&gt; ‘mys3bucket’, p_directory_name =&gt; ‘DATA_PUMP_DIR’) AS TASK_ID FROM DUAL;</pre><p><strong>STEP 5: Verify the file has been uploaded by checking the task id</strong></p><p>Copy the task id from the previous step and paste it in the following SQL:</p><pre>SELECT text from table(rdsadmin.rds_file_util.read_text_file(‘BDUMP’ , ‘dbtask-1663788182757–49.log’));</pre><p>NOTE: Replace the task id with your task id.</p><p><strong>STEP 6: Create the schema user in the target database</strong></p><p>We need to create the schema in which we will load the import. You can export just the schema from the source database to recreate it on the target instance.</p><pre>CREATE USER <em>schema</em> IDENTIFIED BY <em>password</em>;</pre><pre>GRANT CREATE SESSION, RESOURCE TO schema;</pre><pre>ALTER USER schema QUOTA 100M ON users;</pre><p><strong>STEP 7: Import the dump file into the target database</strong></p><p>Replace the dumpfilename.dmp with the .dmp file you have uploaded in the DATA_PUMP_DIR</p><pre>DECLARE</pre><pre>hdnl NUMBER;</pre><pre>BEGIN</pre><pre>hdnl:= DBMS_DATAPUMP.OPEN( <br>operation =&gt; ‘IMPORT’, <br>job_mode =&gt; ‘SCHEMA’, <br>job_name=&gt;null);</pre><pre>DBMS_DATAPUMP.ADD_FILE( <br>handle =&gt; hdnl, <br>filename =&gt; ‘dump_filename.dmp’, <br>directory =&gt; ‘DATA_PUMP_DIR’, <br>filetype =&gt; dbms_datapump.ku$_file_type_dump_file);</pre><pre>DBMS_DATAPUMP.METADATA_FILTER(hdnl,’SCHEMA_EXPR’,’IN (‘’ADMIN’’)’);</pre><pre>DBMS_DATAPUMP.START_JOB(hdnl);</pre><pre>END;</pre><pre>/</pre><p><strong>STEP 8: Verify the data in the schema</strong></p><p>We need to make sure all the objects between both the RDS instances looks same. Sometimes Data Pump can cause issues with copying views.</p><pre>SELECT COUNT(*) FROM DBA_TABLES WHERE OWNER=’<em>SAMPLE_SCHEMA</em>&#39;;</pre><p><strong>STEP 9: Cleanup</strong></p><p>Cleanup the DATA_PUMP_DIR by removing the dump file that you uploaded.</p><pre>SELECT * FROM TABLE(rdsadmin.rds_file_util.listdir(‘DATA_PUMP_DIR’)) ORDER BY MTIME;</pre><pre>EXEC UTL_FILE.FREMOVE(‘DATA_PUMP_DIR’ , ‘<em>&lt;file name&gt;</em>’);</pre><p><strong>Conclusion</strong></p><p>The above method provides a way to restore Oracle Enterprise Edition schema to Oracle Standard Edition. A lot of companies do not want to run Enterprise Edition software for their DEV/TEST environments and Data pump gives the ability to run Standard edition in lower environments.</p><p><strong>Updated by Megha Gupta| on SEPTEMBER 27, 2022</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53c7d60d074e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Glue]]></title>
            <link>https://medium.com/@gupta.megha/aws-glue-bb1229b4c01?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb1229b4c01</guid>
            <category><![CDATA[aws-glue-crawler]]></category>
            <category><![CDATA[aws-glue]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Tue, 27 Sep 2022 19:47:51 GMT</pubDate>
            <atom:updated>2022-10-12T17:25:22.876Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/163/1*5c0tSz-zOCnhCYR7e6mfOA.png" /></figure><p>AWS Glue is a fully managed ETL (Extract, Transform and Load) service. It categorizes your data, clean it, enrich it, and move it reliably between various data stores. Once catalogued, your data is immediately searchable and queryable across your data silos.</p><p>With organizations dealing with explosion of data, Glue and Glue crawlers comes handy in analyzing this massive influx of data.</p><p>What kind of data are we talking about?</p><ul><li>Structured data — data that is highly normalized with common schema and stored in relation databases of the likes — MySQL, Oracle, Microsoft SQL Server, PostgreSQL, etc.</li><li>Semi-structured data — Data that contain identifiers without conforming to a predefined schema (where schema is built-in, or it is implicit to the data)</li><li>Unstructured data — Data that does not conform to a data model and are typically stored as individual files — emails, audio files, video files, images, etc.</li></ul><p><strong>AWS Glue: The big picture</strong></p><p>This is a quick overview of how a data lake looks like in AWS.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*XmgGgT8ElHWeKz09CY6Psg.png" /></figure><p><strong>AWS Glue components</strong></p><ul><li>Data/Glue Catalog — Discover and organize your data.</li><li>Job Authoring — Writing transformations which will transform the data</li><li>Job Execution — Actually executing the job. Glue runs jobs in Spark containers</li></ul><p>I am working with customers to utilize AWS Glue and Glue Crawlers to extract and sanitize the data stored in S3 and run data visualizations against it.</p><p><strong>Customer requirement:</strong></p><ul><li>Customer was running legacy data on MS SQL 2008 on-prem</li><li>The data was only needed for reporting purposes</li><li>Needed a solution that could be developed quickly</li></ul><p>Me and my team suggested the solution to utilize S3 to act as a data lake to store the MS SQL data files.</p><p>Once the data was in S3, that’s when you get to have fun with it. You can query this data using Redshift, Athena, do analytics, Build Dashboards.</p><p><strong>Here is the architecture of what was implemented for the customer:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/975/1*tCvS_-PuhTsMDBsyYCCQpQ.png" /></figure><p>In the center of this architecture is the Amazon S3 service acting as a data lake. The data is brought into S3 and from there on its extracted, queried, sanitized, analyzed and consumed.</p><p>Glue Crawler is the star of the show in the architecture. The crawler extracts the schema and create the metadata table inside the glue data catalog. Glue data catalog is the metadata store. But the part that is super important is the creation of schema inside the Glue data catalog and that’s where crawlers play a big role.</p><p><strong>What does AWS Glue Crawler does?</strong></p><ul><li>A crawler accesses your data store, extracts metadata and created table definitions in the AWS Glue Data Catalog</li><li>It creates and manage AWS Glue Table Schema</li><li>It manages partitions of the AWS Glue tables</li></ul><p>It’s important to organize and store data in S3 buckets under subfolders — called prefixes inside those buckets. If this step is missed, Glue crawler will not be able to extract this data into separate tables.</p><p>Once the Glue Crawlers create the table schema, we were able to query the data using AWS Athena using custom queries.</p><p><strong>How do we go about scheduling this?</strong></p><p>The Glue job scheduling system allows users to automate ETL pipelines by creating and executing schedule or event-based jobs triggering. It also allows chaining ETL pipelines.</p><p><strong>Usage and Pricing</strong></p><ul><li>With Glue, you only pay for the time your ETL job takes to run. There are no resources to manage and upfront costs since its all serverless.</li><li>You are charged an hourly rate based on number of Data Processing Units used to run your ETL job.</li><li>You are billed per hour in increments or 1 minute, rounded up to the nearest minute, with a 10-minute minimum duration of each job</li></ul><p><strong>Conclusion</strong></p><p>In this article we explored how raw data in S3 buckets can be extracted and transformed using AWS Glue Data Catalog. The data can then be queried using Athena or visualized using QuickSight. This will really help companies make sense of their raw data effectively and efficiently.</p><p><strong>Updated by Megha Gupta | on SEPTEMBER 27, 2022</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb1229b4c01" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Send Microsoft SQL Server backups hosted on EC2 to Amazon S3]]></title>
            <link>https://medium.com/@gupta.megha/send-microsoft-sql-server-backups-to-amazon-s3-cc2d6089ddfb?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/cc2d6089ddfb</guid>
            <category><![CDATA[amazon-s3]]></category>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[rds]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 18:55:53 GMT</pubDate>
            <atom:updated>2022-11-29T23:29:01.299Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/739/1*gpx1SJg_cdRr_MgKrMj65A.png" /></figure><p>I was recently asked by a customer of ours to set up SQL native backups to S3 for long term storage. When talking about SQL Server in AWS there are two ways to host your SQL Server database instance, one is off course the managed AWS RDS solution and other one is hosting your SQL Server database on EC2 instance.</p><p>In both the methods, you can take native Microsoft SQL Server backups and sync it to S3. You might ask why S3 for storing my backups? S3 is secure, durable, and highly available backup storage. With some fine-grained Life Cycle management your company can meet compliance of keeping your data for many years. Its fast to recover from S3. Long term storage is available via transitioning your backups to AWS Glacier.</p><p>There are multiple ways to sync/send native backups of SQL Server to S3.</p><p><strong>Some of the options are:</strong></p><ul><li><em>Map S3 bucket to EC2 instance as a drive</em></li></ul><p>This method lets you map a S3 bucket as a drive to your EC2 instance so you can send native SQL backups directly to that drive. This feature is currently not available within EC2 or SQL server because S3 is object storage and for taking backups to drive, we need block storage. Having said that there are many 3rd party tools like TNTDRIVE, CloudBerry that can help facilitate this. I have used TNTDRIVE successfully and will be talking about the steps in the next section of this article.</p><ul><li><em>Write to EBS and sync it with S3</em></li></ul><p>This method is essentially a two-step approach. You must first take the backup to the EBS volume and then use AWS CLI sync command to sync the backups to S3.</p><p>It’s important that when sizing your EBS volume, it needs to be at least the size of your biggest database backup (with some room for growth). If this is the size you choose, bear in mind you can only back up one database at a time. If you size the drive bigger, you can back up more databases in the same job before syncing with S3 however this will be more expensive. With EBS, you pay for the size of the volume allocated, not just what is used. This is different to S3 where you only pay for data stored.</p><ul><li><em>Write directly to S3</em></li></ul><p>At the time of writing this article, writing directly is doable with some 3rd party tools like LiteSpeed. Quest LiteSpeed in combination with SQL Server Enterprise Edition can write SQL Server backups directly to S3.</p><p>Currently this feature is not available natively to SQL Server.</p><p>SQL Server 2022 is introducing native integration with S3 object storage. I am excited to see this feature in action. You can find more information on this here:</p><p><a href="https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backup-">https://docs.microsoft.com/en-us/sql/relational-databases/backup-restore/sql-server-backu</a>p-and-restore-with-s3-compatible-object-storage?view=sql-server-ver16</p><ul><li><em>Using File gateway/storage gateway</em></li></ul><p>Storage Gateway is a hybrid cloud storage service providing on-premises applications with access to virtually unlimited cloud storage. This can be a great solution for companies that have huge on-prem SQL Server databases and want to reduce the cost and their storage footprint by sending backups to S3 or use it as their DR strategy.</p><p>Back to the customer ask. The customer that I was working with had a very specific requirement on retention of the backups stored in S3. I used the method to map S3 bucket to EC2 instance as a drive to send backups to S3.</p><p>First off, I want to thank my friend and colleague <strong>Jeremy</strong> <strong>Sand</strong>, who helped me navigate through some advanced areas of Microsoft SQL Server. He is our inhouse expert on anything SQL Server.</p><p>Here are the customer requirements for database backup retention:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/556/1*ZO-wpznbUJoK5nyppw47xQ.png" /></figure><p>Let’s do a deep dive on this solution and how to go about setting it up.</p><h4><strong>Map S3 bucket as a drive on EC2 instance</strong></h4><p>There are many 3rd tools to facilitate this, but I used TNTDRIVE to map my S3 bucket as a drive on the SQL Server EC2 instance.</p><p><a href="https://urldefense.com/v3/__https:/tntdrive.com/__;!!HUqgN_M!-ur1uCLsVmRC28H1ZbpKh_xwnGrb6sFAcpEl6zSabLTzbimov_H0I7ISC_GEeGdx$">https://tntdrive.com/</a></p><p><strong>NOTE</strong>: This is not a paid advertisement of TNTDRIVE. I just happen to use this product for some of our customers and it’s working well for them. Its not a free product.</p><p>I am assuming that you already have a Microsoft SQL Server instance up and running as an EC2 instance.</p><p>These are the overall steps we need to take to map the S3 drive:</p><ol><li>Install TNTDRIVE on SQL Server</li><li>Install AWS CLI</li><li>Create an IAM role with SSM and S3 full access and attach that to SQL Server</li><li>Reboot SQL Server</li><li>Create S3 buckets</li><li>Map S3 bucket as Drive</li><li>Set up scripts in SSMS to send backups to S3</li><li>Create S3 lifecycle policies</li></ol><p>Lets go into detail into each step now.</p><p><strong>Step 1: Install TNTDRIVE</strong></p><p>Download the TNTDRIVE software and run the installer as administrator</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*ZelTK7o1KHT7YlWJXPg9bQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*1ADsO51UoOlA-Sa9FeSLnw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*bt9U0U9j-bf7CobTm5IvoQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*hI1XBx-07B5P34ixRAmKCw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/596/1*g8WG2v5Vz2-v97BJ_Inv2Q.png" /></figure><p><strong>Step 2: Install AWS CLI</strong></p><p>Follow the steps on this link to install AWS CLI according to your OS:</p><p><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html</a></p><p><strong>Step 3: Create an IAM role with SSM and S3 full access and attach that to SQL Server</strong></p><p>Create an IAM role with following AWS Managed polices attached to the role. Once the role is created, we need to attach the role to the EC2 SQL Server instance.</p><ul><li>Create a role from IAM console:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IHPx5RhOzN5-mOgM_AT-NA.png" /></figure><ul><li>On the Create role page, Select “type of trusted entity” as AWS service. Select a service as Ec2 from the list to view its use case, and then choose a “use case” as EC2 and click Next.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QMYpy2WMln0YXUS9e7PVIw.png" /></figure><ul><li>On the Attach permissions policy page, select the Policy from the list of AWS managed policy that grants your instances access to the resources. Policies needed: AmazonSSMManagedInstanceCore, AmazonS3FullAccess</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2e7bwiuXcvvQZqxXvKOubA.png" /></figure><ul><li>Next, on the Review page, enter a name for the role and choose Create role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XvrdtwMpXe3YlEdQcl4OHA.png" /></figure><ul><li>Next, we will attach this role to our SQL Server EC2 instance. Browse to your EC2 instance and select actions, choose Security. Select Modify IAM role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/559/1*-mAPL0tVB3OyJICro-z7QA.png" /></figure><ul><li>From the drop down, choose the role that we created earlier and select update IAM role</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/872/1*zDOi_UcurQdPN66zlRVl0g.png" /></figure><p><strong>Step 4: Reboot SQL Server</strong></p><p>Now the IAM role is created and attached to the EC2 instance, we need to reboot the EC2 instance on which SQL Server is running.</p><p><strong>Step 5: Create S3 buckets</strong></p><p>Create a bucket and create subfolders in the bucket for keeping different types of backups.</p><p>Browse to S3 and create bucket. Give a unique name to your bucket (I uses sql-server-native-backups). Accept all the default and hit create.</p><p>Click create folder and create 4 different folders for housing different types of backups:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8YoF8G2TfgAJElz6hlBrhA.png" /></figure><p><strong>Step 6: Map S3 bucket as Drive</strong></p><p>This is the fun step where we will map the bucket we created in the previous step as a Drive to EC2 instance.</p><ul><li>RDP to the EC2 instance and open TNTDrive and click Add new map drive:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*J9iFVYPK03Q5hyVuiccaBQ.png" /></figure><ul><li>Click the pen icon next to storage to add a new AWS account:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*-52ekV2BYlVV6oFLKumewg.png" /></figure><ul><li>Now give a name to your AWS Account and from the Account Type drop down list — choose Amazon S3 via EC2 IAM Role. Click Add new account:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3Wmz04d9di75ZvMaKzZxg.png" /></figure><ul><li>Browse the bucket we created earlier and click Add new drive:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*-xURYsI0uBdZgUi5Vh5uug.png" /></figure><ul><li>If the role we created earlier is correct, we should now see Z: drive on our EC2 instance that would show all the 4 folders we created in our backup bucket:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*es8ecXsMByPsFNyRzDCouw.png" /></figure><p><strong>Step 7: Set up scripts in SSMS to send backups to S3</strong></p><p>Create a new maintenance plan and combine all different types of backups into one maintenance plan in in SQL Server. You can create separate maintenance plans for each type of backup if you like.</p><p>For each subtask, add three functions:</p><ul><li>Maintenance cleanup task — This will help keep the EBS volume storage in check</li><li>Backup database task — The actual backup task</li><li>Execute T-SQL statement task — This is where we will have the XCOPY command to transfer the backups to S3</li></ul><figure><img alt="SQL Server Maintenance Plan for backups" src="https://cdn-images-1.medium.com/max/1024/1*DC7syF5AOgerWruDgKpTIQ.png" /><figcaption>SQL Server Maintenance Plan for backups</figcaption></figure><p>Within the Backup database subtask, be sure to select the option to create backups in their own subdirectories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/681/1*C0cVVuSQUpuIWakEGwcbeQ.png" /></figure><p>As I mentioned previously, I have used XCOPY to transfer the backups from local drive to S3</p><p>For Yearly Backups, here is how the T-SQL looks like</p><blockquote>USE master</blockquote><blockquote>EXEC xp_cmdshell ‘Xcopy E:\YearlyBackups Z:\YearlyBackups /E /I /S /D’, NO_OUTPUT</blockquote><p>Similarly create subtasks for each backup type.</p><p><strong>Step 8: Set up Lifecycle policies in S3 to transition backups</strong></p><p>We need to step lifecycle policies in S3 according to the retention of the backups. These are the Lifecycle policies I have set up:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/852/1*VAbtg3W7kWOD7raWTyCoiA.png" /><figcaption>S3 Lifecycle configurations</figcaption></figure><p>To create a Lifecycle rule in S3, follow these steps:</p><p><a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html">https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lifecycle-mgmt.html</a></p><p>Once all the lifecycle policies are created, one should run some test backups to see if they are landing in the right bucket.</p><p><strong>Conclusion</strong></p><p>Mapping a S3 bucket to your EC2 instance can be a great and easy solution for businesses looking to send their native SQL Server backups to S3 for long term storage.</p><p>This solution also be considered for businesses looking to use S3 for their Database backups as a DR.</p><p><strong>Updated by Megha Gupta | on SEPTEMBER 12, 2022</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cc2d6089ddfb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate AWS RDS for SQL Server with on-prem Active Directory]]></title>
            <link>https://medium.com/@gupta.megha/integrate-aws-rds-for-sql-server-with-on-prem-active-directory-40f6efa8c0bb?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/40f6efa8c0bb</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-directory-service]]></category>
            <category><![CDATA[aws-ec2]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 21:03:02 GMT</pubDate>
            <atom:updated>2022-10-12T17:18:29.800Z</atom:updated>
            <content:encoded><![CDATA[<p>I have helped many of our AWS customers utilize their corporate active directory to authenticate into their RDS for SQL Server database. The entire configuration is very straightforward and takes only 1 hour to configure.</p><p><strong>Solution Overview:</strong></p><p>I am assuming that the Corporate/on-prem Active Directory domain is already set up and configured.</p><p>The goal of this article is to help you configure authentication of RDS for SQL Server using on-prem active directory. We will be configuring Microsoft AD running in the same VPC as the RDS SQL Server instance and build a trust relationship between the Microsoft AD and your Corporate active directory domain.</p><p><strong>Architecture of the solution:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*fiqFsxPosLIYqla06ee7PA.png" /></figure><p><strong>Setup:</strong></p><p>To complete the setup, your AWS environment and corporate domain deployment should include the following:</p><ul><li>A VPC with at least 2 subnets in different Availability Zones</li><li>One or more domain controllers for your corporate domain with working DNS (example: testlab.com)</li><li>One or more bastion hosts or some other mechanism that allows you to connect to the corporate domain and change the configuration</li><li>A user account with membership in the Domain Admin or Enterprise Admin groups to establish the forest trust relationship</li><li>An IAM permission that allows you to create and manage the AWS Directory Service resources and RDS resources along with supporting resources mentioned in the architecture. IAM policies needed by</li></ul><p><strong>Step 1: Set up RDS for SQL Server:</strong></p><p>Follow the steps listed in this document to set up RDS for SQL Server:</p><p><a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.SQLServer.html#CHAP_GettingStarted.Creating.SQLServer">https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_GettingStarted.CreatingConnecting.SQLServer.html#CHAP_GettingStarted.Creating.SQLServer</a></p><p><strong>Step 2: Create Microsoft AD in the same VPC as your RDS instance:</strong></p><p>In this step we will set a Microsoft AD directory which we will using to set up a Forest Trust relationship between the AWS Directory and the corporate Domain Controller.</p><ul><li>Browse to AWS Directory Service and select create Directory</li><li>Select AWS Managed Microsoft AD and select next</li><li>Select Standard edition, or choose Enterprise Edition if you have very large set of users. For most use cases Standard Edition is good</li><li>Give a name to the Directory DNS, example (rdsdemoad.com)</li><li>Provide an admin password and confirm the admin password</li><li>Provide the VPC (same as the RDS VPC) and provide the 2 subnets</li><li>Review and create the AD</li><li>It can take up to 15–20 minutes for the Directory to be created.</li></ul><p><strong>Step 3: Create a Forest Trust relationship between the Microsoft AD and Corporate Domain:</strong></p><p>There are 2 parts to creating a Forest Trust relationship:</p><p>a. Configure Corporate Domain</p><p>b. Configure AWS Managed Microsoft AD</p><p>Before you can establish the trust relationship between the two forests, you must meet the following prerequisites. The AWS Directory Service documentation on trusts provides a <a href="http://docs.aws.amazon.com/directoryservice/latest/admin-guide/setup_trust.html">comprehensive guide</a> to addressing these requirements.</p><ul><li>Ensure that the Microsoft AD directory service can receive inbound connections and can initiate network connections for Active Directory-related traffic with your corporate domain controllers. AWS Directory Service automatically creates a security group for the newly created resource. It must be adjusted to allow communication with corporate domain controllers.</li><li>Ensure that your corporate domain controllers can receive inbound connections from the new directory controllers.</li><li>Create a DNS conditional forwarder on your corporate domain to the new domain’s DNS name, providing the IP addresses of the directory’s domain controllers.</li></ul><p><strong><em>a. Configure Corporate Domain</em></strong></p><p>After all the 3 prerequisites are complete, we can create an inbound forest trust on the corporate domain. For that login to the Corporate Domain server and open to Active Directory Domains and Trusts.</p><ul><li>Right click the domain and select Properties</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*vRMjJ2jhI_JRSTtgleqHJw.png" /></figure><ul><li>On the Trusts tab, choose new trust</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*hB-xZ8zzkF95YfnONYpUzA.png" /></figure><p>Follow the steps to create a New Trust using the Wizard:</p><ul><li>Provide the name for the AWS Managed domain, example (rdsdemoad.com)</li><li>On the Trust Type choose Forest Trust</li><li>Under Direction of trust, choose One-way: incoming</li><li>Provide a Trust password. You will need the same password to complete the relationship later</li><li>Under Confirm incoming trust, choose No, do not confirm the incoming trust</li></ul><p><strong><em>b. Configure AWS Microsoft Managed AD Trust</em></strong></p><ul><li>Go to AWS Console and select AWS Directory Service. Select the Microsoft AD that you created in Step 2.</li><li>Go to Trust Relationships and under Actions, select add trust relationship</li><li>Select ‘Forest Trust’ and type of the name of the Corporate domain</li><li>Type the Trust password that you used when setting up trust on Corporate domain</li><li>Trust Direction: Select on-way: outgoing</li><li>Type the FDQN of the conditional forwarder of the corporate domain</li><li>The outgoing trust should have a status of verified. If not, check the Security Group of the Directory Service to see if inbound and outbound rules are correctly set up to allow traffic between corporate domain and AWS Managed AD.</li></ul><p><strong>Step 4: Configure RDS instance to use the AWS Managed AD</strong></p><p>Now we need to configure the RDS for SQL Server to use the Managed AD that we created in Step 2</p><ul><li>Browse to the RDS instance in AWS console and select the RDS instance that you would like to set up AD for</li><li>Click modify and under Microsoft SQL Server Windows Authentication, check ‘Enable Microsoft SQL Server Windows Authentication</li><li>Under Directory, Click Browse Directory and select the AWS Managed AD directory we created in step 2</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/759/1*XNO4ZlUK2Zw1aVcImNBwrA.png" /></figure><ul><li>Click continue and select ‘apply immediately’</li><li>Click ‘Modify DB Instance’. If you are doing this on a production RDS instance, this will cause some downtime</li></ul><p><strong>Step 5: Add logins to RDS SQL Server</strong></p><p>After the RDS for SQL Server is provisioned and configured to use Managed AD, you can start creating logins for the domain users.</p><p>Before we begin this step, we would need an EC2 instance that has SQL Server Management Tools already installed. You would need to allow 1433 port this EC2 instance in the RDS Security Group</p><ul><li>Log in to the SQL Server Management Studio using the Master username and password</li><li>Use the following T-SQL script to create the logins:</li></ul><pre>CREATE LOGIN [DOMAIN\Domain Users] FROM WINDOWS WITH DEFAULT_DATABASE = [master], DEFAULT_LANGUAGE = [us_english];</pre><pre>GO ;</pre><ul><li>If you prefer to use your existing domain DBA login to manage the RDS DB instance or do more fine grain access control, you can configure the users using the following T-SQL script:</li></ul><pre>CREATE LOGIN [DOMAIN\DBAdmin] FROM WINDOWS WITH DEFAULT_DATABASE = [master], DEFAULT_LANGUAGE = [us_english];</pre><pre>GO</pre><pre>EXEC sp_addsrvrolemember ‘DOMAIN\DBAdmin’, ‘processadmin’;</pre><pre>EXEC sp_addsrvrolemember ‘DOMAIN\DBAdmin’, ‘setupadmin’;</pre><pre>GO</pre><pre>GRANT ALTER ANY CONNECTION, ALTER ANY LINKED SERVER, ALTER ANY LOGIN, ALTER ANY SERVER ROLE, ALTER SERVER STATE, ALTER TRACE, CONNECT SQL, CREATE ANY DATABASE, VIEW ANY DATABASE, VIEW ANY DEFINITION, VIEW SERVER STATE TO [DOMAIN\DBAdmin] WITH GRANT OPTION;</pre><pre>GO</pre><p><strong>Conclusion:</strong></p><p>This architecture reinforces security imperatives and requirements that a company might already have in place. Using the Forest Trust relationship allows for fine grained access control to your RDS instance which was not possible to do with just RDS alone.</p><p><strong>Updated by Megha Gupta | on SEPTEMBER 1st 2022</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=40f6efa8c0bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Troubleshoot high CPU in AWS MySQL RDS]]></title>
            <link>https://medium.com/@gupta.megha/troubleshoot-high-cpu-in-aws-mysql-rds-2b50982bd638?source=rss-820aeabfec2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b50982bd638</guid>
            <category><![CDATA[mysql]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[rds]]></category>
            <dc:creator><![CDATA[Megha Gupta]]></dc:creator>
            <pubDate>Thu, 01 Sep 2022 20:06:51 GMT</pubDate>
            <atom:updated>2022-10-12T17:16:34.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*kRUNsXM85diTkf6ri2lQ4A.png" /></figure><h3>Description:</h3><p>This guide documents the basic steps to follow when troubleshooting MySQL CPU issues on Amazon RDS. For issues with any performance metrics, one of the first things you can do to improve performance is tune the most used and most expensive queries to see if that lowers the pressure on system resources. For more information, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_BestPractices.html#CHAP_BestPractices.TuningQueries">Tuning Queries</a>. If the queries are tuned and an issue persists, consider upgrading your Amazon RDS <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Concepts.DBInstanceClass.html">DB Instance Class</a> to one with more of the resource (CPU, RAM, disk space, network bandwidth, I/O capacity) that is related to the issue you are experiencing.</p><h3><strong>Troubleshooting steps:</strong></h3><ol><li><strong>Check CPU utilization graph under Cloudwatch: </strong>Login to AWS console and go to the RDS instance. Check the CPU utilization graph for the time frame when the problem started occurring. Look for any specific patterns in the graph to rule out a specific batch job causing the high CPU usage.</li></ol><p>Double click the CPU utilization graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k9Nm9EddMaZi5qfnBWHwIQ.png" /></figure><p>Select the time range from the drop down list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Nfr-aneJGQqp8p0XjDsB3g.png" /></figure><p>This is will show specific patterns, if any.</p><p>A consistent state of 80 percent to 90 percent may indicate the need to upgrade or add more processors. A “CPU spike” during a short period of time may not be an issue. However, if we see sustained periods of high CPU we should investigate further and possibly scale up the database instance to a higher tier.</p><p><strong>2. Check Memory graphs over time in the AWS Console: </strong>An Amazon RDS performance best practice is to allocate enough RAM so that your working set resides almost completely in memory. To tell if your working set is almost all in memory, check the ReadIOPS metric (using Amazon CloudWatch) while the DB instance is under load. The value of ReadIOPS should be small and stable. If scaling up the DB instance class — to a class with more RAM — results in a dramatic drop in ReadIOPS, your working set was not almost completely in memory. Continue to scale up until ReadIOPS no longer drops dramatically after a scaling operation, or ReadIOPS is reduced to a very small amount. For information on monitoring a DB instance’s metrics, see <a href="https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_Monitoring.html#USER_Monitoring">Viewing DB Instance Metrics</a></p><p><strong>3. Check DB Connections graph under CloudWatch</strong></p><p>Double-click the DB Connection graph to check if all/most of the DB connections are used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KLExqZzY5uFQ7PZT8aGeXQ.png" /></figure><p><strong>4. Check Show processlist:</strong></p><p>Login to the MySQL RDS instance via SSH or Workbench and run ‘Show processlist’ to see what’s queries are running in the database.</p><ul><li>Exclusive LOCK queries : Check MySQL processlist to see if lot of queries are in LOCK status.</li><li>Deadlock : Check if there is an active log deadlock in the database causing all the connections to back up.</li><li>Long running queries : Check specially for queries that have been running for a long time.</li><li>Backup process : Check if a backup process is running.</li><li>Optimization process : Check if any database maintenance scripts are running like table optimization.</li></ul><p><strong>5. Check slow query log:</strong></p><p>One of the most effect ways to fix CPU issue is to Optimize your database queries. Some web applications are known to use complex queries to display site information. These queries can take a long time to execute, and cause CPU load. Get the list of such queries from the “slow query log” and reduce the number of joins and other table manipulations under a single query. Also check for queries doing Full Table scans.</p><p>Use Explain plans to identify how the query is being run.</p><p>Example of explain plan shows that the query is doing a Full table scan. The possible keys shows NULL which means there is an index and creating an index on lastmodified_date_orig would help make the query run faster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KF2fZYoRREky818h-Gfovg.png" /></figure><h3>Conclusion:</h3><p>Its always a combination of different things that a DBA needs to take to find the root cause of consistent CPU issues with AWS MySQL RDS instance.</p><p><strong>Updated by Megha Gupta | on SEPTEMBER 1st 2022</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b50982bd638" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>