69 FIGURE 2.10 The Control Panel ➢ Services window showing Oracle services Most (if not all) Oracle services are prefixed with the word Oracle followed by the ORACLE_HOME name for that service. Thus, if the ORACLE_HOME name is ora817, then all your Oracle service names will end with ora817. It may be, of course, that you will have more than one ORACLE_HOME name and therefore will have duplicate instances of a service that start with different names (for example, OracleOra816TNSListener and OracleOra817TNSListener). Following are some common services that you will stop: • All Instance/Database Services (These services start with the word OracleService, followed by the name of the database. Thus for an instance called Robert, the name of the associated service would be OracleServiceRobert.) • The Oracle TNS Listener Other services that may be running include • The Oracle Agent • The client cache • Oracle Connection Manager services (CMADMIN and CMAN) • The Data Gatherer Step 2: Remove All Oracle Services WARNING Do not do anything to your Registry until you have backed it up! Failure to follow this advice will cause this book to self-destruct. You have been warned… tick…tick…tick… tick…. REMOVING THE ORACLE SOFTWARE Oracle Essentials PART I Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 2 • INSTALLING, UPGRADING, AND MIGRATING ORACLE 70 Sometimes removing services manually is the only way to get it done right. To remove the services from the NT Registry: 1. Make sure you’ve stopped all Oracle services. 2. Now, before you do anything, back up your Registry. 3. Click Start ➢ Run and start REGEDIT. 4. Navigate to My Computer and then to the HKEY_LOCAL_MACHINE folder. Expand that folder and then expand SYSTEM, then ControlSet001, then SERVICES. 5. The SERVICES folder contains a subfolder for each service listed in the Control Panel Services window. Carefully remove each Oracle-related service from the Registry by highlighting its folder and pressing Delete. Step 3: Remove All Oracle Entries in the Registry The next step is to remove the software entries for Oracle from the Registry. Still in REGEDIT, find the HKEY_LOCAL_MACHINE folder and open the SOFTWARE sub- folder. Find the ORACLE folder and remove it. Then exit REGEDIT. Step 4: Remove All Oracle Software You are now almost home free (free of Oracle files, that is). Your final step is to remove all the Oracle software. Using Explorer, simply click on the uppermost Oracle software folder and delete away. Once this is complete, you have completely wiped Oracle off your NT system. Migrating/Updating to Oracle8i This section is for those of you very intelligent DBAs who have decided that you need to get your Oracle database running on Oracle8i. First we’ll make sure we know the difference between a migration and an upgrade. Then we’ll explore the various options available for migrating to Oracle 8i, including the MIG utility, the Data Migration Assistant (DMA), the EXP/IMP utilities, and the SQL*Plus COPY operation. Some of you are moving databases that are not supported by the Oracle8i direct migration process, and here you’ll find help with those sometimes more-complicated migrations. There’s also an extensive, comprehensive checklist for the migration process, step by step. Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 71 NOTE After doing literally hundreds of 7.x-to-8i migrations and several more hundred upgrades, we’ve included in this section some hints and suggestions from our experiences with these processes. We hope our advice about migrations in particular will help save you from a failed migration effort. Migration vs. Upgrade DBAs tend to use the terms migration and upgrade interchangeably when referring to transition from one version of the Oracle database to another. In fact, however, these terms have two very different meanings. Version numbers of Oracle software start with a major version number (6, 7, or 8) followed by a dot, then the release number (giving you 7.2, 7.3, 8.0, 8.1), and then a patch number (giving you 7.3.3 or 8.1.6). This numbering scheme may extend even further into four and five digits for various “one-off” patch sets from Oracle. Upgrad- ing means advancing to later release numbers within the same major version number. Migrating means advancing to subsequent major version numbers. Migrations often require a great deal more work, because significant changes usually occur when major version numbers change. Oracle generally supplies a migration utility to facilitate migrations. The process of upgrading is typically much easier; generally, you’ll run a single upgrade script and then a couple of other standard Oracle scripts. Upgrades between the one-off patch sets are usually easier yet, requiring only the running of some standard Oracle scripts, depending on the options your database system uses. Migrating a Pre-7.1 Database to Oracle8i If you are running your current database on an Oracle version prior to 7.1 and you have decided to migrate to Oracle8i, you’ve made a wise decision. Unfortunately, your migration path will be somewhat more limited and potentially complex than for those who have already migrated to Oracle7 or Oracle8. With pre-7.1 databases, you have only a few migration options. You can use the Oracle Export and Import utilities to move the data to Oracle8i. You can also use the SQL*Plus COPY command to move the data. Or you can opt to first migrate your database to a version of Oracle7 that will support more robust migration options to Oracle8i. Let’s take a look at the various migration paths available to Oracle6 DBAs. MIGRATING/UPDATING TO ORACLE8i Oracle Essentials PART I Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 2 • INSTALLING, UPGRADING, AND MIGRATING ORACLE 72 WARNING Migrations and upgrades are subject to many opportunities for massive failure. Don’t put a production database at risk by failing to plan and test your migration strategy. Then test it again to make sure you are comfortable with it. Finally, take the addi- tional precaution of having one of your DBA peers review it and test it again. Using the Export and Import Utilities The Import (IMP) and Export (EXP) programs are covered in much more detail in Chapter 11, but for now we’ll examine their use for doing migration. First you use EXP to create a logical backup of your database. This logical backup is dumped out to an operating system file. The dump file can then be used by IMP, which loads the data back into the same or another database. Here are the basic steps for this process: 1. Create an Oracle8i database. 2. Do a full export of the pre-7.1 database. 3. Do a full import of the dump file created in step 2 into the new Oracle8i database. 4. Check for any invalid objects, failures to import specific objects, and so on, as required. The Export/Import method isn’t a bad choice as long as the database is relatively small. Typically, if the amount of data to be exported is greater than 2GB, this solu- tion may become impractical. In this case, you’d consider the option to migrate first to a database under Oracle 7.0 or later, and then to Oracle8i (as explained shortly). TIP If your SYSTEM tablespace is badly fragmented, and your data dictionary tables are fragmented into many extents (SYS.SOURCE$), the Import/Export migration might be an advantage. That’s because it will allow you to rebuild your data dictionary and the SYSTEM tablespace, and performance may improve. Using the SQL*Plus COPY Command In our opinion, using the SQL*Plus COPY command is, at best, a kludgy answer to migration. You have to create the Oracle8i database first, and then use the SQL*Plus COPY command to create the tables and copy the data into those tables. You then have to create any indexes, primary keys, foreign key constraints, load triggers, Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 73 functions, procedures, and so on, as required. This is a great deal more work than what’s needed for the migration utility, which we will discuss shortly. Note that you can use a combination of these first two options, Import/Export and the SQL*Plus COPY command, to make the job easier. Here’s how: 1. Create the Oracle8i instance and the basic database shell (SYSTEM tablespace, rollback segments, temporary tablespace, and so on), including all tablespaces that will be needed. 2. Do a full export of the Oracle database you are migrating. Use the ROWS=N parameter in the export so that only the logical structure of the database is exported and not the data. (See Appendix C for syntax of the SQL*Plus COPY command.) 3. Into the new Oracle8i database, import the exported dump file created in step 2. This creates all structures, indexes, tables, stored code, and so on. 4. You may wish to disable all primary keys and wait to build indexes until after the load has completed. This will speed up the load process significantly because index updates will not occur during the load processes. Migrating to Oracle7 and Then to Oracle8i If you are migrating a pre-Oracle 7.1 database, you won’t be able to migrate directly to Oracle8i with the Oracle migration utility (MIG, discussed shortly) or the Database Migration Assistant (both of which we will discuss shortly). If your pre-Oracle 7.1 database is smaller than 2GB or so, it may be more expedient to migrate using just the Oracle Export and Import utilities. For larger databases, however, MIG is usually your best choice for upgrading. In any of these cases, you’ll need to determine how to migrate the pre-Oracle 7.1 database first to Oracle version 7.1 or later. This is because the Oracle8i migration process doesn’t support migrating from a version of the Oracle database that is earlier than Oracle 7.1. Refer to the Oracle 7.1 migration instructions for the version from which you are migrating. Once you have migrated to Oracle 7.1, you can move for- ward to Oracle8i. Migrating an Existing 7.1+ Database to Oracle8i You’ve waited for Oracle8 to mature and you figure it’s time to get on the Oracle8i bandwagon (not to mention that Oracle is pulling support for Oracle7). There are several options available for migrating your database to Oracle8i. These include the Oracle MIG utility, the Data Migration Assistant (DMA), the EXP/IMP utilities, and MIGRATING/UPDATING TO ORACLE8i Oracle Essentials PART I Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 2 • INSTALLING, UPGRADING, AND MIGRATING ORACLE 74 the SQL*Plus COPY operation. The last two options work just as described above for pre-7.1 databases. Here, let’s look at the MIG utility and then the DMA. The Oracle Migration Utility The Migration utility (MIG) facilitates migrations from supported Oracle7 databases (usually 7.1 and above) to Oracle8i. This utility modifies the Oracle7 data dictionary, making it compatible with the new Oracle8i data dictionary structures. In the process, it re-creates the entire Oracle7 data dictionary as an Oracle8i data dictionary, adding and removing columns, tables, and indexes as required. The MIG utility does not change the fundamental database structures at all, and the original data dictionary tables are left intact (although the views on those tables are removed). Because the Oracle7 data dictionary tables are left intact by MIG, you can recover the Oracle7 database easily should the MIG utility fail. You simply rerun the various database conversion scripts, such as catalog, catproc, and catrep, and you’re in business. Once you determine why MIG failed, you can rerun it without any problem. The MIG utility creates a schema in the database called MIGRATE. Before you start the migration process, make sure you don’t already have a MIGRATE schema. After MIG is done working, it will have created a conversion file called conv<sid>.dbf file in the Oracle7 ORACLE_HOME. This file must be moved to the Oracle8i ORACLE_ HOME, as shown in step 20 of the migration instructions later in this section. Note that the MIG utility runs with the ORACLE_HOME of the database pointing to the Oracle7 software, not the Oracle8i software. This is because MIG precedes the actual conversion process that takes place when you issue the ALTER DATABASE CONVERT command. It’s this fact that makes it easy to recover the database should MIG fail. Once the ALTER DATABASE CONVERT command has been issued, though, it’s a whole different story. Running MIGPREP If you have already done some 7.3-to-8 migrations in UNIX, you’ll be happy to know that the method of installing the MIG utility has changed. Previously, you had to load MIG into the 7.3 ORACLE_HOME from the Oracle8 CD-ROM. Now, MIG loads into the Oracle8i ORACLE_HOME directory when you install the 8i software, and you need only run a new utility called MIGPREP to move the migration software, includ- ing MIG, to the Oracle7 ORACLE_HOME. The syntax for the MIGPREP utility is Migprep <Oracle8i ORACLE_HOME> <Oracle7 ORACLE_HOME> Thus, if you are installing the MIG utility from 8.1.6 to 7.3.4, your MIGPREP com- mand would look something like this: Migprep /ora01/oracle/product/8.1.6 /ora01/oracle/product/7.3.4 Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. Note that this does not apply to migrations on NT. The MIG utility can be run from the Oracle8i install on NT without a problem. A Checklist for Using MIG The sidebar “Checklist for Migrating Oracle7 to Oracle8i” presents a step-by-step process for supported Oracle 7.x migrations to Oracle8i. This checklist has been through the test of time, updated and improved by Robert Freeman over the course of running many migrations and working through their problems. We recommend you print it out from the book’s CD-ROM and use it during your migrations to Oracle8i. This checklist is current as of Oracle version 8.1.7. And hey, if Robert has left any- thing out, feel free to write him at the e-mail address in the Introduction! Checklist for Migrating Oracle7 to Oracle8i 1. Verify successful backup of your database. 2. Install Oracle8i software on the server. 3. If you are running on NT, set the ORACLE_SID environment variable. If you are running on Unix, set up these environment variables for the Oracle7 environment: ORACLE_HOME, ORACLE_SID, PATH, LD_LIBRARY_PATH, ORA_NLS, ORACLE_BASE, and ORACLE_PATH (if set). 4. Unix only: If this is the first 7-to-8 migration for your Unix Oracle system, run the MIGPREP script to copy migration files to the Oracle7 environment. migprep /ora01/oracle/product/8.1.6.0 /ora01/oracle/product/7.3.4.4 5. In /tmp, create a directory and subdirectory called mig and mig/<sid> (if they don’t already exist). 6. Remove all rows (via TRUNCATE) from the aud$ table. 7. Modify the following parameters in the initsid.ora (don’t forget to save a copy of the original file!): job_queue_processes=0 audit_trail=None 75 MIGRATING/UPDATING TO ORACLE8i Oracle Essentials PART I Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. 8. Confirm the version of the MIG utility. It should be the Oracle8i version to which you are migrating. To do this, print the MIG help screen, which will include the version of the utility. You’ll run MIG from the Oracle 7.3 ORACLE_HOME on Unix, and from the newly installed Oracle8i ORACLE_HOME on NT. Run MIG with this command: Mig help=y which produces this output: ORACLE7 to ORACLE8 Migration Utility Release 8.1.6.0.0 - Production 9. Shut down the database with SHUTDOWN IMMEDIATE. 10. Run the MIG utility with the CHECK_ONLY option to ensure that enough space is available in the database for the migration process. Unix example: From the Oracle 7.3 ORACLE_HOME, enter this command (note that the slashes before the quotes are required): mig CHECK_ONLY=TRUE SPOOL=\”/tmp/mig/<dbname>_check_only.out\” NT example: From the newly installed Oracle8i ORACLE_HOME, enter mig CHECK_ONLY=TRUE SPOOL=”c:\mig\<dbname>_check_only.out” pfile=<ORACLE7 parameter file> 11. Check the data dictionary tables for fragmentation and/or excessive numbers of extents. Modify the migrate.bsq as required. The following script will look for fragmented data dictionary objects. If an excessive number of these exist, consider modifying these objects in the migrate.bsq so they will fit in fewer extents. SELECT a.owner, a.segment_name, a.segment_type, a.extents, b.initial_extent, b.next_extent FROM dba_segments a, dba_tables b WHERE a.owner=b.owner and a.segment_name=b.table_name and a.owner=’SYS’ and a.extents > 5 UNION SELECT a.owner, a.segment_name, a.segment_type, a.extents, b.initial_extent, b.next_extent CHAPTER 2 • INSTALLING, UPGRADING, AND MIGRATING ORACLE 76 Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. FROM dba_segments a, dba_indexes b WHERE a.owner=b.owner and a.segment_name=b.index_name and a.owner=’SYS’ and a.extents > 5; 12. Make sure the SYSTEM rollback segment does not have an optimal setting. Use the following query to check the OPTIMAL setting for the SYSTEM rollback segment. If the SYSTEM rollback segment is set to OPTIMAL, you will need to use the ALTER ROLLBACK SEGMENT command to reconfigure it so that OPTIMAL is NULL. SELECT a.usn, a.name, b.optsize FROM v$rollname a, v$rollstat b WHERE a.usn = b.usn AND name = ‘SYSTEM’; ALTER ROLLBACK SEGMENT SYSTEM STORAGE (OPTIMAL NULL); 13. Check the SYSTEM tablespace of the database to ensure that it has sufficient con- tiguous space. The SYSTEM tablespace should have a few chunks of space that are moderate to large. If it does not, consider adding to the size of the existing system tablespace database datafiles, or adding a new datafile as required. SELECT tablespace_name, bytes FROM dba_free_space WHERE tablespace_name = ‘SYSTEM’; 14. Check the DBA_2PC_PENDING table for any unresolved distributed transactions. If there are any unresolved transactions, see Chapter 22. SELECT * FROM dba_2pc_pending; 15. Shut down the Oracle database with a normal or immediate shutdown. Do not do a shutdown abort. 16. Run the Oracle8i Migration utility: Unix example (still set up for the ORACLE7 environment): mig SPOOL=\”/tmp/mig/<sid>_migration.out\” NT example: mig SPOOL=”c:\mig\<dbname>_check_only.out” pfile=<ORACLE7 parameter file> 17. Check the output file after running the Migration utility. If the utility ran correctly, you may wish to do another backup of the database at this point. (We rarely do this in practice, however, since we use a special backup/recovery method described later in this section, and it doesn’t take as long to rerun the MIG process as it does to recover the database.) 77 MIGRATING/UPDATING TO ORACLE8i Oracle Essentials PART I Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark. CHAPTER 2 • INSTALLING, UPGRADING, AND MIGRATING ORACLE 78 18. If you are running on Unix, set up the following environment variables for the Oracle8i environment: ORACLE_HOME, ORACLE_SID, PATH, LD_LIBRARY_PATH, ORA_NLS, ORACLE_BASE, and ORACLE_PATH (if set). If you are running on NT, take these steps: • Stop the Oracle service for your database: NET STOP OracleServiceORCL • Delete the Oracle7 service on NT using the ORADIM7x commands: ORADIM71 -delete -sid ORCL ORADIM72 -delete -sid ORCL ORADIM73 -delete -sid ORCL • Restart the system. • Create the Oracle8i service for the newly migrated Oracle8i database, using the ORADIM command. (See the NT-specific documentation for instructions on using ORADIM.) Here is an example: ORADIM -NEW -SID ORCL -INTPWD MYPASSWORD -MAXUSERS 200 -STARTMODE AUTO -PFILE ORACLE_HOME\DATABASE\INITSID.ORA 19. Remove or rename the database control files. Alternatively, you can change the CONTROL_FILES initialization parameter to specify new location and/or names for the control files. The CONTROL_FILES initialization parameter typically is set in the initsid.ora file. 20. Move or copy the convert file from the Oracle7 ORACLE_HOME to the Oracle8i ORACLE_HOME. On most Unix systems, in both the Oracle7 and the Oracle8i envi- ronments, the convert file (convsid.dbf, where sid is the Oracle8i database name), should reside in $ORACLE_HOME/dbs; in an NT system, it’s in ORACLE_HOME\database. Unix example: cp /ora01/oracle/product/7.3.4.4/dbs/convsid.dbf /ora01/oracle/product/8.1.6.0/dbs/convsid.dbf NT example: copy c:\oracle\product\7.3.4.4\database\convsid.dbf c:\ora01\oracle\product\8.1.6.0\database\convsid.dbf Copyright ©2002 SYBEX, Inc., Alameda, CA www.sybex.com Please purchase PDF Split-Merge on www.verypdf.com to remove this watermark.