1. Trang chủ
  2. » Công Nghệ Thông Tin

OCA /OCP Oracle Database 11g A ll-in-One Exam Guide- P81 pot

10 114 1

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 10
Dung lượng 225,87 KB

Nội dung

OCA/OCP Oracle Database 11g All-in-One Exam Guide 756 128KB stripes, in what is known as “fine” striping. Thus there will be lower latency in satisfying the (typically, small) requests for reads and writes of these file types, because the one small request can be split up into several even smaller requests directed to each disk in the group in parallel. The syntax for creating and managing ASM files is exactly the same as for file system–based files. All ASM files are created and managed by the RDBMS instance, using the usual commands. The only difference is in the filename: when creating a database file, you specify only the name of the disk group to which the file should be directed, and ASM will generate the actual filename and manage the physical locations. There is a one-to-one relationship between a database file and an ASM file. If your database has 200 datafiles using conventional file system storage, it will still have 200 datafiles when you convert to ASM. But they will no longer exist as individual files that you can see with operating system utilities. In fact, normal operating system commands will not be able to see anything at all within the ASM disks, because they are not formatted with a file system. This means that the only way to get at ASM files is through Oracle utilities. This is not a problem at all, but it does mean that you must use RMAN to back up your ASM datafiles, archive logs, and controlfiles. ASM files can coexist with files stored within file systems. There is no reason why a tablespace should not consist of one ASM file and one conventional file, but there would be no purpose in such an arrangement. However, this does mean that it is possible to migrate a database to ASM over time, by moving the various files whenever convenient. Because you cannot write to an ASM disk group with any operating system tools, for datafiles this move must be accomplished with RMAN through a backup and restore operation. To move online logs, create new members in an ASM disk group and drop the old members. Creating Raw Devices Your system administrators will be responsible for creating the raw devices to be given to ASM. These may be whole disks, partitions of a disk, or RAID devices provided by a logical volume manager. Whatever they are, there will be some operating system syntax that lets Oracle address them: a Unix raw device will be addressed through a block device driver in the /dev directory; Windows will address it through a \\.\ path name. On a Windows PC, you could use the Microsoft Management Console Disk Management snap-in to create the devices. On a Linux PC, you could use the fdisk utility. Larger systems will have an LVM, either part of the operating system or a third- party product such as Veritas. Exercise 20-1: Create Raw Devices If you can create raw devices on your system, or have a system administrator who can provide them, you will need to do so now for the purposes of the exercises that follow. They do not need to be particularly large—a few hundred megabytes will do. If you cannot create raw devices, it is possible Chapter 20: Automatic Storage Management 757 PART III to simulate raw devices by using files. Creating simulated raw devices is the purpose of this exercise. There are two sets of instructions: first for Linux, then for Windows. 1. Linux: Use the dd command to create empty two empty files, of 1GB each, in a directory of your choice. For example, dd if=/dev/zero of=/u01/app/oracle/raw1.disk bs=1024 count=1000000 dd if=/dev/zero of=/u01/app/oracle/raw2.disk bs=1024 count=1000000 The files raw1.disk and raw2.disk will consist of one million blocks, each containing 1KB of nothing. 2. Windows: Locate any large file, which is a multiple of 1024 bytes, and copy it twice to a directory of your choice. In this example, the file happens to be an ISO image of a compact disc: copy \tmp\oel5\d1.iso \app\oracle\raw1.disk copy \tmp\oel5\d1.iso \app\oracle\raw2.disk The files created will be formatted by ASM when they are assigned to a disk group. ASM will make some checks (it will not, for example, accept a copy of an Oracle datafile) but pretty much any file should do as the source. If you have a problem, try again with a different file. Creating, Starting, and Stopping an ASM Instance An ASM instance is controlled by an instance parameter file, as is an RDBMS instance, but there are strict limits on the parameters that can be included. Many will cause an ASM instance to have errors on startup, so keep the parameter file as small as possible. The parameters most likely to be needed (and often all that are required) are listed in Table 20-1. Parameter Required? Description instance_type Yes Must be ASM for an ASM instance. Default is RDBMS. instance_name No Must be prefixed with “+”. Defaults to the ORACLE_SID environment variable. asm_power_limit No Controls the number of ASMB processes to be used for rebalancing operations. Default is 1, the lowest. asm_diskstring Yes List of paths identifying the disks to be given to ASM. asm_diskgroups No Disk groups to be mounted on startup. Default is NULL. Table 20-1 Common ASM Initialization Parameters OCA/OCP Oracle Database 11g All-in-One Exam Guide 758 An ASM parameter file for Windows might take this form: instance_name='+asm' instance_type='asm' asm_diskstring='\\.\*:' asm_diskgroups=dgroupA,dgroupB The instance name must be prefixed with a “+” symbol, on all platforms. On Windows, this must also be specified when creating the Windows service for the instance. The syntax for the ASM_DISKSTRING will be platform specific. In the example, Oracle will find every device, as indicated by the “\\.\” characters, that includes the “:” character in its name. All Windows disk devices that have been assigned a drive letter will have a “:” in their name, so this string will find all devices that have been assigned a drive letter. The two nominated disk groups, dgroupA and dgroupB, must exist; if this is the first startup of the ASM instance, omit this parameter and set it only after the groups have been created. Many databases will require only two disk groups: one for the live database files, the other for the flash recovery area. Wildcard characters (such as the asterisk in the preceding example) can be used to let ASM find a number of devices without having to name them all individually. A Linux parameter file might look like this: instance_name='+asm' instance_type='asm' asm_diskstring='/dev/md2','/dev/md3','/dev/md4','/dev/md5' asm_diskgroups=dgroupA,dgroupB remote_login_passwordfile=exclusive This time the disk string has four distinct values, rather than using wildcards, which will let it find four named RAID devices. The two nominated disk groups must exist and be composed of the RAID volumes named in diskstring. In this example, there are no wildcards, but they could be used if desired. For example, if using Solaris this would let ASM find all disks on the second and third controllers: asm_disk_string='/dev/rdsk/c2*','/dev/rdsk/c3*' To start the instance, you must connect to it as SYSASM and issue a STARTUP command. The connection can be made by setting the ORACLE_SID environment variable to the instance name (not forgetting that it must be prefixed with a “+” symbol), or if a password file has been created and enabled as in the preceding example, you can connect with password file authentication. The startup will first go through NOMOUNT, where the instance is built in memory and the disks identified by the ASM_DISKSTRING parameter are discovered. Then the instance will mount the disk groups specified by ASM_DISKGROUPS. There is no MOUNT or OPEN mode for an ASM instance; disk groups can be mounted or unmounted. TIP The size of an ASM instance can, as in the preceding examples, be left completely on default. This will result in an instance of about 160MB. In most circumstances this is both sufficient and necessary. Chapter 20: Automatic Storage Management 759 PART III RDBMS instances use files in disk groups managed by the ASM instance. If the ASM instance has not started and mounted the disk groups, then the RDBMS instances cannot open. It is therefore necessary to ensure, through your operating system utilities, that the ASM instance starts before the RDBMS instances that are dependent upon it. If the ASM instance terminates, then the dependent RDBMS instances will terminate also. If, when a SHUTDOWN command is issued to an ASM instance, one or more RDBMS instances have opened files in one of its disk groups, then you will receive this message: ORA-15097: cannot SHUTDOWN ASM instance with connected RDBMS instance The exception is a SHUTDOWN ABORT, which will terminate the ASM instance and thus cause the termination of the RDBMS instance(s). TIP If an RDBMS instance fails, the ASM instance will not be affected. If an ASM instance fails, the dependent RDBMS instances will abort. Exercise 20-2: Create an ASM Instance Create a parameter file and use it to start an ASM instance. All steps in this exercise should be done from an operating system prompt. The examples assume that you are using simulated raw disks, as created in Exercise 20-1. If you have real raw devices, substitute their names accordingly, and omit the hidden parameter. Note that Step 2 is applicable only to Windows 1. Configure the Cluster Synchronization Services Daemon. This requires running the localconfig utility, in the ORACLE_HOME/bin directory. On Unix, this must be run as the root user: localconfig add On Windows, you will see that a service has been created and put on automatic start called OracleCSService; on Unix, you will see an entry in the /etc/ inittab file that will respawn the init.cssd process at run levels 3 and 5. 2. From an operating system prompt, run the ORADIM utility to create a Windows service for the ASM instance. C:\> oradim -new -asmsid +ASM -startmode manual This will create and start the ASM service. Subsequently, it must be started either from the Control Panel Services, or with this command from the operating system prompt: C:\> net start oracleasmservice+ASM 3. If using Windows, use the Notepad to create a file named INIT+ASM.ORA in the ORACLE_HOME\database directory, with just these four lines: instance_name='+asm' instance_type='asm' asm_diskstring='c:\app\oracle\raw*.disk' _asm_allow_only_raw_disks=false OCA/OCP Oracle Database 11g All-in-One Exam Guide 760 If using Linux, use an editor such as vi to create a file named init+asm.ora in the ORACLE_HOME/dbs directory with these five lines: instance_name='+asm' instance_type='asm' asm_diskstring='/u01/app/oracle/raw*.disk' _asm_allow_only_raw_disks=false memory_target=0 Note the use of the parameter _ASM_ALLOW_ONLY_RAW_DISKS. This is a “hidden” parameter (use of which is not supported) that will allow ASM to use files rather than raw devices for the purposes of this exercise. The last parameter disables automatic memory management, which is necessary on some Linux systems depending on how shared memory has been configured. 4. Set your ORACLE_SID environment variable to the ASM instance name. 5. Connect to the ASM instance with SQL*Plus as SYSASM, and start the instance. 6. Confirm that ASM has found the disks with this SQL statement: select path,os_mb from v$asm_disk; The illustration shows Steps 3, 4, and 5 executed on a Windows system. Creating ASM Disk Groups Disk groups are created by an ASM instance and then used by an RDBMS instance. To create a disk group, as a minimum, give the group a name and a list of disks that have been discovered by the ASM disk string and are therefore visible in the V$ASM_DISK view: SQL> create diskgroup dg1 disk '/dev/sdc', '/dev/sdd', '/dev/sde', '/dev/sdf'; Chapter 20: Automatic Storage Management 761 PART III If you nominate a disk that is already part of a disk group, the command will fail. The default level of redundancy provided by ASM is “normal” redundancy, meaning that each AU is mirrored once. All files will be striped across all the disks for maximum performance. For normal redundancy, the group must have at least two disks, and the effective size of the group will be half the total space allocated. In the preceding example, which continues the Linux four-SCSI-disk example discussed earlier, the result will be a disk group with an effective size of 144GB (less a small amount). Every file created in the group will (unless specified otherwise) be striped and mirrored with RAID 0+1. The stripe size will be selected by ASM according to the type of file: online redo log files and controlfile copies will be fine striped; datafiles and archive logs will be coarse striped. To override the default NORMAL redundancy, meaning single mirror, add the keywords HIGH REDUNDANCY or EXTERNAL REDUNDANCY to the CREATE DISKGROUP command. HIGH REDUNDANCY will create three copies of every allocation unit (and therefore requires a minimum of three disks), and EXTERNAL REDUNDANCY will not mirror at all: the assumption is that there is an underlying LVM that is doing whatever level of RAID is deemed appropriate. Redundancy can be taken a step further by putting ASM disks within a disk group into failure groups. When ASM mirrors extents, it will never mirror an extent to another disk in the same failure group. This means that you are better protected against the failure of multiple disks. By default, each disk is considered to be its own failure group; this gives ASM complete freedom to mirror that disk’s data onto any other disk in the group. However, if some disks are connected at the hardware level, typically by being attached to the same controller, you would not want ASM to mirror between them. Using failure groups forces ASM to create mirrors on a different subset of the disks within the group. An example of this is SQL> create diskgroup dgroupa normal redundancy failgroup controller2 disk '/dev/rdsk/c2*' failgroup controller3 disk '/dev/rdsk/c3*'; This command creates a disk group consisting of all the disk devices matched by the wildcards given, which is all the disks hanging off the second and third controllers. But the use of failure groups (their names are not significant) instructs ASM never to mirror data between two disks that are on the same controller. Exercise 20-3: Create a Disk Group Use the ASM instance created in Exercise 20-2 to create a disk group with the two raw volumes created in Exercise 20-1. 1. From an operating system prompt, set your ORACLE_SID environment variable to the ASM instance. 2. Connect to your ASM instance with SQL*Plus with the SYSASM privilege using operating system authentication, and start the instance. 3. Create a disk group, nominating the two raw volumes listed in Step 5 of Exercise 20-2. create diskgroup dg1 disk 'C:\APP\ORACLE\RAW1.DISK', 'C:\APP\ORACLE\RAW2.DISK'; OCA/OCP Oracle Database 11g All-in-One Exam Guide 762 4. Confirm the creation of the group by querying the relevant views. select name,group_number,type,state,total_mb from v$asm_diskgroup; Note that the group has NORMAL redundancy, so the total space available will be effectively halved. The group is MOUNTED, meaning that it is available for use. The illustration shows Steps 1 through 4 on a Linux system. 5. To ensure that the disk group is mounted automatically when the ASM instance starts, add this line to the ASM instance parameter file created in Exercise 20-2, Step 3: asm_diskgroups=dg1 If this is not done, you will have to mount the disk group manually every time you start the ASM instance: alter diskgroup dg1 mount; Creating and Using ASM Files The ASM disk groups are created in the ASM instance; the ASM files are created in the RDBMS instance. The normal commands for creating datafiles, tempfiles, and log files can all take a disk group name in place of a filename. For example, Chapter 20: Automatic Storage Management 763 PART III SQL> create tablespace new_tbs datafile '+dg1' size 100m; SQL> alter tablespace system add datafile '+system_dg' size 1000m; SQL> alter database add logfile group 4 '+dg_log1','+dg_log2' size 100m; The first of these commands creates a new tablespace with one datafile in the disk group DG1. The second command adds a datafile to the SYSTEM tablespace, in a disk group created specially for the SYSTEM datafiles; this will probably be a disk group created with HIGH redundancy. The third command creates a new online log file group, with two members in different disk groups; these will likely be groups with EXTERNAL redundancy, because you can rely on the multiplexing to provide fault tolerance. To direct archive logs to ASM, set the LOG_ARCHIVE_DEST parameters to point to disk groups: SQL> alter system set log_archive_dest_1='location=+dg_arc1'; SQL> alter system set log_archive_dest_2='location=+dg_arc2'; It is also possible to direct the flash recovery area to an ASM disk group: SQL> alter system set db_recovery_file_dest='+dg_flash'; In all these examples, you do not specify a filename, only a disk group. ASM will generate the actual filenames according to its own conventions. If you wish, you can see the names by querying views such as V$DATAFILE, V$LOGFILE, or V$ARCHIVED_ LOG, but there is little value in this. A feature of ASM is that it gives you complete independence from the physical storage: there is no reason for you to want to know the actual filenames. It is possible to interpret the system-generated names, but they are not any sort of physical path. Exercise 20-4: Use ASM for Datafiles Create a tablespace in the disk group created in Exercise 20-3. 1. Connect to your RDBMS instance with SQL*Plus as user SYSTEM. Ensure that your ORACLE_SID environment variable is set to the name of your RDBMS instance first. 2. Create a tablespace with a datafile in your ASM disk group. SQL> create tablespace new_tbs datafile '+dg1' size 100m; 3. Find the filename of the new datafile. SQL> select file_name from dba_data_files where tablespace_name='NEW_TBS'; FILE_NAME +DG1/orcl/datafile/new_tbs.256.675459139 ASM and RMAN Since ASM files are created on raw devices managed by Oracle, there is no way that you can back up ASM files with operating system utilities: no regular operating system command or utility can see the contents of an ASM disk, because it has no file system OCA/OCP Oracle Database 11g All-in-One Exam Guide 764 installed upon it. You must use RMAN. The RMAN backup and restore and recover commands do not change at all when using ASM; wherever you would use a filename, enter the ASM filename. If your backup scripts specify tablespace names, or the whole database, then they will run unchanged. Apart from being required for regular backup and recovery procedures, RMAN is also the only tool available for migrating a database from conventional file system storage to ASM storage. The examples that follow assume that you have three disk groups: group dg1 is for your datafiles; groups dg2 and dg3 are for controlfiles and online redo log files. To migrate the controlfile, change the CONTROLFILES instance parameter to point toward your disk groups and then shut down the database and start it in NOMOUNT mode: SQL> alter system set controlfiles='+dg2','+dg3' scope=spfile; SQL> shutdown immediate; SQL> startup nomount; Then launch RMAN, and restore the controlfile from its original location: RMAN> restore controlfile from '/u01/app/oracle/oradata/orcl/control01.ctl'; You can now mount and open the database, using the controlfile on the ASM device. From an RMAN prompt, this script will migrate all your datafiles to an ASM disk group: shutdown immediate; startup mount; backup as copy database format '+dg1'; switch database to copy; alter database open; To migrate the redo logs, create new members in your disk groups and drop the old members: SQL> alter database add logfile member '+dg2','+dg3' to group 1; SQL> alter database drop logfile member '/u01/app/oracle/oradata/orcl/redo01a.log', '/u01/app/oracle/oradata/orcl/redo01b.log '; Finally, you must move your temporary tablespace tempfiles. Since these cannot be backed up, the technique is to drop them and create new files on a disk group. It may be simpler just to create a new temporary tablespace, and drop the original temporary tablespace: create temporary tablespace tempasm tempfile '+dg1' size 1g; alter database default temporary tablespace tempasm; drop tablespace temp including contents and datafiles; EXAM TIP RMAN is the only tool you can use to back up ASM files. User- managed backups are not possible, because operating system utilities cannot see ASM files. Chapter 20: Automatic Storage Management 765 PART III The ASMCMD Utility In order to make administration of ASM files simpler, Oracle provides a command-line utility that gives a Unix-like interface to ASM. This is the ASMCMD utility, named %ORACLE_HOME%\bin\asmcmd.bat on Windows and $ORACLE_HOME/bin/asmcmd on Unix. To run the tool, you must first set your ORACLE_SID environment variable to the name of the ASM instance, and then a set of commands are available with functionality and syntax similar to that of a Unix file system. The commands are summarized in Table 20-2. Most of the ASMCMD commands are self-explanatory and follow standard (although much simplified) Unix in their syntax. Two do require special attention: the md_backup and md_restore commands. These let you recreate a disk group. They do not back up or restore any files in the disk group (the files must be protected by other means, usually RMAN), but they do make it possible to extract the metadata describing the disk groups and the disks of which they are composed. This would be necessary in the event of a disaster recovery operation. If the machine hosting the ASM instance and its attached disks were lost and had to be replaced, then after creating an ASM instance on a replacement machine (which should ideally have the same disk configuration), restoring the metadata would recreate the disk groups. Then using RMAN, the files themselves could be restored. Command Description help View available commands and usage cd Navigate around the ASM directory structure cp Copy a file du Return the space used in a directory find Find a file ls List contents of a directory lsct List connected RDBMS instances lsdg List the disk groups mkalias Create an alias name for a file mkdir Create a directory pwd Display the current ASM directory rm Delete a file rmalias Delete a file alias md_backup Back up the metadata describing a disk group md_restore Restore the metadata describing a disk group lsdsk List the discovered disks remap Attempt to repair damaged disk blocks Table 20-2 ASMCMD Commands . lines: instance_name='+asm' instance_type='asm' asm_diskstring='c:app oracle raw*.disk' _asm_allow_only_raw_disks=false OCA/ OCP Oracle Database 11g All-in-One Exam Guide 760 . Parameters OCA/ OCP Oracle Database 11g All-in-One Exam Guide 758 An ASM parameter file for Windows might take this form: instance_name='+asm' instance_type='asm' asm_diskstring='\.*:' asm_diskgroups=dgroupA,dgroupB The. Exercise 20-2. create diskgroup dg1 disk 'C:APP ORACLE RAW1.DISK', 'C:APP ORACLE RAW2.DISK'; OCA/ OCP Oracle Database 11g All-in-One Exam Guide 762 4. Confirm the creation of the

Ngày đăng: 06/07/2014, 13:20

TỪ KHÓA LIÊN QUAN