{"id":1472,"date":"2020-08-04T23:26:32","date_gmt":"2020-08-04T21:26:32","guid":{"rendered":"https:\/\/blog.sqlora.com\/en\/?p=1472"},"modified":"2020-08-04T23:31:47","modified_gmt":"2020-08-04T21:31:47","slug":"upgrading-a-19c-database-on-docker","status":"publish","type":"post","link":"https:\/\/blog.sqlora.com\/en\/upgrading-a-19c-database-on-docker\/","title":{"rendered":"Upgrading a 19c database on docker"},"content":{"rendered":"\n<p>I&#8217;m neither an Oracle DBA, nor am I a Docker expert. How on earth did I get here to write this post? Well, I&#8217;m still an Oracle Developer and as you may have noticed, I was recently focused on SQL macros. It is a new feature of Oracle Database 20c, but obviously so awesome that it was backported to 19.6.0. Of course I asked myself, how can I start testing SQL macros in 19c? <\/p>\n\n\n\n<!--more-->\n\n\n\n<p>For testing, blogging and so on I switched to using an Oracle DB on docker a while ago. Until now I was running a container with a 19.3 database. Before doing an upgrade I looked for other free options, also in terms of effort and skills needed, but without success: <a rel=\"noreferrer noopener\" aria-label=\"livesql.oracle.com (opens in a new tab)\" href=\"https:\/\/livesql.oracle.com\/\" target=\"_blank\">livesql.oracle.com<\/a> is on 19.5.0, Oracle&#8217;s <a rel=\"noreferrer noopener\" aria-label=\"pre-built Developer VM (opens in a new tab)\" href=\"https:\/\/www.oracle.com\/downloads\/developer-vm\/community-downloads.html\" target=\"_blank\">pre-built Developer VM<\/a> has 19.3 installed, autonomous databases in <a href=\"https:\/\/www.oracle.com\/cloud\/free\/?source=:ow:o:h:po:OHPPanel1nav0625&amp;intcmp=:ow:o:h:po:OHPPanel1nav0625\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"OCI free tier (opens in a new tab)\">OCI free tier<\/a> are also on 19.5. So at the end I had to upgrade my docker DB.<\/p>\n\n\n\n<p>As I mentioned, it&#8217;s not a typical day-to-day task for me and because it was a little bit tricky, I decided to write it up in this post. It&#8217;s more like a note for myself or maybe for you,  if you are in a similar situation and have similar skills. On the other hand, if you are experienced in this topic, your comments are welcome! Feel free to point out better ways!<\/p>\n\n\n\n<p>First of all, let&#8217;s clarify: we are not going to upgrade the database in existing container. Docker best practice is to create a new image instead.<\/p>\n\n\n\n<p><a rel=\"noreferrer noopener\" aria-label=\"Official docker images on Github (opens in a new tab)\" href=\"https:\/\/github.com\/oracle\/docker-images\" target=\"_blank\">Official docker images on Github<\/a> provides an <a rel=\"noreferrer noopener\" aria-label=\"explanation of how to do it (opens in a new tab)\" href=\"https:\/\/github.com\/oracle\/docker-images\/tree\/master\/OracleDatabase\/SingleInstance\/samples\/applypatch\" target=\"_blank\">explanation of how to do it<\/a>. Either you have already built and used a base image (oracle\/database:19.3.0-ee in my example) or you have to build one first and then create a patched version of it. I had to rebuild my image anyway and I will show why.<\/p>\n\n\n\n<p>So let&#8217;s start. If you&#8217;ve cloned the repository, the relevant path will be under  <code>\\docker-images-master\\OracleDatabase\\SingleInstance\\samples\\applypatch. <\/code>There you&#8217;ll find the structure like this:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"478\" height=\"127\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder-2.png\" alt=\"\" class=\"wp-image-1481\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder-2.png 478w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder-2-300x80.png 300w\" sizes=\"auto, (max-width: 478px) 100vw, 478px\" \/><\/figure>\n\n\n\n<p>Seems like nobody&#8217;s been concerned with newer releases lately. But it is pretty easy to fix. Create a copy of the folder <strong>12.2.0.1<\/strong> including subfolders and files and name it <strong>19.3.0<\/strong><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"423\" height=\"137\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder2.png\" alt=\"\" class=\"wp-image-1482\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder2.png 423w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/patchfolder2-300x97.png 300w\" sizes=\"auto, (max-width: 423px) 100vw, 423px\" \/><\/figure>\n\n\n\n<p>Now we have to do a minor change to Dockerfile. If you&#8217;re working with Enterprise Edition, open <strong>Dockerfile.ee<\/strong> and change the name of the base image at line  21 and also in comments above:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"693\" height=\"123\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image.png\" alt=\"\" class=\"wp-image-1483\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image.png 693w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-300x53.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-624x111.png 624w\" sizes=\"auto, (max-width: 693px) 100vw, 693px\" \/><\/figure>\n\n\n\n<p>For Standrad Edition just do the same change in <strong>Dockerfile.se2<\/strong><\/p>\n\n\n\n<p>Download the patch ZIP-file and save it under <strong>patches\\001<\/strong>. If you have several patches to apply, you can create subfolder 002, 003 and so on and save further patch files in these folders. Patches often require the newer version of OPatch. Download the latest Version and save it under <strong>patches<\/strong>. I decided to apply the latest RU 19.8.0,  so i downloaded and saved two files: <strong><em>p31281355_190000_Linux-x86-64.zi<\/em><\/strong><em><strong>p<\/strong><\/em> and <strong><em>p6880880_190000_Linux-x86-64.zip<\/em><\/strong> (Opatch)<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"462\" height=\"141\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-1.png\" alt=\"\" class=\"wp-image-1486\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-1.png 462w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-1-300x92.png 300w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n\n\n\n<p>We are ready to build the image now. Go into  <code>\\docker-images-master\\OracleDatabase\\SingleInstance\\samples\\applypatch<\/code> and run the command to build:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; gutter: false; title: ; notranslate\" title=\"\">\n.\/buildPatchedDockerImage.sh -v 19.3.0 -e Patch\n<\/pre><\/div>\n\n\n<p>This can take a minute, so you can grab a cup of coffee. However, inspecting a log you will find that the build was not successful. Particularly, you&#8217;ll see a couple of errors at the end of the log file, something like this:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n...\nJar Action: Destination File &quot;\/opt\/oracle\/product\/19c\/dbhome_1\/assistants\/dbua\/jlib\/dbua.jar&quot; does not exists or is not writeable\n&#039;oracle.assistants.server, 19.0.0.0.0&#039;: Cannot update file &#039;\/opt\/oracle\/product\/19c\/dbhome_1\/assistants\/dbua\/jlib\/dbua.jar&#039; with &#039;\/oracle\/assistants\/dbua\/action\/SummaryAction$2.class&#039;\nJar Action: Destination File &quot;\/opt\/oracle\/product\/19c\/dbhome_1\/assistants\/dbua\/jlib\/dbua.jar&quot; does not exists or is not writeable\n&#039;oracle.assistants.server, 19.0.0.0.0&#039;: Cannot update file &#039;\/opt\/oracle\/product\/19c\/dbhome_1\/assistants\/dbua\/jlib\/dbua.jar&#039; with &#039;\/oracle\/assistants\/dbua\/backend\/BackupDatabase$DBInstanceInfo.class&#039;\n\n\u001b&#x5B;91mUtilSession failed: \nPrerequisite check &quot;CheckApplicable&quot; failed.\n\u001b&#x5B;0mLog file location: \/opt\/oracle\/product\/19c\/dbhome_1\/cfgtoollogs\/opatch\/opatch2020-07-27_20-02-43PM_1.log\n\nOPatch failed with error code 73\nRemoving intermediate container 595216bc5332\nThere was an error building the image.\n\n<\/pre><\/div>\n\n\n<p>It&#8217;s because OPatch tries to update those non-existent files. But why are these files not there? The answer is simple: they were intentionally removed while building the base image!   As you can see at the end of <strong>installDBBinaries.sh<\/strong> some files are being removed:<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n  # Remove not needed components\n    # APEX\n    rm -rf $ORACLE_HOME\/apex &amp;amp;&amp;amp; \\\n    # ORDS\n    rm -rf $ORACLE_HOME\/ords &amp;amp;&amp;amp; \\\n    # SQL Developer\n    rm -rf $ORACLE_HOME\/sqldeveloper &amp;amp;&amp;amp; \\\n...\n<\/pre><\/div>\n\n\n<p>This problem is described here: <a rel=\"noreferrer noopener\" aria-label=\"https:\/\/github.com\/oracle\/docker-images\/issues\/1187  (opens in a new tab)\" href=\"https:\/\/github.com\/oracle\/docker-images\/issues\/1187\" target=\"_blank\">https:\/\/github.com\/oracle\/docker-images\/issues\/1187 <\/a>. And it seems to be addressed in one of the <a rel=\"noreferrer noopener\" aria-label=\"latest commits (opens in a new tab)\" href=\"https:\/\/github.com\/oracle\/docker-images\/commit\/7d9c232d4bbaa450d431249328495b0c07eaf4ca#diff-918128f11227ee09e1956dc78e8588e9\" target=\"_blank\">latest commits<\/a>. Before building the base 19.3 image, you can now set the argument SLIMMING in the Dockerfile to control the removal of files :<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"772\" height=\"171\" src=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-4.png\" alt=\"\" class=\"wp-image-1492\" srcset=\"https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-4.png 772w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-4-300x66.png 300w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-4-768x170.png 768w, https:\/\/blog.sqlora.com\/en\/wp-content\/uploads\/sites\/2\/2020\/07\/image-4-624x138.png 624w\" sizes=\"auto, (max-width: 772px) 100vw, 772px\" \/><\/figure>\n\n\n\n<p>Now we can rebuild the base image keeping all files and repeat the creation of the patched version. The patch succeeds without problems this time.<\/p>\n\n\n\n<p>After that we can run a new container using the newly created image <code>oracle\/database:19.3.0-ee-Patch<\/code>, for example as follows (of course the name of the container, post mappings, password and volumes will be yours):<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\ndocker run -d --name db198 -p 1543:1521 -p 5633:5500 \\\n-e ORACLE_PWD=mysecurepassword \\\n-v \/docker\/ora198:\/opt\/oracle\/oradata \\\noracle\/database:19.3.0-ee-Patch  \n\n<\/pre><\/div>\n\n\n<p>Connecting to the new database shows the patch was successfully installed<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\nSQL&gt; select description, status\n  2  from DBA_REGISTRY_SQLPATCH;\n\nDESCRIPTION                                             STATUS \n----------------------------------------------------- ---------------\nDatabase Release Update : 19.8.0.0.200714 (31281355)    SUCCESS \n<\/pre><\/div>\n\n\n<p><\/p>\n\n\n\n<p>Now I&#8217;m ready to do some tests with SQL macros again! But it&#8217;s a topic for the next post.<\/p>\n\n\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-2925154690547867\" crossorigin=\"anonymous\"><\/script><ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-client=\"ca-pub-2925154690547867\" \ndata-ad-slot=\"2727403138\" \ndata-ad-layout=\"in-article\"\ndata-ad-format=\"fluid\"><\/ins>\n<script> \n(adsbygoogle = window.adsbygoogle || []).push({}); \n<\/script>\n\n\n<div class=\"crp-list-container\"><h3 class=\"crp-list-title\">Related Posts<\/h3><ul class=\"crp-list\"><li class=\"crp-list-item crp-list-item-image-none\"><div class=\"crp-list-item-title\"><a href=\"https:\/\/blog.sqlora.com\/en\/oracle-20c-sql-macros\/\" target=\"_blank\">Oracle 20c: SQL Macros<\/a><\/div><\/li><li class=\"crp-list-item crp-list-item-image-none\"><div class=\"crp-list-item-title\"><a href=\"https:\/\/blog.sqlora.com\/en\/sql-macros-in-oracle-19c\/\" target=\"_blank\">SQL macros in Oracle 19c<\/a><\/div><\/li><\/ul><\/div>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m neither an Oracle DBA, nor am I a Docker expert. How on earth did I get here to write this post? Well, I&#8217;m still an Oracle Developer and as you may have noticed, I was recently focused on SQL macros. It is a new feature of Oracle Database 20c, but obviously so awesome that [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1503,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[108],"class_list":["post-1472","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-oracle","tag-docker"],"_links":{"self":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/comments?post=1472"}],"version-history":[{"count":22,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1472\/revisions"}],"predecessor-version":[{"id":1506,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/posts\/1472\/revisions\/1506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/media\/1503"}],"wp:attachment":[{"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/media?parent=1472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/categories?post=1472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sqlora.com\/en\/wp-json\/wp\/v2\/tags?post=1472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}