{"id":1941,"date":"2020-05-18T10:19:04","date_gmt":"2020-05-18T08:19:04","guid":{"rendered":"http:\/\/www.ludovicocaldara.net\/dba\/?p=1941"},"modified":"2020-05-18T14:33:32","modified_gmt":"2020-05-18T12:33:32","slug":"push-pdb-to-cloud","status":"publish","type":"post","link":"https:\/\/www.ludovicocaldara.net\/dba\/push-pdb-to-cloud\/","title":{"rendered":"Multitenant Pills: Pushing your PDB to the Cloud in one step?"},"content":{"rendered":"<p>The Oracle Multitenant architecture introduces some nice opportunities, including local and remote cloning (see <a href=\"https:\/\/oracle-base.com\/articles\/12c\/multitenant-hot-clone-remote-pdb-or-non-cdb-12cr2\">this example on ORACLE_BASE blog<\/a>).<\/p>\n<p>However, the only available cloning procedure use the PULL method to get the data from the remote source PDB.<\/p>\n<p>This can be a limitation, especially in environments where the cloning environment does not have direct access to the production, or where the clones must be done in the Cloud with no direct access to the production VLAN on-premises.<\/p>\n<p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1942\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-1024x344.png\" alt=\"\" width=\"584\" height=\"196\" srcset=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-1024x344.png 1024w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-300x101.png 300w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-768x258.png 768w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-1536x516.png 1536w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1-500x168.png 500w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_1.png 1813w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><\/p>\n<p>So, one common approach is to clone\/detach locally, put the PDB files in the Object Store and then attach them in the cloud.<\/p>\n<p>Another approach is to use SSH tunnels. If you follow my blog you can see it is something that I use every now and then to do stuff from on-premises to the cloud.<\/p>\n<p><strong>How to set it up?<\/strong><\/p>\n<p>Actually, it is super-easy: just prepare a script in the cloud that will do the create pluggable database, then trigger it from on-premises.<\/p>\n<p><a href=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-1943\" src=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-1024x357.png\" alt=\"\" width=\"584\" height=\"204\" srcset=\"https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-1024x357.png 1024w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-300x105.png 300w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-768x268.png 768w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-1536x535.png 1536w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2-500x174.png 500w, https:\/\/www.ludovicocaldara.net\/dba\/wp-content\/uploads\/2020\/05\/pdb_clone_cloud_2.png 1831w\" sizes=\"auto, (max-width: 584px) 100vw, 584px\" \/><\/a><\/p>\n<p>This is an example:<\/p>\n<pre class=\"lang:sh decode:true\">SRC_PDB=$1\r\nTGT_PDB=$2\r\nALIAS=$3\r\n\r\nexport ORACLE_HOME=\/u01\/app\/oracle\/product\/19c\/dbhome_1\r\nexport ORACLE_SID=ORCL\r\n\r\n$ORACLE_HOME\/bin\/sqlplus -s \/ as sysdba &lt;&lt;EOF\r\n        create database link onprem_temp\r\n          connect to C##ONPREM identified by manager using '$ALIAS';\r\n        create pluggable database $2 from $1@onprem_temp ;\r\n        drop database link onprem_temp;\r\n        alter pluggable database $2 open;\r\n        alter pluggable database $2 save state;\r\n        exit\r\nEOF<\/pre>\n<p>It takes as parameters: the name of the source PDB, the name of the target PDB and the SQL*Net descriptor to create the temporary database link from the cloud CDB to the on-premises CDB.<\/p>\n<p>The user C##ONPREM must obviously exist on-premises with the following privileges:<\/p>\n<pre class=\"lang:plsql decode:true\">grant create session, sysoper, create pluggable database to C##ONPREM container=all;<\/pre>\n<p>The cloud database should use OMF so you don&#8217;t have to take care about file name conversions.<\/p>\n<p>At this point, if you have set up correctly the SSH keys to connect to the cloud server, it is just a matter of running the script remotely using the proper SSH tunnel. Once the remote port binding established, the cloud server can contact the on-premises listener port using localhost:remote_bind:<\/p>\n<pre class=\"lang:sh decode:true \">oracle@onpremsrv:~$ ssh opc@cloudsrv -R 1522:onpremsrv:1521 \\\r\n \"sudo -u oracle \/home\/oracle\/clone_db.sh PDBSRC PDBDEST localhost:1522\/ONPREMCDB\"\r\n\r\nDatabase link created.\r\n\r\nPluggable database created.\r\n\r\n\r\nDatabase link dropped.\r\n\r\noracle@onpremsrv:~$<\/pre>\n<p>Of course the timing depends a lot on the size of the database and your connection to the Cloud.<\/p>\n<p>I have tested this procedure with Oracle Database 19.7 on OCI compute instances and on DBaaS VM instance, it works without any additional work. Of course, it does not work for Autonomous Database \ud83d\ude42<\/p>\n<p>&#8212;<\/p>\n<p>Ludovico<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The Oracle Multitenant architecture introduces some nice opportunities, including local and remote cloning (see this example on ORACLE_BASE blog). However, the only available cloning procedure use the PULL method to get the data from the remote source PDB. This can &hellip; <a href=\"https:\/\/www.ludovicocaldara.net\/dba\/push-pdb-to-cloud\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[321,3,315],"tags":[211,117,289],"class_list":["post-1941","post","type-post","status-publish","format-standard","hentry","category-aced","category-oracledb","category-oracle-database-19c","tag-cloning","tag-cloud","tag-multitenant"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1941","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/comments?post=1941"}],"version-history":[{"count":4,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1941\/revisions"}],"predecessor-version":[{"id":1949,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/posts\/1941\/revisions\/1949"}],"wp:attachment":[{"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/media?parent=1941"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/categories?post=1941"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ludovicocaldara.net\/dba\/wp-json\/wp\/v2\/tags?post=1941"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}