{"id":5,"date":"2017-08-10T06:25:04","date_gmt":"2017-08-10T06:25:04","guid":{"rendered":"http:\/\/www.mrmarkyoung.com\/oracle\/?p=5"},"modified":"2017-08-13T22:38:47","modified_gmt":"2017-08-13T22:38:47","slug":"oracle-to-aurora-using-data-migration-services-dms","status":"publish","type":"post","link":"http:\/\/www.mrmarkyoung.com\/oracle\/2017\/08\/10\/oracle-to-aurora-using-data-migration-services-dms\/","title":{"rendered":"Oracle to Aurora using Data Migration Services (DMS)"},"content":{"rendered":"<p>We are looking to migrate some customer data, however we don&#8217;t need all the data, but only a subset. The idea was to create a copy of the existing tables using a copy with the relevant rows, then create a series of triggers to keep them up-to-date with the main tables. It goes something like this.<\/p>\n<pre><code>create table customer_aws as select * from customer where custno =&lt; 10000;\r\nalter table customer_aws add constraint customer_aws_pk primary key (userid) enable validate;\r\n<\/code><\/pre>\n<p>Once the table has been created, we can place a trigger to update the newly created table when there is a change to the parent.<\/p>\n<pre><code>CREATE OR REPLACE TRIGGER SCOTT.CUSTOMERUPDATE\r\nBEFORE UPDATE\r\nON SCOTT.customer\r\nREFERENCING NEW AS NEW OLD AS OLD\r\nFOR EACH ROW\r\nBEGIN \r\n\r\n--delete the record, ensure we remove the record with the primary key.\r\ndelete from scott.customer_aws where userid = :old.USERID;\r\n\r\n-- If we have deleted a row, then perform the update.\r\nif sql%rowcount = 1 then\r\n\r\n  Insert into SCOTT.CUSTOMER_AWS\r\n       (HISTORYID, PROPERTYID, TABLENAME, IDENTITYKEY, USERID, \r\n        USEROVERRIDE, PROPERTYKEY, PROPERTYVALUE, LASTUPDATEDBY, TXNTYPE, \r\n        CREATEDATETIME, UPDATEDDATETIME)\r\n    Values\r\n        (:new.HISTORYID, :new.PROPERTYID, :new.TABLENAME, :new.IDENTITYKEY, :new.USERID, \r\n        :new.USEROVERRIDE, :new.PROPERTYKEY, :new.PROPERTYVALUE, :new.LASTUPDATEDBY, :new.TXNTYPE, \r\n        :new.CREATEDATETIME, :new.UPDATEDDATETIME);\r\nend if;\r\nEND;\r\n\/\r\n<\/code><\/pre>\n<p>Now that we have created the new table and trigger, test this out and make sure changes to the parent are replicated to the table copy.<\/p>\n<p>If we want to use the &#8220;Ongoing Replication&#8221; AWS Data Migration Service (DMS) from Amazon, we need to set a few things up on the Oracle database.<\/p>\n<p>Turn on supplemental logging for the database<\/p>\n<pre><code>alter database add supplemental log data;\r\n<\/code><\/pre>\n<p>Then, for each table, you must turn on further supplemental logging for each table. Information can be found <a href=\"http:\/\/docs.aws.amazon.com\/dms\/latest\/userguide\/CHAP_Source.Oracle.html\">here<\/a><\/p>\n<pre><code>alter table scott.CUSTOMER_AWS add supplemental log data (PRIMARY KEY) columns;\r\n<\/code><\/pre>\n<p>Login to your aws.amzon.com account and select RDS to setup your target database. Once your RDS is complete, we can select the DMS component.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-16 size-full\" src=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-04-04-PM-1.png\" alt=\"\" width=\"920\" height=\"298\" srcset=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-04-04-PM-1.png 920w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-04-04-PM-1-300x97.png 300w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-04-04-PM-1-768x249.png 768w\" sizes=\"auto, (max-width: 920px) 100vw, 920px\" \/><\/p>\n<p>Then select &#8220;Get Started&#8221;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-20 size-full\" src=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-12-12-PM.png\" alt=\"\" width=\"1267\" height=\"446\" srcset=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-12-12-PM.png 1267w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-12-12-PM-300x106.png 300w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-12-12-PM-768x270.png 768w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-12-12-PM-1024x360.png 1024w\" sizes=\"auto, (max-width: 1267px) 100vw, 1267px\" \/><\/p>\n<p>Click next<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-27 size-full\" src=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-55-31-PM.png\" alt=\"\" width=\"926\" height=\"695\" srcset=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-55-31-PM.png 926w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-55-31-PM-300x225.png 300w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-55-31-PM-768x576.png 768w\" sizes=\"auto, (max-width: 926px) 100vw, 926px\" \/><\/p>\n<p>If you are on a private network, then make sure &#8220;Publicly accessible&#8221; is not checked.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-30 size-full\" src=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-39-06-PM.png\" alt=\"\" width=\"1625\" height=\"832\" srcset=\"http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-39-06-PM.png 1625w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-39-06-PM-300x154.png 300w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-39-06-PM-768x393.png 768w, http:\/\/www.mrmarkyoung.com\/oracle\/wp-content\/uploads\/2017\/08\/10-08-2017-1-39-06-PM-1024x524.png 1024w\" sizes=\"auto, (max-width: 1625px) 100vw, 1625px\" \/><\/p>\n<p>Please be aware, that you must select an IP Address on your internal network for the server name of the Oracle database, it does now know how to resolve a host name. Once your endpoints are created and the replication database has finished building, then you can perform &#8220;Run test&#8221;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We are looking to migrate some customer data, however we don&#8217;t need all the data, but only a subset. The idea was to create a copy of the existing tables using a copy with the relevant rows, then create a series of triggers to keep them up-to-date with the main tables. It goes something like &#8230; <a title=\"Oracle to Aurora using Data Migration Services (DMS)\" class=\"read-more\" href=\"http:\/\/www.mrmarkyoung.com\/oracle\/2017\/08\/10\/oracle-to-aurora-using-data-migration-services-dms\/\" aria-label=\"Read more about Oracle to Aurora using Data Migration Services (DMS)\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[12,11],"class_list":["post-5","post","type-post","status-publish","format-standard","hentry","category-oracle-aws","tag-aws","tag-dms"],"_links":{"self":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/5","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/comments?post=5"}],"version-history":[{"count":14,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/5\/revisions"}],"predecessor-version":[{"id":33,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/posts\/5\/revisions\/33"}],"wp:attachment":[{"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/media?parent=5"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/categories?post=5"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.mrmarkyoung.com\/oracle\/wp-json\/wp\/v2\/tags?post=5"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}