{"id":73097,"date":"2016-09-29T10:50:32","date_gmt":"2016-09-29T10:50:32","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/uncategorized\/migrate-oracle-database-to-asm-using-asmcmd\/"},"modified":"2021-07-14T13:07:01","modified_gmt":"2021-07-14T13:07:01","slug":"migrate-oracle-database-to-asm-using-asmcmd","status":"publish","type":"post","link":"https:\/\/www.red-gate.com\/simple-talk\/databases\/oracle-databases\/migrate-oracle-database-to-asm-using-asmcmd\/","title":{"rendered":"Migrate Oracle Database To ASM Using ASMCMD"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Oracle Database 10g Release 1 introduced Automatic Storage Management (ASM), a new framework for managing Oracle database files. ASM provides a foundation for highly efficient storage management with direct I\/O, redundancy, striping and load balancing. Files stored on ASM are evenly distributed across disks in a disk group and mirrored according to the policies defined in the disk group. Since ASM provides an easy and highly efficient way to manage storage, it is the recommended file system for storing database files for RAC as well as single instance databases.<\/p>\n<p>The following types of database files can be stored in ASM diskgroups:<\/p>\n<ul>\n<li>Control files<\/li>\n<li>Datafiles, temporary datafiles, and datafile copies<\/li>\n<li>SPFILEs<\/li>\n<li>Online redo logs, archive logs, and Flashback logs<\/li>\n<li>RMAN backups<\/li>\n<li>Disaster recovery configurations<\/li>\n<li>Change tracking bitmaps<\/li>\n<li>Data Pump dumpsets<\/li>\n<\/ul>\n<p>To take advantage of ASM with an existing database using non-ASM storage, all or part of the database needs to be migrated into ASM. Native operating system commands such as Linux cp or Windows COPY cannot write or read files in ASM storage. Oracle provides the following means to access and manipulate ASM files:<\/p>\n<ul>\n<li><strong>Oracle Recovery Manager (RMAN)<\/strong>: The preferred method for backup and recovery of databases contained in ASM. RMAN can also be used to migrate existing non-ASM databases into ASM.<\/li>\n<li><strong>ASMCMD:<\/strong> ASM command-line interface is used to interrogate and manage ASM. It includes many UNIX-like commands that can be used to manage the files and directories in an ASM system.<\/li>\n<li><strong>XML DB:<\/strong> ASM files and directories can be accessed through a virtual folder in the XML DB repository. XML DB provides a means to access and manipulate the ASM files and directories with programmatic APIs, such as the DBMS_XDB package, and with XML DB protocol services such as FTP and HTTP\/WebDAV.<\/li>\n<li><strong>DBMS_FILE_TRANSFER<\/strong>: The DBMS_FILE_TRANSFER package provides procedures to:\n<ul>\n<li>Copy ASM files within a database<\/li>\n<li>Transfer binary files in either direction between a local ASM instance and a remote database file<\/li>\n<li>Transfer all combinations involving ASM and\/or local file system, namely:\n<ul>\n<li>Local file system to local file system<\/li>\n<li>Local file system to ASM<\/li>\n<li>ASM to local file system<\/li>\n<li>ASM to ASM<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>In this article, I will describe the necessary steps to migrate an existing Oracle database stored on the local file system to ASM using ASMCMD. This will include all datafiles, tempfiles, online redo log files, control files and the SPfile.<\/p>\n<h3>Current Setup:<\/h3>\n<p>Oracle database version: 11.2.0.3<br \/>\nName of database : orcl<br \/>\nType of storage: Local file system<\/p>\n<h3>Demonstration:<\/h3>\n<ul>\n<li>Determine the file names of the control files, datafiles, and online redo logs as they exist on the local file system for the orcl database. All of the files listed will be relocated from the local file system to ASM:<\/li>\n<\/ul>\n<pre>ORCL&gt; select name from v$datafile;\r\n\r\nNAME\r\n----------------------------------------------------------------------\r\n\/u01\/app\/oracle\/oradata\/orcl\/system01.dbf\r\n\/u01\/app\/oracle\/oradata\/orcl\/sysaux01.dbf\r\n\/u01\/app\/oracle\/oradata\/orcl\/undotbs01.dbf\r\n\/u01\/app\/oracle\/oradata\/orcl\/users01.dbf\r\n\/u01\/app\/oracle\/oradata\/orcl\/example01.dbf\r\n\r\nORCL&gt; select name from v$controlfile;\r\n\r\nNAME\r\n----------------------------------------------------------------------\/u01\/app\/oracle\/oradata\/orcl\/control01.ctl\r\n\/u01\/app\/oracle\/flash_recovery_area\/orcl\/control02.ctl\r\n\r\n\r\nSQL&gt; select member from v$logfile;\r\n\r\nMEMBER\r\n----------------------------------------------------------------------\r\n\/u01\/app\/oracle\/oradata\/orcl\/redo03.log\r\n\/u01\/app\/oracle\/oradata\/orcl\/redo02.log\r\n\/u01\/app\/oracle\/oradata\/orcl\/redo01.log<\/pre>\n<ul>\n<li>Set the CONTROL_FILES parameter in SPfile to the alias names of control files in the directory +DATA\/orcl\/oradata in DATA diskgroup. We will copy control files there later.<\/li>\n<\/ul>\n<pre>ORCL&gt;alter system set control_files = '+DATA\/orcl\/oradata\/control01.ctl','+DATA\/orcl\/oradata\/control02.ctl' scope = spfile;<\/pre>\n<ul>\n<li>Perform a consistent shutdown of the database.<\/li>\n<\/ul>\n<pre>ORCL&gt; shu immediate;<\/pre>\n<ul>\n<li>Copy control files, datafiles, and online redo logs from local file system into the directory +DATA\/orcl\/oradata in DATA diskgroup using ASMCMD.<\/li>\n<\/ul>\n<pre>ASMCMD&gt; mkdir +DATA\/orcl\/oradata\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">control01.ctl<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/control01.ctl -&gt; +DATA\/orcl\/oradata\/control01.ctl\r\n \r\nASMCMD&gt; cp \/u01\/app\/oracle\/flash_recovery_area\/orcl\/<span style=\"color:red\">control02.ctl<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/flash_recovery_area\/orcl\/control02.ctl -&gt; +DATA\/orcl\/oradata\/control02.ctl\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">system01.dbf<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/system01.dbf -&gt; +DATA\/orcl\/oradata\/system01.dbf\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">sysaux01.dbf<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/sysaux01.dbf -&gt; +DATA\/orcl\/oradata\/sysaux01.dbf\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">undotbs01.dbf<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/undotbs01.dbf -&gt; +DATA\/orcl\/oradata\/undotbs01.dbf\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">users01.dbf<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/users01.dbf -&gt; +DATA\/orcl\/oradata\/users01.dbf\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">example01.dbf<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/example01.dbf -&gt; +DATA\/orcl\/oradata\/example01.dbf\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">redo01.log<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/redo01.log -&gt; +DATA\/orcl\/oradata\/redo01.log\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">redo02.log<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/redo02.log -&gt; +DATA\/orcl\/oradata\/redo02.log\r\n\r\nASMCMD&gt; cp \/u01\/app\/oracle\/oradata\/orcl\/<span style=\"color:red\">redo03.log<\/span> +DATA\/orcl\/oradata\/\r\ncopying \/u01\/app\/oracle\/oradata\/orcl\/redo03.log -&gt; +DATA\/orcl\/oradata\/redo03.log<\/pre>\n<ul>\n<li>Bring the database to the mount stage and verify that control files have been read from their new location in DATA disk group:<\/li>\n<\/ul>\n<pre>SQL&gt; startup mount;\r\nORACLE instance started.\r\n\r\nTotal System Global Area  272019456 bytes\r\nFixed Size                  1335924 bytes\r\nVariable Size             247467404 bytes\r\nDatabase Buffers           20971520 bytes\r\nRedo Buffers                2244608 bytes\r\nDatabase mounted.\r\n  \r\nSQL&gt; select name from v$controlfile;\r\n\r\nNAME\r\n----------------------------------------------------------------------\r\n<span style=\"color:red\">+DATA\/orcl\/oradata\/control01.ctl<\/span>\r\n<span style=\"color:red\">+DATA\/orcl\/oradata\/control02.ctl<\/span><\/pre>\n<ul>\n<li>Rename data files and online redo log files to point to their new location in DATA diskgroup:<\/li>\n<\/ul>\n<pre>ORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/system01.dbf' to '+DATA\/orcl\/oradata\/system01.dbf';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/sysaux01.dbf' to '+DATA\/orcl\/oradata\/sysaux01.dbf';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/undotbs01.dbf' to '+DATA\/orcl\/oradata\/undotbs01.dbf';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/users01.dbf' to '+DATA\/orcl\/oradata\/users01.dbf';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/example01.dbf' to '+DATA\/orcl\/oradata\/example01.dbf';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/redo01.log' to '+DATA\/orcl\/oradata\/redo01.log';\r\n\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/redo02.log' to '+DATA\/orcl\/oradata\/redo02.log';\r\nORCL&gt;alter database RENAME file '\/u01\/app\/oracle\/oradata\/orcl\/redo03.log' to '+DATA\/orcl\/oradata\/redo03.log';<\/pre>\n<ul>\n<li>Open the database and verify that the data files and online redo log files have been read from their new location in DATA diskgroup:<\/li>\n<\/ul>\n<pre>ORCL&gt;alter database open;\r\n    \r\nSQL&gt; select name from v$datafile;\r\n\r\nNAME\r\n----------------------------------------------------------------------\r\n+DATA\/orcl\/oradata\/system01.dbf\r\n+DATA\/orcl\/oradata\/sysaux01.dbf\r\n+DATA\/orcl\/oradata\/undotbs01.dbf\r\n+DATA\/orcl\/oradata\/users01.dbf\r\n+DATA\/orcl\/oradata\/example01.dbf\r\n\r\nSQL&gt; select member from v$logfile;\r\n\r\nMEMBER\r\n----------------------------------------------------------------------+DATA\/orcl\/oradata\/redo03.log\r\n+DATA\/orcl\/oradata\/redo02.log\r\n+DATA\/orcl\/oradata\/redo01.log<\/pre>\n<p>We have successfully migrated all the datafiles, online redo log files and control files from local file system to ASM.<\/p>\n<p>Now, let&#8217;s migrate tempfile also to ASM.<\/p>\n<ul>\n<li>Find out name of the temporary tablespace and the tempfile associated with it.<\/li>\n<\/ul>\n<pre>SQL&gt; select name from v$tablespace;\r\n\r\nNAME\r\n------------------------------\r\nSYSTEM\r\nSYSAUX\r\nUNDOTBS1\r\nUSERS\r\nTEMP\r\nEXAMPLE\r\n\r\n6 rows selected.\r\nSQL&gt; select name from v$tempfile;\r\n\r\nNAME\r\n----------------------------------------------------------------------\r\n<span style=\"color:red; font-weight:bold\">\/u01\/app\/oracle\/oradata\/orcl\/temp01.dbf<\/span><\/pre>\n<ul>\n<li>In order to migrate the tempfile to ASM, add another tempfile on ASM diskgroup DATA and drop the earlier one.<\/li>\n<\/ul>\n<pre>SQL&gt; alter tablespace temp add tempfile '+DATA'; \r\n\r\nTablespace altered.\r\n\r\nSQL&gt; alter tablespace temp drop tempfile '\/u01\/app\/oracle\/oradata\/orcl\/temp01.dbf';                                       \r\n\r\nTablespace altered.\r\n\r\nSQL&gt; select name from v$tempfile;\r\n\r\nNAME\r\n----------------------------------------------------------------------+DATA\/orcl\/tempfile\/temp.272.918596139<\/pre>\n<p>Now, let&#8217;s migrate SPfile to ASM.<\/p>\n<ul>\n<li>Find out name and location of the SPfile on local file system.<\/li>\n<\/ul>\n<pre>SQL&gt; sho parameter spfile;\r\n\r\nNAME                    TYPE        VALUE\r\n----------------------- ----------- ----------------------------------------------------------\r\nspfile                  string      <Span style=\"font-weight:bold; color:red\">\/u01\/app\/oracle\/product\/11.2.0                                          \/db_1\/dbs\/spfileorcl.ora<\/Span><\/pre>\n<ul>\n<li>Create a copy of the SPFILE in the ASM disk group DATA and find out the name of the created file.<\/li>\n<\/ul>\n<pre>SQL&gt; create pfile from spfile;\r\n\r\nFile created.\r\n\r\nSQL&gt; create spfile = '+DATA' from pfile;\r\n\r\nFile created.\r\n\r\nASMCMD&gt; ls +DATA\/orcl\/PARAMETERFILE\r\n<span style=\"font-weight:bold; color:red\">spfile.271.918596231<\/span><\/pre>\n<ul>\n<li>In $ORACLE_HOME\/dbs create pfile initorcl.ora with an entry pointing to the new location of SPfile in ASM.<\/li>\n<\/ul>\n<pre>echo <span style=\"font-weight:bold; color:red\">'spfile=+DATA\/orcl\/PARAMETERFILE\/spfile.271.918596231'<\/span> &gt; $ORACLE_HOME\/dbs\/initorcl.ora<\/pre>\n<ul>\n<li>Rename the earlier SPfile on local filesystem. This step is not mandatory.<\/li>\n<\/ul>\n<pre>[oracle@node1 dbs]$ mv spfileorcl.ora spfileorcl.ora.bak<\/pre>\n<ul>\n<li>Restart the database and verify that SPfile has been read from its new location in ASM diskgroup DATA.<\/li>\n<\/ul>\n<pre>SQL&gt; startup force;\r\n\r\nSQL&gt; sho parameter spfile;\r\n\r\nNAME       TYPE        VALUE\r\n---------- ----------- ------------------------------\r\nspfile     string      <span style=\"font-weight:bold; color:red\">+DATA\/orcl\/parameterfile\/spfile.271.918596231<\/span><\/pre>\n<p>Thus we have successfully migrated all the datafiles, tempfiles, online redo log files, control files and SPfile for the database orcl from local file system to ASM using ASMCMD.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Oracle Database 10g Release 1 introduced Automatic Storage Management (ASM), a new framework for managing Oracle database files. ASM provides a foundation for highly efficient storage management with direct I\/O, redundancy, striping and load balancing. Files stored on ASM are evenly distributed across disks in a disk group and mirrored according to the policies defined in the disk grou&hellip;<\/p>\n","protected":false},"author":316217,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[143533],"tags":[48357,48359,4309],"coauthors":[],"class_list":["post-73097","post","type-post","status-publish","format-standard","hentry","category-oracle-databases","tag-asm","tag-asmcmd","tag-migration"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73097","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/316217"}],"replies":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/comments?post=73097"}],"version-history":[{"count":1,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73097\/revisions"}],"predecessor-version":[{"id":91597,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/posts\/73097\/revisions\/91597"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=73097"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/categories?post=73097"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=73097"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=73097"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}